Skip to content

ICE: name of non-Rpitit assoc item #140058

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

Open
vivax3794 opened this issue Apr 20, 2025 · 4 comments
Open

ICE: name of non-Rpitit assoc item #140058

vivax3794 opened this issue Apr 20, 2025 · 4 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@vivax3794
Copy link

vivax3794 commented Apr 20, 2025

Code

struct Hello;

trait Foo {
    type Data: i32;
}

impl Hello::What {}

With natrix = "1.0.0" as a dependency in the project.

Meta

rustc --version --verbose:

rustc 1.88.0-nightly (077cedc2a 2025-04-19)
binary: rustc
commit-hash: 077cedc2afa8ac0b727b7a6cbe012940ba228deb
commit-date: 2025-04-19
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2

Error Output

thread 'rustc' panicked at compiler/rustc_middle/src/ty/assoc.rs:43:25:
name of non-Rpitit assoc item
Backtrace

error[E0404]: expected trait, found builtin type `i32`
 --> src/lib.rs:4:16
  |
4 |     type Data: i32;
  |                ^^^ not a trait


thread 'rustc' panicked at compiler/rustc_middle/src/ty/assoc.rs:43:25:
name of non-Rpitit assoc item
stack backtrace:
   0:     0x7f74440c8db3 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hfaf8ed89211e6e1f
   1:     0x7f7444805b07 - core::fmt::write::h2da0a0da460f5037
   2:     0x7f7445ca2491 - std::io::Write::write_fmt::h4507b1cbf0ceb6dd
   3:     0x7f74440c8c12 - std::sys::backtrace::BacktraceLock::print::h41d0ebab53bd7768
   4:     0x7f74440cc58a - std::panicking::default_hook::{{closure}}::h4431b1eedebd3951
   5:     0x7f74440cc10f - std::panicking::default_hook::h897735e88042dbbc
   6:     0x7f7443148b93 - std[cfbc79774844d935]::panicking::update_hook::<alloc[9883a7069eddc933]::boxed::Box<rustc_driver_impl[4168e4092cb5e4c5]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7f74440cce03 - std::panicking::rust_panic_with_hook::hdfd38210fc20e43b
   8:     0x7f74440ccafa - std::panicking::begin_panic_handler::{{closure}}::hc72899d25392f7bc
   9:     0x7f74440c9279 - std::sys::backtrace::__rust_end_short_backtrace::hd11e673a53554045
  10:     0x7f74440cc7bd - __rustc[6dc022cbd14ae54d]::rust_begin_unwind
  11:     0x7f7440a870c0 - core::panicking::panic_fmt::h88a862c704395f75
  12:     0x7f7441e3b3cb - core::option::expect_failed::h23bc92f892e77f28
  13:     0x7f74461191b3 - <rustc_middle[dbe9dbab0f97c09d]::ty::assoc::AssocItem>::ident.cold
  14:     0x7f7443298901 - <core[8f5efdd3e17dd637]::iter::adapters::flatten::FlattenCompat<_, _> as core[8f5efdd3e17dd637]::iter::traits::iterator::Iterator>::try_fold::flatten::<core[8f5efdd3e17dd637]::iter::adapters::copied::Copied<core[8f5efdd3e17dd637]::slice::iter::Iter<rustc_span[cb8fd5489eeaf0e3]::def_id::DefId>>, (), core[8f5efdd3e17dd637]::ops::control_flow::ControlFlow<rustc_span[cb8fd5489eeaf0e3]::def_id::DefId>, core[8f5efdd3e17dd637]::iter::traits::iterator::Iterator::find::check<rustc_span[cb8fd5489eeaf0e3]::def_id::DefId, &mut <dyn rustc_hir_analysis[98c22e4b0d6d5cdc]::hir_ty_lowering::HirTyLowerer>::probe_traits_that_match_assoc_ty::{closure#0}>::{closure#0}>::{closure#0}
  15:     0x7f74432c885f - <core[8f5efdd3e17dd637]::iter::adapters::map::Map<core[8f5efdd3e17dd637]::iter::adapters::filter::Filter<core[8f5efdd3e17dd637]::iter::adapters::flatten::FlatMap<core[8f5efdd3e17dd637]::iter::adapters::chain::Chain<core[8f5efdd3e17dd637]::iter::sources::once::Once<rustc_span[cb8fd5489eeaf0e3]::def_id::CrateNum>, core[8f5efdd3e17dd637]::iter::adapters::copied::Copied<core[8f5efdd3e17dd637]::slice::iter::Iter<rustc_span[cb8fd5489eeaf0e3]::def_id::CrateNum>>>, core[8f5efdd3e17dd637]::iter::adapters::copied::Copied<core[8f5efdd3e17dd637]::slice::iter::Iter<rustc_span[cb8fd5489eeaf0e3]::def_id::DefId>>, <rustc_middle[dbe9dbab0f97c09d]::ty::context::TyCtxt>::all_traits::{closure#0}>, <dyn rustc_hir_analysis[98c22e4b0d6d5cdc]::hir_ty_lowering::HirTyLowerer>::probe_traits_that_match_assoc_ty::{closure#0}>, <dyn rustc_hir_analysis[98c22e4b0d6d5cdc]::hir_ty_lowering::HirTyLowerer>::probe_traits_that_match_assoc_ty::{closure#1}> as core[8f5efdd3e17dd637]::iter::traits::iterator::Iterator>::next
  16:     0x7f7443288114 - <core[8f5efdd3e17dd637]::iter::adapters::map::Map<core[8f5efdd3e17dd637]::iter::adapters::filter::Filter<core[8f5efdd3e17dd637]::iter::adapters::flatten::FlatMap<core[8f5efdd3e17dd637]::iter::adapters::chain::Chain<core[8f5efdd3e17dd637]::iter::sources::once::Once<rustc_span[cb8fd5489eeaf0e3]::def_id::CrateNum>, core[8f5efdd3e17dd637]::iter::adapters::copied::Copied<core[8f5efdd3e17dd637]::slice::iter::Iter<rustc_span[cb8fd5489eeaf0e3]::def_id::CrateNum>>>, core[8f5efdd3e17dd637]::iter::adapters::copied::Copied<core[8f5efdd3e17dd637]::slice::iter::Iter<rustc_span[cb8fd5489eeaf0e3]::def_id::DefId>>, <rustc_middle[dbe9dbab0f97c09d]::ty::context::TyCtxt>::all_traits::{closure#0}>, <dyn rustc_hir_analysis[98c22e4b0d6d5cdc]::hir_ty_lowering::HirTyLowerer>::probe_traits_that_match_assoc_ty::{closure#0}>, <dyn rustc_hir_analysis[98c22e4b0d6d5cdc]::hir_ty_lowering::HirTyLowerer>::probe_traits_that_match_assoc_ty::{closure#1}> as core[8f5efdd3e17dd637]::iter::traits::iterator::Iterator>::collect::<alloc[9883a7069eddc933]::vec::Vec<alloc[9883a7069eddc933]::string::String>>
  17:     0x7f744557da32 - <dyn rustc_hir_analysis[98c22e4b0d6d5cdc]::hir_ty_lowering::HirTyLowerer>::lower_assoc_path_shared::{closure#0}
  18:     0x7f7445579000 - <dyn rustc_hir_analysis[98c22e4b0d6d5cdc]::hir_ty_lowering::HirTyLowerer>::lower_assoc_path_ty
  19:     0x7f7444ae21d0 - <dyn rustc_hir_analysis[98c22e4b0d6d5cdc]::hir_ty_lowering::HirTyLowerer>::lower_ty
  20:     0x7f7444aca94b - rustc_hir_analysis[98c22e4b0d6d5cdc]::collect::type_of::type_of
  21:     0x7f7444ac9f78 - rustc_query_impl[8687e3a7a5e012fc]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8687e3a7a5e012fc]::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[dbe9dbab0f97c09d]::query::erase::Erased<[u8; 8usize]>>
  22:     0x7f7444a708cd - rustc_query_system[aee8ed8ba3f3d4a4]::query::plumbing::try_execute_query::<rustc_query_impl[8687e3a7a5e012fc]::DynamicConfig<rustc_query_system[aee8ed8ba3f3d4a4]::query::caches::DefIdCache<rustc_middle[dbe9dbab0f97c09d]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[8687e3a7a5e012fc]::plumbing::QueryCtxt, true>
  23:     0x7f7444a6c77d - rustc_query_impl[8687e3a7a5e012fc]::query_impl::type_of::get_query_incr::__rust_end_short_backtrace
  24:     0x7f744514adfd - <rustc_hir_analysis[98c22e4b0d6d5cdc]::collect::CollectItemTypesVisitor as rustc_hir[6df87b3874aa120f]::intravisit::Visitor>::visit_item
  25:     0x7f744513e0e3 - rustc_hir_analysis[98c22e4b0d6d5cdc]::check::wfcheck::check_well_formed
  26:     0x7f744513deeb - rustc_query_impl[8687e3a7a5e012fc]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8687e3a7a5e012fc]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[dbe9dbab0f97c09d]::query::erase::Erased<[u8; 1usize]>>
  27:     0x7f7444a65dbe - rustc_query_system[aee8ed8ba3f3d4a4]::query::plumbing::try_execute_query::<rustc_query_impl[8687e3a7a5e012fc]::DynamicConfig<rustc_data_structures[a4e62dcbac3a6fff]::vec_cache::VecCache<rustc_span[cb8fd5489eeaf0e3]::def_id::LocalDefId, rustc_middle[dbe9dbab0f97c09d]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[aee8ed8ba3f3d4a4]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[8687e3a7a5e012fc]::plumbing::QueryCtxt, true>
  28:     0x7f7444a6556f - rustc_query_impl[8687e3a7a5e012fc]::query_impl::check_well_formed::get_query_incr::__rust_end_short_backtrace
  29:     0x7f74451396e5 - rustc_hir_analysis[98c22e4b0d6d5cdc]::check::wfcheck::check_mod_type_wf
  30:     0x7f74451394dd - rustc_query_impl[8687e3a7a5e012fc]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8687e3a7a5e012fc]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[dbe9dbab0f97c09d]::query::erase::Erased<[u8; 1usize]>>
  31:     0x7f74458cf775 - rustc_query_system[aee8ed8ba3f3d4a4]::query::plumbing::try_execute_query::<rustc_query_impl[8687e3a7a5e012fc]::DynamicConfig<rustc_query_system[aee8ed8ba3f3d4a4]::query::caches::DefaultCache<rustc_span[cb8fd5489eeaf0e3]::def_id::LocalModDefId, rustc_middle[dbe9dbab0f97c09d]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[8687e3a7a5e012fc]::plumbing::QueryCtxt, true>
  32:     0x7f74458d0240 - rustc_query_impl[8687e3a7a5e012fc]::query_impl::check_mod_type_wf::get_query_incr::__rust_end_short_backtrace
  33:     0x7f7444a3dd32 - rustc_hir_analysis[98c22e4b0d6d5cdc]::check_crate
  34:     0x7f74451fbef4 - rustc_interface[9462fce10cf7ee10]::passes::run_required_analyses
  35:     0x7f744569305e - rustc_interface[9462fce10cf7ee10]::passes::analysis
  36:     0x7f744569302d - rustc_query_impl[8687e3a7a5e012fc]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8687e3a7a5e012fc]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[dbe9dbab0f97c09d]::query::erase::Erased<[u8; 0usize]>>
  37:     0x7f7445b1c8fd - rustc_query_system[aee8ed8ba3f3d4a4]::query::plumbing::try_execute_query::<rustc_query_impl[8687e3a7a5e012fc]::DynamicConfig<rustc_query_system[aee8ed8ba3f3d4a4]::query::caches::SingleCache<rustc_middle[dbe9dbab0f97c09d]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[8687e3a7a5e012fc]::plumbing::QueryCtxt, true>
  38:     0x7f7445b1c221 - rustc_query_impl[8687e3a7a5e012fc]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
  39:     0x7f74456c20be - rustc_interface[9462fce10cf7ee10]::passes::create_and_enter_global_ctxt::<core[8f5efdd3e17dd637]::option::Option<rustc_interface[9462fce10cf7ee10]::queries::Linker>, rustc_driver_impl[4168e4092cb5e4c5]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  40:     0x7f74459188c4 - rustc_interface[9462fce10cf7ee10]::interface::run_compiler::<(), rustc_driver_impl[4168e4092cb5e4c5]::run_compiler::{closure#0}>::{closure#1}
  41:     0x7f7445703c68 - std[cfbc79774844d935]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[9462fce10cf7ee10]::util::run_in_thread_with_globals<rustc_interface[9462fce10cf7ee10]::util::run_in_thread_pool_with_globals<rustc_interface[9462fce10cf7ee10]::interface::run_compiler<(), rustc_driver_impl[4168e4092cb5e4c5]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  42:     0x7f74457040b4 - <<std[cfbc79774844d935]::thread::Builder>::spawn_unchecked_<rustc_interface[9462fce10cf7ee10]::util::run_in_thread_with_globals<rustc_interface[9462fce10cf7ee10]::util::run_in_thread_pool_with_globals<rustc_interface[9462fce10cf7ee10]::interface::run_compiler<(), rustc_driver_impl[4168e4092cb5e4c5]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[8f5efdd3e17dd637]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  43:     0x7f74457054b7 - std::sys::pal::unix::thread::Thread::new::thread_start::h924abcfa8ac99dff
  44:     0x7f743f6a370a - <unknown>
  45:     0x7f743f727aac - <unknown>
  46:                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: please attach the file at `/tmp/fail/rustc-ice-2025-04-20T03_08_58-1902919.txt` to your bug report

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

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

query stack during panic:
#0 [type_of] computing type of `<impl at src/lib.rs:10:1: 10:17>`
#1 [check_well_formed] checking that `<impl at src/lib.rs:10:1: 10:17>` 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
For more information about this error, try `rustc --explain E0404`.

@vivax3794 vivax3794 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 Apr 20, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 20, 2025
@matthiaskrgr matthiaskrgr added the S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress. label Apr 20, 2025
@vivax3794
Copy link
Author

Oh, hmmm it seems the ICE only happens when one of my projects is included as a dependency, I orignally found it in some code using it, so pulled it into my test project for this, and when I narrowed the repro to something that didnt import it I didnt think to test removing it from the Cargo.toml

the package is natrix, and can confirm the ICE happens on a clean project with the above code and natrix = "1.0.0" in Cargo.toml

I really have no clue what in natrix might be triggering this when it isnt even used in the code.

@vivax3794
Copy link
Author

I managed to cut down the repo more, it seems like the requirements are:

  • A trait with a associated type with a invalid trait bound
  • A impl Something::Something block (doesnt have to use the same associated item at all)
  • something that happens in natrix, still dont know what

@vivax3794
Copy link
Author

vivax3794 commented Apr 21, 2025

Hmm, so I found that

trait Bar {
    fn hello() -> impl PartialEq;
}

struct Hello;

impl Hello::What {}

seems to trigger the same panic without having to depend on natrix, (and natrix does in fact have a trait with such a return type)
but also in this case you dont need the type Assoc: i32 to trigger the panic, which you do in the repro currently in the issue body (which depends on natrix).

But creating a crate with

trait bar {
    fn hello() -> impl partialeq;
}

and depending on it in a crate with

struct Hello;

trait Foo {
    type Data: i32;
}

impl Hello::What {}

causes the panic (and removing type Data: i32 causes the panic to not happen)

@vivax3794
Copy link
Author

vivax3794 commented Apr 21, 2025

This might get fixed by #139981 ? (I initally didnt think it was a duplicate of its two linked issue since the original repro didnt have a -> impl ... anywhere afaik at the time)

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) ❄️ needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants