Skip to content

ICE Normalizing &'^0.Named(DefId(..::foo::'_), "'_") u32 without wrapping in a Binder #142382

Open
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#![feature(generic_const_parameter_types)]
struct Bar<'a, const N: &'a u32>;

fn foo(&self) -> Bar<248> {
    empty!()
}

original:

// checks that when we relate a `Expr::Binop` we also relate the types of the
// const arguments.
#![feature(ConstParamTy)]
#![feature(adt_const_params, unsized_const_params)]

struct Bar<'a, const N: &'a u32>;

const fn make_generic(_: U) -> bool {
    a
}

fn foo<const N: usize>(&self, other: &Union) -> Bar<248> { empty!() }

fn foo<const N: usize>(bar: &mut Foo<N>)
where
    [(); N + 1]: ,
{
    *bar = new(loop {});
}

Version information

rustc 1.89.0-nightly (f77bb1b29 2025-06-11)
binary: rustc
commit-hash: f77bb1b294a30efb73ff4845946a3aad0950cb83
commit-date: 2025-06-11
host: x86_64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.5

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcrate-attr=feature(generic_const_parameter_types)

Program output

error: `self` parameter is only allowed in associated functions
 --> /tmp/icemaker_global_tempdir.ACtxj9825bxn/rustc_testrunner_tmpdir_reporting.O7UrJ2tqVbrD/mvce.rs:3:8
  |
