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: $ident: found TraitItem(TraitItem #138211

Closed
matthiaskrgr opened this issue Mar 8, 2025 · 3 comments · Fixed by #138238
Closed

ICE: $ident: found TraitItem(TraitItem #138211

matthiaskrgr opened this issue Mar 8, 2025 · 3 comments · Fixed by #138238
Assignees
Labels
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.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

//@compile-flags: --edition=2024
pub trait TraitWAssocConst {
    const A: TraitWAssocConst<A = 0>;
}

original:

#![feature(generic_const_exprs)]
pub trait TraitWAssocConst {
  const A: TraitWAssocConst<A=0>;
}

fn main<A: TraitWAssocConst<A=32>>() {
  TraitWAssocConst<A=0>:: TraitWAssocConst<A=32> ();
}

Version information

rustc 1.87.0-nightly (20f0108ad 2025-03-08)
binary: rustc
commit-hash: 20f0108ada90e37c2350ad68fdc6afe56f51539d
commit-date: 2025-03-08
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0

Possibly related line of code:

label: &str,
sugg: Vec<(Span, String)>,
diag: &mut Diag<'_>,
) -> bool {
let tcx = self.tcx();
let parent_id = tcx.hir_get_parent_item(self_ty.hir_id).def_id;
let parent_item = tcx.hir_node_by_def_id(parent_id).expect_item();
// If the parent item is an enum, don't suggest the dyn trait.
if let hir::ItemKind::Enum(..) = parent_item.kind {
return false;
}

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc --edition=2024

Program output

error[E0658]: associated const equality is incomplete
 --> /tmp/icemaker_global_tempdir.xCmlSFx4hmpo/rustc_testrunner_tmpdir_reporting.tPdpsshuU7cG/mvce.rs:2:31
  |
2 |     const A: TraitWAssocConst<A = 0>;
  |                               ^^^^^
  |
  = note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information
  = help: add `#![feature(associated_const_equality)]` to the crate attributes to enable
  = note: this compiler was built on 2025-03-08; consider upgrading it if it is out of date

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.xCmlSFx4hmpo/rustc_testrunner_tmpdir_reporting.tPdpsshuU7cG/mvce.rs:3:2
  |
3 | }
  |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.xCmlSFx4hmpo/rustc_testrunner_tmpdir_reporting.tPdpsshuU7cG/mvce.rs`


thread 'rustc' panicked at compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs:210:61:
$ident: found TraitItem(TraitItem { ident: A#0, owner_id: DefId(0:4 ~ mvce[a2ab]::TraitWAssocConst::A), generics: Generics { params: [], predicates: [], has_where_clause_predicates: false, where_clause_span: /tmp/icemaker_global_tempdir.xCmlSFx4hmpo/rustc_testrunner_tmpdir_reporting.tPdpsshuU7cG/mvce.rs:2:37: 2:37 (#0), span: /tmp/icemaker_global_tempdir.xCmlSFx4hmpo/rustc_testrunner_tmpdir_reporting.tPdpsshuU7cG/mvce.rs:2:12: 2:12 (#0) }, kind: Const(Ty { hir_id: HirId(DefId(0:4 ~ mvce[a2ab]::TraitWAssocConst::A).8), span: /tmp/icemaker_global_tempdir.xCmlSFx4hmpo/rustc_testrunner_tmpdir_reporting.tPdpsshuU7cG/mvce.rs:2:14: 2:37 (#0), kind: TraitObject([PolyTraitRef { bound_generic_params: [], modifiers: TraitBoundModifiers { constness: Never, polarity: Positive }, trait_ref: TraitRef { path: Path { span: /tmp/icemaker_global_tempdir.xCmlSFx4hmpo/rustc_testrunner_tmpdir_reporting.tPdpsshuU7cG/mvce.rs:2:14: 2:37 (#0), res: Def(Trait, DefId(0:3 ~ mvce[a2ab]::TraitWAssocConst)), segments: [PathSegment { ident: TraitWAssocConst#0, hir_id: HirId(DefId(0:4 ~ mvce[a2ab]::TraitWAssocConst::A).5), res: Def(Trait, DefId(0:3 ~ mvce[a2ab]::TraitWAssocConst)), args: Some(GenericArgs { args: [], constraints: [AssocItemConstraint { hir_id: HirId(DefId(0:4 ~ mvce[a2ab]::TraitWAssocConst::A).4), ident: A#0, gen_args: GenericArgs { args: [], constraints: [], parenthesized: No, span_ext: no-location (#0) }, kind: Equality { term: Const(ConstArg { hir_id: HirId(DefId(0:4 ~ mvce[a2ab]::TraitWAssocConst::A).3), kind: Anon(AnonConst { hir_id: HirId(DefId(0:4 ~ mvce[a2ab]::TraitWAssocConst::A).1), def_id: DefId(0:5 ~ mvce[a2ab]::TraitWAssocConst::A::{constant#0}), body: BodyId { hir_id: HirId(DefId(0:4 ~ mvce[a2ab]::TraitWAssocConst::A).2) }, span: /tmp/icemaker_global_tempdir.xCmlSFx4hmpo/rustc_testrunner_tmpdir_reporting.tPdpsshuU7cG/mvce.rs:2:35: 2:36 (#0) }) }) }, span: /tmp/icemaker_global_tempdir.xCmlSFx4hmpo/rustc_testrunner_tmpdir_reporting.tPdpsshuU7cG/mvce.rs:2:31: 2:36 (#0) }], parenthesized: No, span_ext: /tmp/icemaker_global_tempdir.xCmlSFx4hmpo/rustc_testrunner_tmpdir_reporting.tPdpsshuU7cG/mvce.rs:2:30: 2:37 (#0) }), infer_args: false }] }, hir_ref_id: HirId(DefId(0:4 ~ mvce[a2ab]::TraitWAssocConst::A).6) }, span: /tmp/icemaker_global_tempdir.xCmlSFx4hmpo/rustc_testrunner_tmpdir_reporting.tPdpsshuU7cG/mvce.rs:2:14: 2:37 (#0) }], TaggedRef { pointer: Lifetime { hir_id: HirId(DefId(0:4 ~ mvce[a2ab]::TraitWAssocConst::A).7), ident: #0, res: ImplicitObjectLifetimeDefault }, tag: None }) }, None), span: /tmp/icemaker_global_tempdir.xCmlSFx4hmpo/rustc_testrunner_tmpdir_reporting.tPdpsshuU7cG/mvce.rs:2:5: 2:38 (#0), defaultness: Default { has_value: false } })
stack backtrace:
   0:     0x735d0f5c6f34 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h07b2089c80742ed5
   1:     0x735d0fe05aa2 - core::fmt::write::h332ae571ae4a9cc4
   2:     0x735d111e3a11 - std::io::Write::write_fmt::h0c761025205b813c
   3:     0x735d0f5c6d92 - std::sys::backtrace::BacktraceLock::print::hbba93a9383b9fa8a
   4:     0x735d0f5c9672 - std::panicking::default_hook::{{closure}}::h00e63950a63732af
   5:     0x735d0f5c9264 - std::panicking::default_hook::h400dc9bc1b724c37
   6:     0x735d0e7204e7 - std[c20316ad899fcaf5]::panicking::update_hook::<alloc[2db8fd01bd7ea837]::boxed::Box<rustc_driver_impl[153d3eccf0c7c750]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x735d0f5c9ee3 - std::panicking::rust_panic_with_hook::he428532615a29ae4
   8:     0x735d0f5c9bda - std::panicking::begin_panic_handler::{{closure}}::h498acb37174be106
   9:     0x735d0f5c73f9 - std::sys::backtrace::__rust_end_short_backtrace::h2c0df5d26e60f09c
  10:     0x735d0f5c989d - rust_begin_unwind
  11:     0x735d0c25df10 - core::panicking::panic_fmt::h35b514d9ffb031f4
  12:     0x735d0e7ecf81 - rustc_hir[229de859651313c0]::hir::expect_failed::<&rustc_hir[229de859651313c0]::hir::Node>
  13:     0x735d1105f858 - <dyn rustc_hir_analysis[2ac45909935d36a1]::hir_ty_lowering::HirTyLowerer>::prohibit_or_lint_bare_trait_object_ty
  14:     0x735d10566736 - <dyn rustc_hir_analysis[2ac45909935d36a1]::hir_ty_lowering::HirTyLowerer>::lower_ty
  15:     0x735d103618cd - rustc_hir_analysis[2ac45909935d36a1]::collect::type_of::type_of
  16:     0x735d10359d2a - rustc_query_impl[824584145395502d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[824584145395502d]::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b1dca1d1b343b3c]::query::erase::Erased<[u8; 8usize]>>
  17:     0x735d10161332 - rustc_query_system[75007086aa92bf3]::query::plumbing::try_execute_query::<rustc_query_impl[824584145395502d]::DynamicConfig<rustc_query_system[75007086aa92bf3]::query::caches::DefIdCache<rustc_middle[b1dca1d1b343b3c]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[824584145395502d]::plumbing::QueryCtxt, false>
  18:     0x735d10160edf - rustc_query_impl[824584145395502d]::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace
  19:     0x735d10597699 - <rustc_hir_analysis[2ac45909935d36a1]::collect::CollectItemTypesVisitor as rustc_hir[229de859651313c0]::intravisit::Visitor>::visit_trait_item
  20:     0x735d105899ef - rustc_hir_analysis[2ac45909935d36a1]::check::wfcheck::check_well_formed
  21:     0x735d1058754d - rustc_query_impl[824584145395502d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[824584145395502d]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b1dca1d1b343b3c]::query::erase::Erased<[u8; 1usize]>>
  22:     0x735d10587004 - rustc_query_system[75007086aa92bf3]::query::plumbing::try_execute_query::<rustc_query_impl[824584145395502d]::DynamicConfig<rustc_data_structures[59c1b7daa758d1f8]::vec_cache::VecCache<rustc_span[268b27c29cacb432]::def_id::LocalDefId, rustc_middle[b1dca1d1b343b3c]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[75007086aa92bf3]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[824584145395502d]::plumbing::QueryCtxt, false>
  23:     0x735d10586abf - rustc_query_impl[824584145395502d]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  24:     0x735d105845f0 - rustc_hir_analysis[2ac45909935d36a1]::check::wfcheck::check_mod_type_wf
  25:     0x735d105840df - rustc_query_impl[824584145395502d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[824584145395502d]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b1dca1d1b343b3c]::query::erase::Erased<[u8; 1usize]>>
  26:     0x735d10e96d56 - rustc_query_system[75007086aa92bf3]::query::plumbing::try_execute_query::<rustc_query_impl[824584145395502d]::DynamicConfig<rustc_query_system[75007086aa92bf3]::query::caches::DefaultCache<rustc_span[268b27c29cacb432]::def_id::LocalModDefId, rustc_middle[b1dca1d1b343b3c]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[824584145395502d]::plumbing::QueryCtxt, false>
  27:     0x735d10e96aff - rustc_query_impl[824584145395502d]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  28:     0x735d1017f9cf - rustc_hir_analysis[2ac45909935d36a1]::check_crate
  29:     0x735d1032807a - rustc_interface[7e29b5e2b62c504d]::passes::run_required_analyses
  30:     0x735d10dc1b7a - rustc_interface[7e29b5e2b62c504d]::passes::analysis
  31:     0x735d10dc1b59 - rustc_query_impl[824584145395502d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[824584145395502d]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b1dca1d1b343b3c]::query::erase::Erased<[u8; 0usize]>>
  32:     0x735d10eda3cb - rustc_query_system[75007086aa92bf3]::query::plumbing::try_execute_query::<rustc_query_impl[824584145395502d]::DynamicConfig<rustc_query_system[75007086aa92bf3]::query::caches::SingleCache<rustc_middle[b1dca1d1b343b3c]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[824584145395502d]::plumbing::QueryCtxt, false>
  33:     0x735d10eda0b9 - rustc_query_impl[824584145395502d]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  34:     0x735d10f1577d - rustc_interface[7e29b5e2b62c504d]::passes::create_and_enter_global_ctxt::<core[8e02e1de5014891c]::option::Option<rustc_interface[7e29b5e2b62c504d]::queries::Linker>, rustc_driver_impl[153d3eccf0c7c750]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  35:     0x735d10f056a0 - rustc_interface[7e29b5e2b62c504d]::interface::run_compiler::<(), rustc_driver_impl[153d3eccf0c7c750]::run_compiler::{closure#0}>::{closure#1}
  36:     0x735d10dabe48 - std[c20316ad899fcaf5]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[7e29b5e2b62c504d]::util::run_in_thread_with_globals<rustc_interface[7e29b5e2b62c504d]::util::run_in_thread_pool_with_globals<rustc_interface[7e29b5e2b62c504d]::interface::run_compiler<(), rustc_driver_impl[153d3eccf0c7c750]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  37:     0x735d10dac734 - <<std[c20316ad899fcaf5]::thread::Builder>::spawn_unchecked_<rustc_interface[7e29b5e2b62c504d]::util::run_in_thread_with_globals<rustc_interface[7e29b5e2b62c504d]::util::run_in_thread_pool_with_globals<rustc_interface[7e29b5e2b62c504d]::interface::run_compiler<(), rustc_driver_impl[153d3eccf0c7c750]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[8e02e1de5014891c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  38:     0x735d10dadb2b - std::sys::pal::unix::thread::Thread::new::thread_start::h63137a35d539f669
  39:     0x735d0aea370a - <unknown>
  40:     0x735d0af27aac - <unknown>
  41:                0x0 - <unknown>

error: 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: please make sure that you have updated to the latest nightly

note: rustc 1.87.0-nightly (20f0108ad 2025-03-08) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z dump-mir-dir=dir

query stack during panic:
#0 [type_of] computing type of `TraitWAssocConst::A`
#1 [check_well_formed] checking that `TraitWAssocConst::A` is well-formed
#2 [check_mod_type_wf] checking that types are well-formed in top-level module
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors

Some errors have detailed explanations: E0601, E0658.
For more information about an error, try `rustc --explain E0601`.

@matthiaskrgr matthiaskrgr 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 Mar 8, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 8, 2025
@matthiaskrgr
Copy link
Member Author

This is regressed around 14 crash files that we had fixed in the past (which is quite a lot)

bisects to #138042

@matthiaskrgr
Copy link
Member Author

I guess this was not found in CI because it requires edition >=2021 and we run with 2015 by default

@matthiaskrgr
Copy link
Member Author

seems this is problematic for
ForeignItem(ForeignItem, ImplItem(ImplItem and TraitItem(TraitItem

@compiler-errors compiler-errors self-assigned this Mar 8, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 9, 2025
…struct, r=nnethercote

Fix dyn -> param suggestion in struct ICEs

Makes the logic from rust-lang#138042 a bit less ICEy and more clean. Also fixes an incorrect suggestion when the struct already has generics. I'll point out the major changes and observations in the code.

Fixes rust-lang#138229
Fixes rust-lang#138211

r? nnethercote since you reviewed the original pr, or re-roll if you don't want to review this
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 10, 2025
…struct, r=nnethercote

Fix dyn -> param suggestion in struct ICEs

Makes the logic from rust-lang#138042 a bit less ICEy and more clean. Also fixes an incorrect suggestion when the struct already has generics. I'll point out the major changes and observations in the code.

Fixes rust-lang#138229
Fixes rust-lang#138211

r? nnethercote since you reviewed the original pr, or re-roll if you don't want to review this
jieyouxu added a commit to jieyouxu/rust that referenced this issue Mar 10, 2025
…struct, r=nnethercote

Fix dyn -> param suggestion in struct ICEs

Makes the logic from rust-lang#138042 a bit less ICEy and more clean. Also fixes an incorrect suggestion when the struct already has generics. I'll point out the major changes and observations in the code.

Fixes rust-lang#138229
Fixes rust-lang#138211

r? nnethercote since you reviewed the original pr, or re-roll if you don't want to review this
@bors bors closed this as completed in 1ae083d Mar 11, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 11, 2025
Rollup merge of rust-lang#138238 - compiler-errors:dyn-suggestion-in-struct, r=nnethercote

Fix dyn -> param suggestion in struct ICEs

Makes the logic from rust-lang#138042 a bit less ICEy and more clean. Also fixes an incorrect suggestion when the struct already has generics. I'll point out the major changes and observations in the code.

Fixes rust-lang#138229
Fixes rust-lang#138211

r? nnethercote since you reviewed the original pr, or re-roll if you don't want to review this
@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 12, 2025
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. 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