-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Description
The ICE triggers for traits with associated consts whose types are some generic struct, but not always.
Code
Checking each trait is a bit of a chore, going through and commenting/uncommenting whichever trait is to be tested. If there's a better way to format this I'm all ears!
mod without_copy {
struct GenericStruct<T>(T);
// No ICE
trait TraitWithTypeAndConst {
type Type;
const CONST: GenericStruct<Self::Type>;
}
// ICE
trait TraitWithConstOnly {
const CONST: GenericStruct<Self>;
}
// No ICE
trait TraitWithoutSelfReference {
const CONST: GenericStruct<f32>;
}
}
mod with_copy {
struct GenericStruct<T: Copy>(T);
// ICE
trait TraitWithTypeAndConst {
type Type;
const CONST: GenericStruct<Self::Type>;
}
// ICE
trait TraitWithConstOnly {
const CONST: GenericStruct<Self>;
}
// No ICE
trait TraitWithoutSelfReference {
const CONST: GenericStruct<f32>;
}
}
mod with_blank_trait {
trait Blank {}
struct GenericStruct<T: Blank>(T);
// ICE
trait TraitWithTypeAndConst {
type Type;
const CONST: GenericStruct<Self::Type>;
}
// ICE
trait TraitWithConstOnly {
const CONST: GenericStruct<Self>;
}
// ICE
trait TraitWithoutSelfReference {
const CONST: GenericStruct<f32>;
}
}
mod with_blank_trait_and_generic_impl {
trait Blank {}
impl<T> Blank for T {}
struct GenericStruct<T: Blank>(T);
// No ICE
trait TraitWithTypeAndConst {
type Type;
const CONST: GenericStruct<Self::Type>;
}
// ICE
trait TraitWithConstOnly {
const CONST: GenericStruct<Self>;
}
// NO ICE
trait TraitWithoutSelfReference {
const CONST: GenericStruct<f32>;
}
}Note how each module has the same 3 traits as each other, the only difference from module to module is the bounds on the referenced type (GenericStruct) and the trait being bound. Interestingly it gets stranger as the blank trait changes the ICE triggering depending on if the trait has the generic impl block (impl<T> Blank for T {}) or not.
Meta
rustc --version --verbose:
rustc 1.56.0-nightly (2faabf579 2021-07-27)
binary: rustc
commit-hash: 2faabf579323f5252329264cc53ba9ff803429a3
commit-date: 2021-07-27
host: x86_64-unknown-linux-gnu
release: 1.56.0-nightly
LLVM version: 12.0.1
Error output
error: internal compiler error: compiler/rustc_typeck/src/hir_wf_check.rs:133:29: Unexpected TraitItem Const(Ty { hir_id: HirId { owner: DefId(0:52 ~ ice_on_example[788e]::with_blank_trait_and_generic_impl::TraitWithConstOnly::CONST), local_id: 1 }, kind: Path(Resolved(None, Path { span: ice_on_example/src/lib.rs:79:22: 79:48 (#0), res: Def(Struct, DefId(0:44 ~ ice_on_example[788e]::with_blank_trait_and_generic_impl::GenericNewTypeStruct)), segments: [PathSegment { ident: GenericNewTypeStruct#0, hir_id: Some(HirId { owner: DefId(0:52 ~ ice_on_example[788e]::with_blank_trait_and_generic_impl::TraitWithConstOnly::CONST), local_id: 4 }), res: Some(Err), args: Some(GenericArgs { args: [Type(Ty { hir_id: HirId { owner: DefId(0:52 ~ ice_on_example[788e]::with_blank_trait_and_generic_impl::TraitWithConstOnly::CONST), local_id: 2 }, kind: Path(Resolved(None, Path { span: ice_on_example/src/lib.rs:79:43: 79:47 (#0), res: SelfTy(Some(DefId(0:51 ~ ice_on_example[788e]::with_blank_trait_and_generic_impl::TraitWithConstOnly)), None), segments: [PathSegment { ident: Self#0, hir_id: Some(HirId { owner: DefId(0:52 ~ ice_on_example[788e]::with_blank_trait_and_generic_impl::TraitWithConstOnly::CONST), local_id: 3 }), res: Some(SelfTy(Some(DefId(0:51 ~ ice_on_example[788e]::with_blank_trait_and_generic_impl::TraitWithConstOnly)), None)), args: None, infer_args: false }] })), span: ice_on_example/src/lib.rs:79:43: 79:47 (#0) })], bindings: [], parenthesized: false, span_ext: ice_on_example/src/lib.rs:79:42: 79:48 (#0) }), infer_args: false }] })), span: ice_on_example/src/lib.rs:79:22: 79:48 (#0) }, None)
thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1034: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.56.0-nightly (2faabf579 2021-07-27) running on x86_64-unknown-linux-gnu
note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [diagnostic_hir_wf_check] performing HIR wf-checking for predicate Binder(TraitPredicate(<Self as std::marker::Sized>), []) at item Ty(DefId(0:52 ~ ice_on_example[788e]::with_blank_trait_and_generic_impl::TraitWithConstOnly::CONST))
#1 [check_trait_item_well_formed] checking that `with_blank_trait_and_generic_impl::TraitWithConstOnly::CONST` is well-formed
end of query stack
Backtrace
thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1034: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::ty::context::tls::with_opt
5: rustc_middle::util::bug::opt_span_bug_fmt
6: rustc_middle::util::bug::bug_fmt
7: rustc_typeck::hir_wf_check::diagnostic_hir_wf_check
8: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
9: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
10: rustc_data_structures::stack::ensure_sufficient_stack
11: rustc_query_system::query::plumbing::get_query_impl
12: rustc_query_system::query::plumbing::get_query
13: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtExt>::report_selection_error
14: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtPrivExt>::report_fulfillment_error
15: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtExt>::report_fulfillment_errors
16: rustc_typeck::check::fn_ctxt::_impl::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::select_all_obligations_or_error
17: rustc_infer::infer::InferCtxtBuilder::enter
18: rustc_typeck::check::wfcheck::check_associated_item
19: rustc_typeck::check::wfcheck::check_trait_item
20: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
21: rustc_data_structures::stack::ensure_sufficient_stack
22: rustc_query_system::query::plumbing::force_query_with_job
23: rustc_query_system::query::plumbing::get_query_impl
24: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_trait_item_well_formed
25: <rustc_typeck::check::wfcheck::CheckTypeWellFormedVisitor as rustc_hir::intravisit::Visitor>::visit_trait_item
26: std::panicking::try
27: rustc_data_structures::sync::par_for_each_in
28: rustc_session::session::Session::track_errors
29: rustc_typeck::check_crate
30: rustc_interface::passes::analysis
31: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
32: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
33: rustc_query_system::dep_graph::graph::DepGraph<K>::with_eval_always_task
34: rustc_data_structures::stack::ensure_sufficient_stack
35: rustc_query_system::query::plumbing::force_query_with_job
36: rustc_query_system::query::plumbing::get_query_impl
37: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
38: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
39: rustc_span::with_source_map
40: rustc_interface::interface::create_compiler_and_run
41: scoped_tls::ScopedKey<T>::set
Full Backtrace
thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1034:9
stack backtrace:
0: 0x7f435c6dbf50 - std::backtrace_rs::backtrace::libunwind::trace::h99dbb39dca18857d
at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
1: 0x7f435c6dbf50 - std::backtrace_rs::backtrace::trace_unsynchronized::h832861927e9cfedf
at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7f435c6dbf50 - std::sys_common::backtrace::_print_fmt::h3d18154c77dcf310
at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/sys_common/backtrace.rs:67:5
3: 0x7f435c6dbf50 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::he312f4ad5b9bb346
at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/sys_common/backtrace.rs:46:22
4: 0x7f435c749bbc - core::fmt::write::h9a6d9c74526a6c1b
at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/core/src/fmt/mod.rs:1115:17
5: 0x7f435c6cd835 - std::io::Write::write_fmt::h6aced00850e8186f
at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/io/mod.rs:1665:15
6: 0x7f435c6dfc6b - std::sys_common::backtrace::_print::h65d996766de40da4
at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/sys_common/backtrace.rs:49:5
7: 0x7f435c6dfc6b - std::sys_common::backtrace::print::h40df9727e635f303
at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/sys_common/backtrace.rs:36:9
8: 0x7f435c6dfc6b - std::panicking::default_hook::{{closure}}::hd2da4327dea91a51
at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/panicking.rs:208:50
9: 0x7f435c6df741 - std::panicking::default_hook::h3d55120ad6ada158
at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/panicking.rs:225:9
10: 0x7f435cebc611 - rustc_driver::DEFAULT_HOOK::{{closure}}::{{closure}}::h6c854bb74ca75dad
11: 0x7f435c6e0499 - std::panicking::rust_panic_with_hook::hf85dd0bb545e3b55
at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/panicking.rs:626:17
12: 0x7f435de9ba5b - std::panicking::begin_panic::{{closure}}::hecbebe18226bf241
13: 0x7f435de9b9e6 - std::sys_common::backtrace::__rust_end_short_backtrace::h7570b823de984483
14: 0x7f435de9ddbf - std::panicking::begin_panic::hbfbf0ff6f7e9a2e1
15: 0x7f435deb2e3d - std::panic::panic_any::h9b58b69598db8d52
16: 0x7f435deb5c5a - rustc_errors::HandlerInner::bug::h69b8d780df20db9a
17: 0x7f435deb5710 - rustc_errors::Handler::bug::h04eb0f7808456322
18: 0x7f435de0e8bc - rustc_middle::ty::context::tls::with_opt::hcefda774443605fb
19: 0x7f435de0eac0 - rustc_middle::util::bug::opt_span_bug_fmt::hbf4f38c7426a3da9
20: 0x7f435de0ea36 - rustc_middle::util::bug::bug_fmt::h23a56cbc4ca6dee5
21: 0x7f435d2898b3 - rustc_typeck::hir_wf_check::diagnostic_hir_wf_check::h4eeb4465ffb9baf1
22: 0x7f435d859bae - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::h181e3b555d8516a3
23: 0x7f435d833887 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::h94a4aef86133f1c1
24: 0x7f435d914bf3 - rustc_data_structures::stack::ensure_sufficient_stack::hfdcca5a77f101ca2
25: 0x7f435d698431 - rustc_query_system::query::plumbing::get_query_impl::h7b79b9ba10dfa38b
26: 0x7f435d735d16 - rustc_query_system::query::plumbing::get_query::h0f5eb8b87a1351b7
27: 0x7f435dc14bce - <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtExt>::report_selection_error::h8b9e7817a71eb078
28: 0x7f435dc1a6bf - <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtPrivExt>::report_fulfillment_error::h51e13a2e8b00d126
29: 0x7f435dc1360c - <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtExt>::report_fulfillment_errors::h7fc1f37867d2ac3b
30: 0x7f435e0a6f77 - rustc_typeck::check::fn_ctxt::_impl::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::select_all_obligations_or_error::hac60e5de99c6ed2e
31: 0x7f435e10e50b - rustc_infer::infer::InferCtxtBuilder::enter::hbf587ccc526e62c3
32: 0x7f435e0f1146 - rustc_typeck::check::wfcheck::check_associated_item::h2994e164cfdef394
33: 0x7f435ebddb11 - rustc_typeck::check::wfcheck::check_trait_item::hd9a198cd47f2a1c4
34: 0x7f435ef29a68 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::h0ea966f60fb357b0
35: 0x7f435efc119a - rustc_data_structures::stack::ensure_sufficient_stack::hfa8b4053572632ab
36: 0x7f435ee8633c - rustc_query_system::query::plumbing::force_query_with_job::h4ca6d0d2005ce713
37: 0x7f435e55fe72 - rustc_query_system::query::plumbing::get_query_impl::hcc942fc8702b5655
38: 0x7f435ef1791b - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_trait_item_well_formed::hd5c993c6aad595fb
39: 0x7f435ebe0f39 - <rustc_typeck::check::wfcheck::CheckTypeWellFormedVisitor as rustc_hir::intravisit::Visitor>::visit_trait_item::h81653c7fe5f91145
40: 0x7f435e0da813 - std::panicking::try::he384848f9f20c194
41: 0x7f435e13d1cb - rustc_data_structures::sync::par_for_each_in::h4c89b4235e43cb38
42: 0x7f435ebf4b2f - rustc_session::session::Session::track_errors::h45cdfa5727dc4520
43: 0x7f435ebe8243 - rustc_typeck::check_crate::h699147646121a6a3
44: 0x7f435e9cf80f - rustc_interface::passes::analysis::h50d0de1731ee4f37
45: 0x7f435d86be73 - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::hcbaeaa9eea970ee4
46: 0x7f435d83cc07 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::he6199cbb439e376a
47: 0x7f435d8400f9 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_eval_always_task::h28179af5692a308b
48: 0x7f435d9135ae - rustc_data_structures::stack::ensure_sufficient_stack::heb8eff9f07414442
49: 0x7f435d6c826d - rustc_query_system::query::plumbing::force_query_with_job::h739ef3432ad7844a
50: 0x7f435ee71506 - rustc_query_system::query::plumbing::get_query_impl::hfb328957edb27639
51: 0x7f435ef13b7d - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis::h6e8468093d45449b
52: 0x7f435e9a3e98 - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter::h3903b65ffca1d745
53: 0x7f435e99298c - rustc_span::with_source_map::hdc8c4c7d7611fe77
54: 0x7f435e9a50ba - rustc_interface::interface::create_compiler_and_run::hbe7a78745769ff96
55: 0x7f435e997e19 - scoped_tls::ScopedKey<T>::set::ha164143a03306a1b
56: 0x7f435e993eba - std::sys_common::backtrace::__rust_begin_short_backtrace::h4dd3c27220dda569
57: 0x7f435e993335 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h546778848e9193e6
58: 0x7f435c6eca27 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h09f167e08fc945ff
at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/alloc/src/boxed.rs:1572:9
59: 0x7f435c6eca27 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf814fe85eeb118e0
at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/alloc/src/boxed.rs:1572:9
60: 0x7f435c6eca27 - std::sys::unix::thread::Thread::new::thread_start::hb71b17934c5f5e68
at /rustc/2faabf579323f5252329264cc53ba9ff803429a3/library/std/src/sys/unix/thread.rs:91:17
61: 0x7f435c60a259 - start_thread
62: 0x7f435c51f5e3 - __GI___clone
63: 0x0 - <unknown>
I came across these ICE working on a project depending on the one that triggered this ICE, I wonder if the 2 issues are possibly related.