#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
const CONST: u32 = 0;
struct Test<const N: u32, const M: u32 = { CONST/* Must be a const and not a Literal */ }> where [(); N as usize]: , ([u32; N as usize]);
fn main() {
let _: Test<1>;
}
error: internal compiler error: compiler/rustc_middle/src/ty/subst.rs:933:9: const parameter `M/#1` (Const { ty: u32, kind: M/#1 }/1) out of range when substituting substs=[Const { ty: u32, kind: Leaf(0x00000001) }]
Backtrace
```
Compiling explody v0.1.0 (/home/user/projects/explody)
error: where clauses are not allowed before tuple struct bodies
--> src/main.rs:5:53
|
5 | struct Test where [(); N as usize]: , ([u32; N as usize]);
| ---- ^^^^^^^^^^^^^^^^^^^^^^^^^ ------------------- the struct body
| | |
| while parsing this tuple struct unexpected where clause
|
help: move the body before the where clause
|
5 - struct Test where [(); N as usize]: , ([u32; N as usize]);
5 + struct Test([u32; N as usize]) where [(); N as usize]: ;
|
error: internal compiler error: compiler/rustc_middle/src/ty/subst.rs:933:9: const parameter `M/#1` (Const { ty: u32, kind: M/#1 }/1) out of range when substituting substs=[Const { ty: u32, kind: Leaf(0x00000001) }]
thread 'rustc' panicked at 'Box', /rustc/e9e1bbc7a820c472b39d3de54b3049bf14050655/compiler/rustc_errors/src/lib.rs:1651:9
stack backtrace:
0: std::panicking::begin_panic::
1: ::bug::
2: ::bug::
3: rustc_middle::util::bug::opt_span_bug_fmt::::{closure#0}
4: rustc_middle::ty::context::tls::with_opt::::{closure#0}, !>::{closure#0}
5: rustc_middle::ty::context::tls::with_context_opt::::{closure#0}, !>::{closure#0}, !>
6: rustc_middle::util::bug::bug_fmt
7: ::const_param_out_of_range
8: <&rustc_middle::ty::list::List as rustc_type_ir::fold::TypeFoldable>::try_fold_with::
9: >::super_fold_with::
10: >::super_fold_with::
11: >::try_fold_with::
12: as alloc::vec::spec_extend::SpecExtend, ::instantiate_into::{closure#0}>>>::spec_extend
13: ::instantiate_into
14: ::nominal_obligations_inner
15: ::compute
16: ::process_obligation
17: >::process_obligations::
18: ::type_inference_fallback
19: rustc_hir_typeck::typeck
20: >::call_once
21: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
22: rustc_query_system::query::plumbing::force_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt>
23: ::{closure#0} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_query_system::dep_graph::dep_node::DepNode)>>::call_once
24: >::try_mark_previous_green::
25: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
26: rustc_hir_analysis::check_crate
27: rustc_interface::passes::analysis
28: >::call_once
29: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
30: rustc_query_impl::get_query_incr::analysis
31: >::enter::, rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#4}>
32: ::enter::, rustc_span::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
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: rustc 1.71.0-nightly (e9e1bbc7a 2023-05-17) running on x86_64-unknown-linux-gnu
note: compiler flags: --crate-type bin -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 [typeck] type-checking `main`
#1 [used_trait_imports] finding used_trait_imports `main`
#2 [analysis] running analysis passes on this crate
end of query stack
there was a panic while trying to force a dep node
try_mark_green dep node stack:
#0 used_trait_imports(explody[44bf]::main)
end of try_mark_green dep node stack
error: could not compile `explody` (bin "explody") due to previous error
```
Code
Meta
rustc --version --verbose
:Error output
Backtrace
``` Compiling explody v0.1.0 (/home/user/projects/explody) error: where clauses are not allowed before tuple struct bodies --> src/main.rs:5:53 | 5 | struct Test where [(); N as usize]: , ([u32; N as usize]);
| ---- ^^^^^^^^^^^^^^^^^^^^^^^^^ ------------------- the struct body
| | |
| while parsing this tuple struct unexpected where clause
|
help: move the body before the where clause
|
5 - struct Test where [(); N as usize]: , ([u32; N as usize]);
5 + struct Test([u32; N as usize]) where [(); N as usize]: ;
|
error: internal compiler error: compiler/rustc_middle/src/ty/subst.rs:933:9: const parameter `M/#1` (Const { ty: u32, kind: M/#1 }/1) out of range when substituting substs=[Const { ty: u32, kind: Leaf(0x00000001) }]
thread 'rustc' panicked at 'Box', /rustc/e9e1bbc7a820c472b39d3de54b3049bf14050655/compiler/rustc_errors/src/lib.rs:1651:9
stack backtrace:
0: std::panicking::begin_panic::
1: ::bug::
2: ::bug::
3: rustc_middle::util::bug::opt_span_bug_fmt::::{closure#0}
4: rustc_middle::ty::context::tls::with_opt::::{closure#0}, !>::{closure#0}
5: rustc_middle::ty::context::tls::with_context_opt::::{closure#0}, !>::{closure#0}, !>
6: rustc_middle::util::bug::bug_fmt
7: ::const_param_out_of_range
8: <&rustc_middle::ty::list::List as rustc_type_ir::fold::TypeFoldable>::try_fold_with::
9: >::super_fold_with::
10: >::super_fold_with::
11: >::try_fold_with::
12: as alloc::vec::spec_extend::SpecExtend, ::instantiate_into::{closure#0}>>>::spec_extend
13: ::instantiate_into
14: ::nominal_obligations_inner
15: ::compute
16: ::process_obligation
17: >::process_obligations::
18: ::type_inference_fallback
19: rustc_hir_typeck::typeck
20: >::call_once
21: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
22: rustc_query_system::query::plumbing::force_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt>
23: ::{closure#0} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_query_system::dep_graph::dep_node::DepNode)>>::call_once
24: >::try_mark_previous_green::
25: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
26: rustc_hir_analysis::check_crate
27: rustc_interface::passes::analysis
28: >::call_once
29: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
30: rustc_query_impl::get_query_incr::analysis
31: >::enter::, rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#4}>
32: ::enter::, rustc_span::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
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: rustc 1.71.0-nightly (e9e1bbc7a 2023-05-17) running on x86_64-unknown-linux-gnu
note: compiler flags: --crate-type bin -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 [typeck] type-checking `main`
#1 [used_trait_imports] finding used_trait_imports `main`
#2 [analysis] running analysis passes on this crate
end of query stack
there was a panic while trying to force a dep node
try_mark_green dep node stack:
#0 used_trait_imports(explody[44bf]::main)
end of try_mark_green dep node stack
error: could not compile `explody` (bin "explody") due to previous error
```