Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal compiler error: unexpected panic #9414

Closed
yonip23 opened this issue Sep 2, 2022 · 8 comments · Fixed by #9417
Closed

internal compiler error: unexpected panic #9414

yonip23 opened this issue Sep 2, 2022 · 8 comments · Fixed by #9417

Comments

@yonip23
Copy link
Contributor

yonip23 commented Sep 2, 2022

Hey all, I get this message when running clippy nightly on my project:

thread 'rustc' panicked at 'assertion failed: !value.has_escaping_bound_vars()', /rustc/2e35f954ada0f0c777844dc4fa66684efe90a035/compiler/rustc_middle/src/ty/sty.rs:1028:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/2e35f954ada0f0c777844dc4fa66684efe90a035/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/2e35f954ada0f0c777844dc4fa66684efe90a035/library/core/src/panicking.rs:142:14
   2: core::panicking::panic
             at /rustc/2e35f954ada0f0c777844dc4fa66684efe90a035/library/core/src/panicking.rs:48:5
   3: rustc_trait_selection::traits::type_known_to_meet_bound_modulo_regions
   4: <rustc_infer::infer::InferCtxtBuilder>::enter::<bool, rustc_ty_utils::common_traits::is_item_raw::{closure#0}>
   5: rustc_ty_utils::common_traits::is_sized_raw
   6: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_middle::ty::ParamEnvAnd<rustc_middle::ty::Ty>, bool>
   7: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::ParamEnvAnd<rustc_middle::ty::Ty>, bool>>
   8: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::is_sized_raw
   9: <rustc_middle::ty::Ty>::is_sized
  10: <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt>>::layout_of_uncached
  11: rustc_middle::ty::layout::layout_of
  12: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::layout_of, rustc_query_impl::plumbing::QueryCtxt>
  13: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::layout_of
  14: <core::iter::adapters::GenericShunt<core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::ty::FieldDef>, <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt>>::layout_of_uncached::{closure#5}::{closure#0}>, core::result::Result<core::convert::Infallible, rustc_middle::ty::layout::LayoutError>> as core::iter::traits::iterator::Iterator>::next
  15: <alloc::vec::Vec<alloc::vec::Vec<rustc_target::abi::TyAndLayout<rustc_middle::ty::Ty>>> as alloc::vec::spec_from_iter::SpecFromIter<alloc::vec::Vec<rustc_target::abi::TyAndLayout<rustc_middle::ty::Ty>>, core::iter::adapters::GenericShunt<core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::ty::VariantDef>, <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt>>::layout_of_uncached::{closure#5}>, core::result::Result<core::convert::Infallible, rustc_middle::ty::layout::LayoutError>>>>::from_iter
  16: <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt>>::layout_of_uncached
  17: rustc_middle::ty::layout::layout_of
  18: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::layout_of, rustc_query_impl::plumbing::QueryCtxt>
  19: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::layout_of
  20: <core::iter::adapters::GenericShunt<core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::ty::FieldDef>, <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt>>::layout_of_uncached::{closure#5}::{closure#0}>, core::result::Result<core::convert::Infallible, rustc_middle::ty::layout::LayoutError>> as core::iter::traits::iterator::Iterator>::next
  21: <alloc::vec::Vec<alloc::vec::Vec<rustc_target::abi::TyAndLayout<rustc_middle::ty::Ty>>> as alloc::vec::spec_from_iter::SpecFromIter<alloc::vec::Vec<rustc_target::abi::TyAndLayout<rustc_middle::ty::Ty>>, core::iter::adapters::GenericShunt<core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::ty::VariantDef>, <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt>>::layout_of_uncached::{closure#5}>, core::result::Result<core::convert::Infallible, rustc_middle::ty::layout::LayoutError>>>>::from_iter
  22: <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt>>::layout_of_uncached
  23: rustc_middle::ty::layout::layout_of
  24: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::layout_of, rustc_query_impl::plumbing::QueryCtxt>
  25: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::layout_of
  26: <core::iter::adapters::GenericShunt<core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::ty::FieldDef>, <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt>>::layout_of_uncached::{closure#5}::{closure#0}>, core::result::Result<core::convert::Infallible, rustc_middle::ty::layout::LayoutError>> as core::iter::traits::iterator::Iterator>::next
  27: <alloc::vec::Vec<alloc::vec::Vec<rustc_target::abi::TyAndLayout<rustc_middle::ty::Ty>>> as alloc::vec::spec_from_iter::SpecFromIter<alloc::vec::Vec<rustc_target::abi::TyAndLayout<rustc_middle::ty::Ty>>, core::iter::adapters::GenericShunt<core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::ty::VariantDef>, <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt>>::layout_of_uncached::{closure#5}>, core::result::Result<core::convert::Infallible, rustc_middle::ty::layout::LayoutError>>>>::from_iter
  28: <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt>>::layout_of_uncached
  29: rustc_middle::ty::layout::layout_of
  30: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::layout_of, rustc_query_impl::plumbing::QueryCtxt>
  31: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::layout_of
  32: clippy_utils::ty::approx_ty_size
  33: clippy_lints::functions::result::check_impl_item
  34: <rustc_lint::early::EarlyLintPassObjects as rustc_lint::passes::EarlyLintPass>::check_attribute
  35: <rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects> as rustc_hir::intravisit::Visitor>::visit_nested_impl_item
  36: rustc_hir::intravisit::walk_item::<rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects>>
  37: <rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects> as rustc_hir::intravisit::Visitor>::visit_nested_item
  38: rustc_hir::intravisit::walk_mod::<rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects>>
  39: rustc_lint::late::late_lint_pass_crate::<rustc_lint::late::LateLintPassObjects>
  40: rustc_lint::late::late_lint_crate::<rustc_lint::BuiltinCombinedLateLintPass>
  41: <rustc_session::session::Session>::time::<(), rustc_lint::late::check_crate<rustc_lint::BuiltinCombinedLateLintPass, rustc_interface::passes::analysis::{closure#5}::{closure#1}::{closure#2}::{closure#0}::{closure#0}>::{closure#0}::{closure#0}>
  42: <rustc_session::session::Session>::time::<(), rustc_interface::passes::analysis::{closure#5}::{closure#1}::{closure#2}::{closure#0}>
  43: <core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::passes::analysis::{closure#5}::{closure#1}> as core::ops::function::FnOnce<()>>::call_once
  44: rustc_interface::passes::analysis
  45: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, (), core::result::Result<(), rustc_errors::ErrorGuaranteed>>
  46: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), core::result::Result<(), rustc_errors::ErrorGuaranteed>>>
  47: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
  48: <rustc_interface::passes::QueryContext>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
  49: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorGuaranteed>>
  50: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
  51: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>
  52: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new

note: Clippy version: clippy 0.1.65 (2e35f95 2022-09-01)

query stack during panic:
#0 [is_sized_raw] computing whether `dyn core::error::Error` is `Sized`
#1 [layout_of] computing layout of `*const dyn core::error::Error`
#2 [layout_of] computing layout of `core::ptr::non_null::NonNull<dyn core::error::Error>`
#3 [layout_of] computing layout of `core::ptr::unique::Unique<dyn core::error::Error>`
#4 [layout_of] computing layout of `alloc::boxed::Box<dyn core::error::Error>`
#5 [analysis] running analysis passes on this crate
end of query stack

Info

  1. clippy version (shown in the log): 0.1.65 (2e35f95 2022-09-01)
  2. rustc version: rustc 1.65.0-nightly (2e35f95 2022-09-01)
  3. cargo version: cargo 1.65.0-nightly (4ed54cecc 2022-08-27)
  4. The command I'm using to run clippy:
cargo +nightly clippy -p <my_crate> --all-features -- --no-deps -D clippy::pedantic -D clippy::print_stdout -A clippy::missing_panics_doc -A clippy::must_use_candidate -A clippy::missing_errors_doc -A clippy::module_name_repetitions -A clippy::implicit_hasher -A unknown-lints
  1. About my crate:
    1. It has 0 external dependencies, and is really small (one lib.rs with ~70 lines, and tests.rs with 12 lines)
    2. It has no "funny" code, no unsafe or anything
    3. It is part of a larger project with workspace configuration, and ~80 other crates (Idk if it helps, just trying to provide as much relevant context as I can)
  2. os: Ubuntu 20.04

Please lmk if there's anything else you need from me, and thank you for this amazing project! 🙂

@Jarcho
Copy link
Contributor

Jarcho commented Sep 2, 2022

I can't manage to make a repro. Can you share the code? It's failing on a Result type for some function.

@yonip23
Copy link
Contributor Author

yonip23 commented Sep 2, 2022

I can't manage to make a repro. Can you share the code? It's failing on a Result type for some function.

The Result hint allowed me to trim down chunks of my code and being able to reproduce with this minimal example:

use std::{
    error::Error,
    sync::{Mutex, MutexGuard},
};

#[cfg(test)]
mod tests;

pub type Result<'a, T> = std::result::Result<T, Box<dyn 'a + Error>>;

#[derive(Default)]
pub struct Foo<T: Send> {
    data: Mutex<T>,
}

pub struct WriteLock<'a, T: Send + 'a>(MutexGuard<'a, T>);

impl<'a, T: Send + 'a> WriteLock<'a, T> {
    pub fn get(&self) -> &T {
        &self.0
    }
}

impl<T: Sync + Send> Foo<T> {
    pub fn foo(&self) -> Result<WriteLock<T>> {
        Ok(WriteLock(self.data.try_lock()?))
    }
}

@Jarcho
Copy link
Contributor

Jarcho commented Sep 2, 2022

Looks like the latest nightly is working (2022-08-31)

@yonip23
Copy link
Contributor Author

yonip23 commented Sep 2, 2022

My clippy version is 09-01 🤔
As shown in my info section above ^

@Jarcho
Copy link
Contributor

Jarcho commented Sep 2, 2022

I guess the playground hadn't updated by the time I checked.

@bors bors closed this as completed in 958a9cf Sep 2, 2022
@yonip23
Copy link
Contributor Author

yonip23 commented Sep 2, 2022

Thank you so much for the quick response and fix!👏

@Jarcho
Copy link
Contributor

Jarcho commented Sep 2, 2022

The change will be in nightly about a week from now.

@poliorcetics
Copy link

Thanks for the very fast fix, we hit that too in our CI !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants