Closed
Description
auto-reduced (treereduce-rust):
trait Foo {
type Assoc<const N: Self>;
fn foo(&Assoc) -> Self::Assoc<3>;
}
original:
// run-pass
// This test unsures that with_opt_const_param returns the
// def_id of the N param in the Foo::Assoc GAT.
trait Foo {
type Assoc<const N: N>;
fn foo(&self) -> Self::Assoc<3>;
}
impl Foo for () {
fn foo(&Assoc) -> Self::Assoc<3>;
fn foo(&Assoc) -> Self::Assoc<3>;
}
trait Foo {
type Assoc<const N: Self>;
fn foo(&Assoc) -> Self::Assoc<3>;
}
Version information
rustc 1.87.0-nightly (8c392966a 2025-03-01)
binary: rustc
commit-hash: 8c392966a013fd8a09e6b78b3c8d6e442bc278e1
commit-date: 2025-03-01
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0
Possibly related line of code:
rust/compiler/rustc_middle/src/ty/generics.rs
Lines 217 to 229 in 8c39296
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zincremental-verify-ich=yes -Cincremental=<dir> -Cdebuginfo=2 -Clink-dead-code=true -Zvalidate-mir --edition=2024
Program output
error: expected one of `:`, `@`, or `|`, found `)`
--> /tmp/icemaker_global_tempdir.lSkQubIYoEeM/rustc_testrunner_tmpdir_reporting.42tnKAQbDl1C/mvce.rs:12:18
|
12 | fn foo(&Assoc) -> Self::Assoc<3>;
| ^ expected one of `:`, `@`, or `|`
|
= note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
help: if this is a `self` type, give it a parameter name
|
12 | fn foo(self: &Assoc) -> Self::Assoc<3>;
| +++++
help: if this is a parameter name, give it a type
|
12 - fn foo(&Assoc) -> Self::Assoc<3>;
12 + fn foo(Assoc: &TypeName) -> Self::Assoc<3>;
|
help: if this is a type, explicitly ignore the parameter name
|
12 | fn foo(_: &Assoc) -> Self::Assoc<3>;
| ++
error[E0601]: `main` function not found in crate `mvce`
--> /tmp/icemaker_global_tempdir.lSkQubIYoEeM/rustc_testrunner_tmpdir_reporting.42tnKAQbDl1C/mvce.rs:13:2
|
13 | }
| ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.lSkQubIYoEeM/rustc_testrunner_tmpdir_reporting.42tnKAQbDl1C/mvce.rs`
error: `Self` is forbidden as the type of a const generic parameter
--> /tmp/icemaker_global_tempdir.lSkQubIYoEeM/rustc_testrunner_tmpdir_reporting.42tnKAQbDl1C/mvce.rs:11:25
|
11 | type Assoc<const N: Self>;
| ^^^^
|
= note: the only supported types are integers, `bool`, and `char`
thread 'rustc' panicked at compiler/rustc_middle/src/ty/generics.rs:223:29:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
0: 0x7295de3bedf4 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hdbd106d724e72c20
1: 0x7295dec057e2 - core::fmt::write::h861eecc74abebf7a
2: 0x7295dfc4dd51 - std::io::Write::write_fmt::h493b3152b071fba0
3: 0x7295de3bec52 - std::sys::backtrace::BacktraceLock::print::h71f315c25fc266cb
4: 0x7295de3c1532 - std::panicking::default_hook::{{closure}}::h8019dc6a2c6c0fe7
5: 0x7295de3c1124 - std::panicking::default_hook::h497f769686a88dd6
6: 0x7295dd518417 - std[e7ccd300aecc5933]::panicking::update_hook::<alloc[8cc49891b291256f]::boxed::Box<rustc_driver_impl[b622dd38a520489a]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x7295de3c1da3 - std::panicking::rust_panic_with_hook::h98fc165e90ef379e
8: 0x7295de3c1a9a - std::panicking::begin_panic_handler::{{closure}}::h2c1a60d0a908eaec
9: 0x7295de3bf2c9 - std::sys::backtrace::__rust_end_short_backtrace::he8aba8f9b7ddf304
10: 0x7295de3c175d - rust_begin_unwind
11: 0x7295db05a680 - core::panicking::panic_fmt::hcbf39f8c1e585f84
12: 0x7295dc33968c - core::panicking::panic_bounds_check::h56f1c876f8f7fa1a
13: 0x7295e063a055 - <rustc_middle[464f7c4b782fc90]::ty::generics::Generics>::type_param.cold
14: 0x7295de1c2278 - <rustc_trait_selection[4edfcc70fd15c568]::error_reporting::TypeErrCtxt>::note_and_explain_type_err
15: 0x7295de272c77 - <rustc_trait_selection[4edfcc70fd15c568]::error_reporting::TypeErrCtxt>::note_type_err
16: 0x7295de1ea498 - <rustc_trait_selection[4edfcc70fd15c568]::error_reporting::TypeErrCtxt>::report_and_explain_type_error
17: 0x7295db9da079 - <rustc_trait_selection[4edfcc70fd15c568]::error_reporting::TypeErrCtxt>::report_mismatched_types
18: 0x7295dee76923 - <rustc_hir_typeck[2e27b1bdaf23c662]::fn_ctxt::FnCtxt>::check_expr_coercible_to_type
19: 0x7295df16f7a1 - rustc_hir_typeck[2e27b1bdaf23c662]::typeck_with_inspect::{closure#0}
20: 0x7295df16c5f0 - rustc_query_impl[f11a5069a0fc322c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f11a5069a0fc322c]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[464f7c4b782fc90]::query::erase::Erased<[u8; 8usize]>>
21: 0x7295df163005 - rustc_query_system[18aefac76bbd956a]::query::plumbing::try_execute_query::<rustc_query_impl[f11a5069a0fc322c]::DynamicConfig<rustc_data_structures[fa39f8fcd9225f43]::vec_cache::VecCache<rustc_span[eeaf0b3b2812840a]::def_id::LocalDefId, rustc_middle[464f7c4b782fc90]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[18aefac76bbd956a]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[f11a5069a0fc322c]::plumbing::QueryCtxt, true>
22: 0x7295df15f787 - rustc_query_impl[f11a5069a0fc322c]::query_impl::typeck::get_query_incr::__rust_end_short_backtrace
23: 0x7295df1614c1 - rustc_query_impl[f11a5069a0fc322c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f11a5069a0fc322c]::query_impl::used_trait_imports::dynamic_query::{closure#2}::{closure#0}, rustc_middle[464f7c4b782fc90]::query::erase::Erased<[u8; 8usize]>>
24: 0x7295df163005 - rustc_query_system[18aefac76bbd956a]::query::plumbing::try_execute_query::<rustc_query_impl[f11a5069a0fc322c]::DynamicConfig<rustc_data_structures[fa39f8fcd9225f43]::vec_cache::VecCache<rustc_span[eeaf0b3b2812840a]::def_id::LocalDefId, rustc_middle[464f7c4b782fc90]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[18aefac76bbd956a]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[f11a5069a0fc322c]::plumbing::QueryCtxt, true>
25: 0x7295dee21838 - rustc_query_impl[f11a5069a0fc322c]::query_impl::used_trait_imports::get_query_incr::__rust_end_short_backtrace
26: 0x7295df45cb94 - rustc_middle[464f7c4b782fc90]::query::plumbing::query_get_at::<rustc_data_structures[fa39f8fcd9225f43]::vec_cache::VecCache<rustc_span[eeaf0b3b2812840a]::def_id::LocalDefId, rustc_middle[464f7c4b782fc90]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[18aefac76bbd956a]::dep_graph::graph::DepNodeIndex>>
27: 0x7295df45c2ad - rustc_hir_analysis[6dcb172f42838441]::check_unused::check_unused_traits
28: 0x7295df45c007 - rustc_query_impl[f11a5069a0fc322c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f11a5069a0fc322c]::query_impl::check_unused_traits::dynamic_query::{closure#2}::{closure#0}, rustc_middle[464f7c4b782fc90]::query::erase::Erased<[u8; 0usize]>>
29: 0x7295dfc4571f - rustc_query_system[18aefac76bbd956a]::query::plumbing::try_execute_query::<rustc_query_impl[f11a5069a0fc322c]::DynamicConfig<rustc_query_system[18aefac76bbd956a]::query::caches::SingleCache<rustc_middle[464f7c4b782fc90]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[f11a5069a0fc322c]::plumbing::QueryCtxt, true>
30: 0x7295dfc44c4e - rustc_query_impl[f11a5069a0fc322c]::query_impl::check_unused_traits::get_query_incr::__rust_end_short_backtrace
31: 0x7295df15e937 - rustc_hir_analysis[6dcb172f42838441]::check_crate
32: 0x7295df15831c - rustc_interface[f15b12210e2206a6]::passes::run_required_analyses
33: 0x7295dfc49cfa - rustc_interface[f15b12210e2206a6]::passes::analysis
34: 0x7295dfc49cd9 - rustc_query_impl[f11a5069a0fc322c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f11a5069a0fc322c]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[464f7c4b782fc90]::query::erase::Erased<[u8; 0usize]>>
35: 0x7295dfc455aa - rustc_query_system[18aefac76bbd956a]::query::plumbing::try_execute_query::<rustc_query_impl[f11a5069a0fc322c]::DynamicConfig<rustc_query_system[18aefac76bbd956a]::query::caches::SingleCache<rustc_middle[464f7c4b782fc90]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[f11a5069a0fc322c]::plumbing::QueryCtxt, true>
36: 0x7295dfc44fa2 - rustc_query_impl[f11a5069a0fc322c]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
37: 0x7295dfd38b3d - rustc_interface[f15b12210e2206a6]::passes::create_and_enter_global_ctxt::<core[9e5e7b8b77114b88]::option::Option<rustc_interface[f15b12210e2206a6]::queries::Linker>, rustc_driver_impl[b622dd38a520489a]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
38: 0x7295dfd03a20 - rustc_interface[f15b12210e2206a6]::interface::run_compiler::<(), rustc_driver_impl[b622dd38a520489a]::run_compiler::{closure#0}>::{closure#1}
39: 0x7295dfb59bc8 - std[e7ccd300aecc5933]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[f15b12210e2206a6]::util::run_in_thread_with_globals<rustc_interface[f15b12210e2206a6]::util::run_in_thread_pool_with_globals<rustc_interface[f15b12210e2206a6]::interface::run_compiler<(), rustc_driver_impl[b622dd38a520489a]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
40: 0x7295dfb5a4b4 - <<std[e7ccd300aecc5933]::thread::Builder>::spawn_unchecked_<rustc_interface[f15b12210e2206a6]::util::run_in_thread_with_globals<rustc_interface[f15b12210e2206a6]::util::run_in_thread_pool_with_globals<rustc_interface[f15b12210e2206a6]::interface::run_compiler<(), rustc_driver_impl[b622dd38a520489a]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[9e5e7b8b77114b88]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
41: 0x7295dfb5b8ab - std::sys::pal::unix::thread::Thread::new::thread_start::h20288ab9ea215a81
42: 0x7295d9c5e70a - <unknown>
43: 0x7295d9ce2aac - <unknown>
44: 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 (8c392966a 2025-03-01) running on x86_64-unknown-linux-gnu
note: compiler flags: -Z incremental-verify-ich=yes -C incremental=[REDACTED] -C debuginfo=2 -C link-dead-code=true -Z validate-mir
query stack during panic:
#0 [typeck] type-checking `Foo::foo::{constant#0}`
#1 [used_trait_imports] finding used_trait_imports `Foo::foo::{constant#0}`
#2 [check_unused_traits] checking unused trait imports in crate
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0601`.