3 | fn foo(&self) -> Bar<248> {
  |        ^^^^^ not semantically valid as function parameter
  |
  = note: associated functions are those in `impl` or `trait` definitions

error: cannot find macro `empty` in this scope
 --> /tmp/icemaker_global_tempdir.ACtxj9825bxn/rustc_testrunner_tmpdir_reporting.O7UrJ2tqVbrD/mvce.rs:4:5
  |
4 |     empty!()
  |     ^^^^^

warning: the feature `generic_const_parameter_types` is incomplete and may not be safe to use and/or cause compiler crashes
 --> <crate attribute>:1:12
  |
1 | #![feature(generic_const_parameter_types)]
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #137626 <https://github.com/rust-lang/rust/issues/137626> for more information
  = note: `#[warn(incomplete_features)]` on by default

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

error[E0392]: lifetime parameter `'a` is never used
 --> /tmp/icemaker_global_tempdir.ACtxj9825bxn/rustc_testrunner_tmpdir_reporting.O7UrJ2tqVbrD/mvce.rs:1:12
  |
1 | struct Bar<'a, const N: &'a u32>;
  |            ^^ unused lifetime parameter
  |
  = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData`

error: `&'a u32` is forbidden as the type of a const generic parameter
 --> /tmp/icemaker_global_tempdir.ACtxj9825bxn/rustc_testrunner_tmpdir_reporting.O7UrJ2tqVbrD/mvce.rs:1:25
  |
1 | struct Bar<'a, const N: &'a u32>;
  |                         ^^^^^^^
  |
  = note: the only supported types are integers, `bool`, and `char`
help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
  |
1 + #![feature(adt_const_params)]
  |
help: add `#![feature(unsized_const_params)]` to the crate attributes to enable references to implement the `ConstParamTy` trait
  |
1 + #![feature(unsized_const_params)]
  |


thread 'rustc' panicked at /rustc-dev/f77bb1b294a30efb73ff4845946a3aad0950cb83/compiler/rustc_trait_selection/src/traits/normalize.rs:172:9:
Normalizing &'^0.Named(DefId(0:9 ~ mvce[b34b]::foo::'_), "'_") u32 without wrapping in a `Binder`
stack backtrace:
   0:     0x76bc58ade7f3 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h83978709893bd0a2
   1:     0x76bc59202d37 - core::fmt::write::h1aa9c78ad7d3283b
   2:     0x76bc58ad4503 - std::io::Write::write_fmt::h995e1e537e740dec
   3:     0x76bc58ade652 - std::sys::backtrace::BacktraceLock::print::h0d3ba10cec4336bf
   4:     0x76bc58ae223a - std::panicking::default_hook::{{closure}}::hafdbafac85c45e91
   5:     0x76bc58ae1dbf - std::panicking::default_hook::h1a3142df0c66deed
   6:     0x76bc57bea4c3 - std[23460a1a556d4fbc]::panicking::update_hook::<alloc[6fa2bf33fa58de87]::boxed::Box<rustc_driver_impl[9d5daabfc91d8374]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x76bc58ae2aa3 - std::panicking::rust_panic_with_hook::h4eff26e24544a2a2
   8:     0x76bc58ae279a - std::panicking::begin_panic_handler::{{closure}}::h9e655ec144a7257c
   9:     0x76bc58adecc9 - std::sys::backtrace::__rust_end_short_backtrace::hc57685637cae63c7
  10:     0x76bc58ae246d - __rustc[f332fee8a4fb17e6]::rust_begin_unwind
  11:     0x76bc55285380 - core::panicking::panic_fmt::h08b16b8409edb4aa
  12:     0x76bc5934dd6e - <rustc_hir_typeck[724ed508f108e1a7]::fn_ctxt::FnCtxt>::normalize::<rustc_middle[46e97e34c114b554]::ty::Ty>
  13:     0x76bc5a3fbca9 - rustc_hir_typeck[724ed508f108e1a7]::typeck_with_inspect::{closure#0}
  14:     0x76bc5a3fa2f2 - rustc_query_impl[8d10c6b1062e623e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8d10c6b1062e623e]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[46e97e34c114b554]::query::erase::Erased<[u8; 8usize]>>
  15:     0x76bc5948f82e - rustc_query_system[ae5a6f3d00818f64]::query::plumbing::try_execute_query::<rustc_query_impl[8d10c6b1062e623e]::DynamicConfig<rustc_data_structures[caf00ecaf550782c]::vec_cache::VecCache<rustc_span[13d7defe36292ef0]::def_id::LocalDefId, rustc_middle[46e97e34c114b554]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[ae5a6f3d00818f64]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[8d10c6b1062e623e]::plumbing::QueryCtxt, false>
  16:     0x76bc5948f289 - rustc_query_impl[8d10c6b1062e623e]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  17:     0x76bc5949066a - rustc_query_impl[8d10c6b1062e623e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8d10c6b1062e623e]::query_impl::used_trait_imports::dynamic_query::{closure#2}::{closure#0}, rustc_middle[46e97e34c114b554]::query::erase::Erased<[u8; 8usize]>>
  18:     0x76bc5948f82e - rustc_query_system[ae5a6f3d00818f64]::query::plumbing::try_execute_query::<rustc_query_impl[8d10c6b1062e623e]::DynamicConfig<rustc_data_structures[caf00ecaf550782c]::vec_cache::VecCache<rustc_span[13d7defe36292ef0]::def_id::LocalDefId, rustc_middle[46e97e34c114b554]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[ae5a6f3d00818f64]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[8d10c6b1062e623e]::plumbing::QueryCtxt, false>
  19:     0x76bc5948f1c9 - rustc_query_impl[8d10c6b1062e623e]::query_impl::used_trait_imports::get_query_non_incr::__rust_end_short_backtrace
  20:     0x76bc5948ed48 - rustc_hir_analysis[c3294ec09277fcbb]::check_unused::check_unused_traits
  21:     0x76bc5948ec09 - rustc_query_impl[8d10c6b1062e623e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8d10c6b1062e623e]::query_impl::check_unused_traits::dynamic_query::{closure#2}::{closure#0}, rustc_middle[46e97e34c114b554]::query::erase::Erased<[u8; 0usize]>>
  22:     0x76bc5a25244e - rustc_query_system[ae5a6f3d00818f64]::query::plumbing::try_execute_query::<rustc_query_impl[8d10c6b1062e623e]::DynamicConfig<rustc_query_system[ae5a6f3d00818f64]::query::caches::SingleCache<rustc_middle[46e97e34c114b554]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[8d10c6b1062e623e]::plumbing::QueryCtxt, false>
  23:     0x76bc5a2520bc - rustc_query_impl[8d10c6b1062e623e]::query_impl::check_unused_traits::get_query_non_incr::__rust_end_short_backtrace
  24:     0x76bc59497d7a - rustc_hir_analysis[c3294ec09277fcbb]::check_crate
  25:     0x76bc59ae8499 - rustc_interface[cc981b5dfdbe0fcc]::passes::analysis
  26:     0x76bc59ae80b3 - rustc_query_impl[8d10c6b1062e623e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8d10c6b1062e623e]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[46e97e34c114b554]::query::erase::Erased<[u8; 0usize]>>
  27:     0x76bc5a25244e - rustc_query_system[ae5a6f3d00818f64]::query::plumbing::try_execute_query::<rustc_query_impl[8d10c6b1062e623e]::DynamicConfig<rustc_query_system[ae5a6f3d00818f64]::query::caches::SingleCache<rustc_middle[46e97e34c114b554]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[8d10c6b1062e623e]::plumbing::QueryCtxt, false>
  28:     0x76bc5a252036 - rustc_query_impl[8d10c6b1062e623e]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  29:     0x76bc5a567559 - rustc_interface[cc981b5dfdbe0fcc]::passes::create_and_enter_global_ctxt::<core[c567bc73f04f05de]::option::Option<rustc_interface[cc981b5dfdbe0fcc]::queries::Linker>, rustc_driver_impl[9d5daabfc91d8374]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  30:     0x76bc5a43c149 - rustc_interface[cc981b5dfdbe0fcc]::interface::run_compiler::<(), rustc_driver_impl[9d5daabfc91d8374]::run_compiler::{closure#0}>::{closure#1}
  31:     0x76bc5a30b0be - std[23460a1a556d4fbc]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[cc981b5dfdbe0fcc]::util::run_in_thread_with_globals<rustc_interface[cc981b5dfdbe0fcc]::util::run_in_thread_pool_with_globals<rustc_interface[cc981b5dfdbe0fcc]::interface::run_compiler<(), rustc_driver_impl[9d5daabfc91d8374]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  32:     0x76bc5a30ad96 - <<std[23460a1a556d4fbc]::thread::Builder>::spawn_unchecked_<rustc_interface[cc981b5dfdbe0fcc]::util::run_in_thread_with_globals<rustc_interface[cc981b5dfdbe0fcc]::util::run_in_thread_pool_with_globals<rustc_interface[cc981b5dfdbe0fcc]::interface::run_compiler<(), rustc_driver_impl[9d5daabfc91d8374]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[c567bc73f04f05de]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  33:     0x76bc5a30c6fd - std::sys::pal::unix::thread::Thread::new::thread_start::h8ddc16f396740493
  34:     0x76bc53ea57eb - <unknown>
  35:     0x76bc53f2918c - <unknown>
  36:                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.89.0-nightly (f77bb1b29 2025-06-11) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z crate-attr=feature(generic_const_parameter_types) -Z dump-mir-dir=dir

query stack during panic:
#0 [typeck] type-checking `foo::{constant#0}`
#1 [used_trait_imports] finding used_trait_imports `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 5 previous errors; 1 warning emitted

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

@rustbot label +F-ConstParamTy +F-adt_const_params +F-unsized_const_params +F-generic_const_parameter_types

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-generic_const_parameter_types`#![feature(generic_const_parameter_types)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions