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

ICE on stable and nightly: compiler/rustc_trait_selection/src/traits/select/mod.rs:2013:17 #91594

Closed
dnavre opened this issue Dec 6, 2021 · 5 comments · Fixed by #92312
Closed
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dnavre
Copy link

dnavre commented Dec 6, 2021

Code

I'm a complete Rust newbie and most of the time I have no idea of what I'm doing. So my source code is probably completely weird and f*cked up by the standards of a seasoned Rust developer. Still, I don't think my compiler should be panicking :) Also please note that the source code is definitely not even supposed to compile, it DOES have a number of syntax errors, however, I would expect a reasonable error message explaining what I'm doing wrong.
The whole project can be found here: XXX
Big thanks to @fee1-dead who has minimized the code to a very simple test case that crashes the compiler: #91594 (comment)

I also found several similar bugs reported but I'm still not sure if this is a duplicate or not. Similar bug reports:
#55765
#25036

To reproduce:

cargo build

Meta

The bug does exist in the current nightly build.

rustc --version --verbose:

rustc 1.57.0 (f1edd0429 2021-11-29)
binary: rustc
commit-hash: f1edd0429582dd29cccacaf50fd134b05593bd9c
commit-date: 2021-11-29
host: x86_64-apple-darwin
release: 1.57.0
LLVM version: 13.0.0

Error output

