Open
Description
auto-reduced (treereduce-rust):
#![feature(unsized_const_params, adt_const_params, generic_const_parameter_types)]
fn foo<'a, const N: &'a Variant = { () as isize }>() {}
original:
// Ensure that we actually treat `N`'s type as `&'a u32` in MIR typeck.
#![feature(unsized_const_params, adt_const_params, generic_const_parameter_types)]
//~^ WARN the feature `unsized_const_params` is incomplete
//~| WARN the feature `generic_const_parameter_types` is incomplete
fn foo<'a, const N: &'a Variant = { std::mem::size_of::<T>() as isize }>() {
let b: &'static u32 = N;
//~^ ERROR lifetime may not live long enough
}
fn main() {}
Version information
rustc 1.90.0-nightly (ae2fc9722 2025-06-23)
binary: rustc
commit-hash: ae2fc9722f08ef131407c1dc8057768868f65e8e
commit-date: 2025-06-23
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.7
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc
Program output
error[E0412]: cannot find type `Variant` in this scope
--> /tmp/icemaker_global_tempdir.2VRPF4YVeGla/rustc_testrunner_tmpdir_reporting.BUOW19XRPqqh/mvce.rs:3:25
|
3 | fn foo<'a, const N: &'a Variant = { () as isize }>() {}
| ^^^^^^^ not found in this scope
warning: the feature `unsized_const_params` is incomplete and may not be safe to use and/or cause compiler crashes
--> /tmp/icemaker_global_tempdir.2VRPF4YVeGla/rustc_testrunner_tmpdir_reporting.BUOW19XRPqqh/mvce.rs:1:12
|
1 | #![feature(unsized_const_params, adt_const_params, generic_const_parameter_types)]
| ^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #95174 <https://github.com/rust-lang/rust/issues/95174> for more information
= note: `#[warn(incomplete_features)]` on by default
warning: the feature `generic_const_parameter_types` is incomplete and may not be safe to use and/or cause compiler crashes
--> /tmp/icemaker_global_tempdir.2VRPF4YVeGla/rustc_testrunner_tmpdir_reporting.BUOW19XRPqqh/mvce.rs:1:52
|
1 | #![feature(unsized_const_params, adt_const_params, generic_const_parameter_types)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #137626 <https://github.com/rust-lang/rust/issues/137626> for more information
error[E0601]: `main` function not found in crate `mvce`
--> /tmp/icemaker_global_tempdir.2VRPF4YVeGla/rustc_testrunner_tmpdir_reporting.BUOW19XRPqqh/mvce.rs:3:56
|
3 | fn foo<'a, const N: &'a Variant = { () as isize }>() {}
| ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.2VRPF4YVeGla/rustc_testrunner_tmpdir_reporting.BUOW19XRPqqh/mvce.rs`
error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
--> /tmp/icemaker_global_tempdir.2VRPF4YVeGla/rustc_testrunner_tmpdir_reporting.BUOW19XRPqqh/mvce.rs:3:12
|
3 | fn foo<'a, const N: &'a Variant = { () as isize }>() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
thread 'rustc' panicked at /rustc-dev/ae2fc9722f08ef131407c1dc8057768868f65e8e/compiler/rustc_type_ir/src/binder.rs:825:9:
region parameter `'a/#0` ('a/#0/0) out of range when instantiating args=[]
stack backtrace:
0: 0x725cb20c76d3 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h556e512b03f67b5c
1: 0x725cb2802c3f - core::fmt::write::hbb40e1548bd87745
2: 0x725cb20bd303 - std::io::Write::write_fmt::ha664174e31701713
3: 0x725cb20c7532 - std::sys::backtrace::BacktraceLock::print::ha35f1936448c3155
4: 0x725cb20cb02a - std::panicking::default_hook::{{closure}}::h108bbbd5d0fe564b
5: 0x725cb20cabaf - std::panicking::default_hook::hae230729f157b3e7
6: 0x725cb11bf373 - std[999dba399e3b7a48]::panicking::update_hook::<alloc[c5fc4e6bd1b1fac0]::boxed::Box<rustc_driver_impl[4c0d84ba05330dae]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x725cb20cb87b - std::panicking::rust_panic_with_hook::h82767e4052a58abb
8: 0x725cb20cb57a - std::panicking::begin_panic_handler::{{closure}}::h3194c4396d409c8f
9: 0x725cb20c7ba9 - std::sys::backtrace::__rust_end_short_backtrace::h54911cee5c28c1d5
10: 0x725cb20cb25d - __rustc[69dc7c4af7122c87]::rust_begin_unwind
11: 0x725cae88eff0 - core::panicking::panic_fmt::heceed76dab79da7f
12: 0x725cb1743a79 - <rustc_type_ir[3b0d0fccfb342a61]::binder::ArgFolder<rustc_middle[d04d44fe5ea925f7]::ty::context::TyCtxt>>::region_param_out_of_range
13: 0x725cb31f6ab6 - <rustc_type_ir[3b0d0fccfb342a61]::binder::ArgFolder<rustc_middle[d04d44fe5ea925f7]::ty::context::TyCtxt> as rustc_type_ir[3b0d0fccfb342a61]::fold::TypeFolder<rustc_middle[d04d44fe5ea925f7]::ty::context::TyCtxt>>::fold_ty
14: 0x725cb31f6f45 - <dyn rustc_hir_analysis[b49c90aa38898513]::hir_ty_lowering::HirTyLowerer>::lower_const_arg
15: 0x725cb3edb47f - rustc_hir_analysis[b49c90aa38898513]::collect::const_param_default
16: 0x725cb3edb31f - rustc_query_impl[69e70150503ed928]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[69e70150503ed928]::query_impl::const_param_default::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d04d44fe5ea925f7]::query::erase::Erased<[u8; 8usize]>>
17: 0x725cb2843665 - rustc_query_system[f819a83fa7adeedf]::query::plumbing::try_execute_query::<rustc_query_impl[69e70150503ed928]::DynamicConfig<rustc_query_system[f819a83fa7adeedf]::query::caches::DefIdCache<rustc_middle[d04d44fe5ea925f7]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[69e70150503ed928]::plumbing::QueryCtxt, false>
18: 0x725cb3edc100 - rustc_query_impl[69e70150503ed928]::query_impl::const_param_default::get_query_non_incr::__rust_end_short_backtrace
19: 0x725cb2ee3322 - rustc_hir_analysis[b49c90aa38898513]::check::wfcheck::check_where_clauses
20: 0x725cb2ff52d3 - rustc_hir_analysis[b49c90aa38898513]::check::wfcheck::check_fn_or_method
21: 0x725cb300e40e - rustc_hir_analysis[b49c90aa38898513]::check::wfcheck::check_item_fn
22: 0x725cb3011fb7 - rustc_hir_analysis[b49c90aa38898513]::check::wfcheck::check_item
23: 0x725cb3009919 - rustc_hir_analysis[b49c90aa38898513]::check::wfcheck::check_well_formed
24: 0x725cb3009799 - rustc_query_impl[69e70150503ed928]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[69e70150503ed928]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d04d44fe5ea925f7]::query::erase::Erased<[u8; 1usize]>>
25: 0x725cb3008fcd - rustc_query_system[f819a83fa7adeedf]::query::plumbing::try_execute_query::<rustc_query_impl[69e70150503ed928]::DynamicConfig<rustc_data_structures[62d642e74611eda2]::vec_cache::VecCache<rustc_span[e2740e6431e61e71]::def_id::LocalDefId, rustc_middle[d04d44fe5ea925f7]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[f819a83fa7adeedf]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[69e70150503ed928]::plumbing::QueryCtxt, false>
26: 0x725cb3008b02 - rustc_query_impl[69e70150503ed928]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
27: 0x725cb300629f - rustc_hir_analysis[b49c90aa38898513]::check::wfcheck::check_type_wf
28: 0x725cb30061a7 - rustc_query_impl[69e70150503ed928]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[69e70150503ed928]::query_impl::check_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d04d44fe5ea925f7]::query::erase::Erased<[u8; 1usize]>>
29: 0x725cb38b2108 - rustc_query_system[f819a83fa7adeedf]::query::plumbing::try_execute_query::<rustc_query_impl[69e70150503ed928]::DynamicConfig<rustc_query_system[f819a83fa7adeedf]::query::caches::SingleCache<rustc_middle[d04d44fe5ea925f7]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[69e70150503ed928]::plumbing::QueryCtxt, false>
30: 0x725cb38b1f02 - rustc_query_impl[69e70150503ed928]::query_impl::check_type_wf::get_query_non_incr::__rust_end_short_backtrace
31: 0x725cb2a7573a - rustc_hir_analysis[b49c90aa38898513]::check_crate
32: 0x725cb2a79b99 - rustc_interface[7d5c07adc9903dba]::passes::analysis
33: 0x725cb2a797a5 - rustc_query_impl[69e70150503ed928]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[69e70150503ed928]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d04d44fe5ea925f7]::query::erase::Erased<[u8; 0usize]>>
34: 0x725cb38abb02 - rustc_query_system[f819a83fa7adeedf]::query::plumbing::try_execute_query::<rustc_query_impl[69e70150503ed928]::DynamicConfig<rustc_query_system[f819a83fa7adeedf]::query::caches::SingleCache<rustc_middle[d04d44fe5ea925f7]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[69e70150503ed928]::plumbing::QueryCtxt, false>
35: 0x725cb38ab6cc - rustc_query_impl[69e70150503ed928]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
36: 0x725cb3a12dd6 - rustc_interface[7d5c07adc9903dba]::passes::create_and_enter_global_ctxt::<core[beb684febea189c2]::option::Option<rustc_interface[7d5c07adc9903dba]::queries::Linker>, rustc_driver_impl[4c0d84ba05330dae]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
37: 0x725cb3a755e5 - rustc_interface[7d5c07adc9903dba]::interface::run_compiler::<(), rustc_driver_impl[4c0d84ba05330dae]::run_compiler::{closure#0}>::{closure#1}
38: 0x725cb3a2b5b8 - std[999dba399e3b7a48]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[7d5c07adc9903dba]::util::run_in_thread_with_globals<rustc_interface[7d5c07adc9903dba]::util::run_in_thread_pool_with_globals<rustc_interface[7d5c07adc9903dba]::interface::run_compiler<(), rustc_driver_impl[4c0d84ba05330dae]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
39: 0x725cb3a2b296 - <<std[999dba399e3b7a48]::thread::Builder>::spawn_unchecked_<rustc_interface[7d5c07adc9903dba]::util::run_in_thread_with_globals<rustc_interface[7d5c07adc9903dba]::util::run_in_thread_pool_with_globals<rustc_interface[7d5c07adc9903dba]::interface::run_compiler<(), rustc_driver_impl[4c0d84ba05330dae]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[beb684febea189c2]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
40: 0x725cb3a2e6bd - std::sys::pal::unix::thread::Thread::new::thread_start::ha744ebd939fc791f
41: 0x725cad4a57eb - <unknown>
42: 0x725cad52918c - <unknown>
43: 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.90.0-nightly (ae2fc9722 2025-06-23) running on x86_64-unknown-linux-gnu
query stack during panic:
#0 [const_param_default] computing the default for const parameter `foo::N`
#1 [check_well_formed] checking that `foo` is well-formed
#2 [check_type_wf] checking that types are well-formed
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors; 2 warnings emitted
Some errors have detailed explanations: E0412, E0601.
For more information about an error, try `rustc --explain E0412`.
@rustbot label +F-unsized_const_params +F-adt_const_params +F-generic_const_parameter_types