error: internal compiler error: compiler/rustc_trait_selection/src/traits/select/mod.rs:2072:17: Impl DefId(0:335 ~ map_server[3b29]::mapserver::endpoints::map_endpoint::{impl#2}) was matchable against Obligation(predicate=Binder(TraitPredicate(<mapserver::endpoints::map_endpoint::map_endpoint as shaku::HasComponent<(dyn mapserver::environment::map::Map + 'static)>>, polarity:Positive), []), depth=3) but now is not

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1170:9

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

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.59.0-nightly (e2116acae 2021-12-05) running on x86_64-apple-darwin

note: compiler flags: -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `mapserver::endpoints::map_endpoint::map_endpoint: shaku::module::module_traits::ModuleInterface`  |  = note: this failure-note originates in the macro `module` (in Nightly builds, run with -Z macro-backtrace for more info)

#1 [check_item_well_formed] checking that `mapserver::endpoints::map_endpoint::<impl at src/mapserver/endpoints/map_endpoint.rs:8:1: 13:2>` is well-formed
end of query stack
warning: `map-server` (bin "map-server") generated 5 warnings
error: could not compile `map-server`; 5 warnings emitted

Backtrace

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1146:9
stack backtrace:
   0: std::panicking::begin_panic
   1: std::panic::panic_any
   2: rustc_errors::HandlerInner::bug
   3: rustc_errors::Handler::bug
   4: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
   5: rustc_middle::ty::context::tls::with_opt::{{closure}}
   6: rustc_middle::ty::context::tls::with_opt
   7: rustc_middle::util::bug::opt_span_bug_fmt
   8: rustc_middle::util::bug::bug_fmt
   9: rustc_infer::infer::InferCtxt::commit_unconditionally
  10: rustc_trait_selection::traits::select::confirmation::<impl rustc_trait_selection::traits::select::SelectionContext>::confirm_candidate
  11: rustc_infer::infer::InferCtxt::probe
  12: rustc_trait_selection::traits::select::SelectionContext::evaluate_stack
  13: rustc_query_system::dep_graph::graph::DepGraph<K>::with_anon_task
  14: rustc_trait_selection::traits::select::SelectionContext::evaluate_trait_predicate_recursively
  15: rustc_data_structures::stack::ensure_sufficient_stack
  16: rustc_trait_selection::traits::select::SelectionContext::evaluate_predicate_recursively
  17: rustc_trait_selection::traits::select::SelectionContext::evaluate_predicates_recursively
  18: rustc_infer::infer::InferCtxt::probe
  19: rustc_trait_selection::traits::select::SelectionContext::evaluate_stack
  20: rustc_query_system::dep_graph::graph::DepGraph<K>::with_anon_task
  21: rustc_trait_selection::traits::select::SelectionContext::evaluate_trait_predicate_recursively
  22: rustc_data_structures::stack::ensure_sufficient_stack
  23: rustc_trait_selection::traits::select::SelectionContext::evaluate_predicate_recursively
  24: rustc_trait_selection::traits::select::SelectionContext::evaluate_predicates_recursively
  25: rustc_infer::infer::InferCtxt::probe
  26: rustc_trait_selection::traits::select::SelectionContext::evaluate_stack
  27: rustc_query_system::dep_graph::graph::DepGraph<K>::with_anon_task
  28: rustc_trait_selection::traits::select::SelectionContext::evaluate_trait_predicate_recursively
  29: rustc_data_structures::stack::ensure_sufficient_stack
  30: rustc_trait_selection::traits::select::SelectionContext::evaluate_predicate_recursively
  31: rustc_infer::infer::InferCtxt::probe
  32: rustc_trait_selection::traits::select::SelectionContext::evaluate_root_obligation
  33: rustc_infer::infer::InferCtxtBuilder::enter_with_canonical
  34: rustc_traits::evaluate_obligation::evaluate_obligation
  35: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
  36: rustc_data_structures::stack::ensure_sufficient_stack
  37: rustc_query_system::query::plumbing::try_execute_query
  38: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::evaluate_obligation
  39: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation
  40: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation_no_overflow
  41: rustc_trait_selection::traits::fulfill::FulfillProcessor::process_trait_obligation
  42: rustc_trait_selection::traits::fulfill::FulfillProcessor::progress_changed_obligations
  43: rustc_data_structures::obligation_forest::ObligationForest<O>::process_obligations
  44: rustc_trait_selection::traits::fulfill::FulfillmentContext::select
  45: <rustc_trait_selection::traits::fulfill::FulfillmentContext as rustc_infer::traits::engine::TraitEngine>::select_with_constness_where_possible
  46: <rustc_trait_selection::traits::fulfill::FulfillmentContext as rustc_infer::traits::engine::TraitEngine>::select_all_with_constness_or_error
  47: rustc_typeck::check::fn_ctxt::_impl::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::select_all_obligations_or_error
  48: rustc_infer::infer::InferCtxtBuilder::enter
  49: rustc_typeck::check::wfcheck::check_item_well_formed
  50: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
  51: rustc_data_structures::stack::ensure_sufficient_stack
  52: rustc_query_system::query::plumbing::try_execute_query
  53: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_item_well_formed
  54: <rustc_typeck::check::wfcheck::CheckTypeWellFormedVisitor as rustc_hir::intravisit::Visitor>::visit_item
  55: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  56: rustc_data_structures::sync::par_for_each_in
  57: rustc_session::session::Session::track_errors
  58: rustc_typeck::check_crate
  59: rustc_interface::passes::analysis
  60: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
  61: rustc_data_structures::stack::ensure_sufficient_stack
  62: rustc_query_system::query::plumbing::try_execute_query
  63: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  64: rustc_interface::passes::QueryContext::enter
  65: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  66: rustc_span::with_source_map
  67: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.57.0 (f1edd0429 2021-11-29) running on x86_64-apple-darwin

note: compiler flags: -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `mapserver::endpoints::map_endpoint::map_endpoint: shaku::module::module_traits::ModuleInterface`  |  = note: this failure-note originates in the macro `module` (in Nightly builds, run with -Z macro-backtrace for more info)

#1 [check_item_well_formed] checking that `mapserver::endpoints::map_endpoint::<impl at src/mapserver/endpoints/map_endpoint.rs:8:1: 13:2>` is well-formed
#2 [analysis] running analysis passes on this crate
end of query stack
warning: `map-server` (bin "map-server") generated 5 warnings
error: could not compile `map-server`; 5 warnings emitted

@dnavre dnavre added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 6, 2021
@fee1-dead
Copy link
Member

Minimized: (play)

trait Component<M> {
    type Interface;
}
trait HasComponent<I> {}

struct Foo;

impl HasComponent<<Foo as Component<Foo>>::Interface> for Foo {}

impl<M: HasComponent<()>> Component<M> for Foo {
    type Interface = u8;
}

Note: I used perses for reducing most of the unneeded code, and cargo-expand to put everything in one big file.

@dnavre
Copy link
Author

dnavre commented Dec 6, 2021

@fee1-dead Thanks for doing that, I'll edit my original post to link to your reply to see a code example.

P.S.
I did open the code reduction tools you linked, but I still am not sure how you got to this minimized state, great job :D

@JohnTitor
Copy link
Member

Triage: It now returns some compiler errors and is no longer ICE, fixed by #91844, I guess. Marking as E-needs-test.

@JohnTitor JohnTitor added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Dec 21, 2021
@JohnTitor
Copy link
Member

@dnavre Just in case, if you could check your code with the latest nightly, it'd be great.

@dnavre
Copy link
Author

dnavre commented Dec 23, 2021

@JohnTitor Indeed, tested with the latest nightly this produces various compiler errors and no ICE. Thank you!

BGR360 added a commit to BGR360/rust that referenced this issue Dec 27, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 5, 2022
Mark-Simulacrum pushed a commit to BGR360/rust that referenced this issue Jan 28, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 29, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 29, 2022
@bors bors closed this as completed in d08e816 Jan 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants