Rust: ICE when attempting to use const_evaluatable_checked without the feature enabled

Created on 22 Oct 2020  路  6Comments  路  Source: rust-lang/rust

Code

trait Ice{}
impl<const N: usize> Ice for [(); N] where [(); 2 * N]:{}

Meta

rustc --version --verbose:

rustc 1.47.0 (18bf6b4f0 2020-10-07)
binary: rustc
commit-hash: 18bf6b4f01a6feaf7259ba7cdae58031af1b7b39
commit-date: 2020-10-07
host: x86_64-pc-windows-msvc
release: 1.47.0
LLVM version: 11.0

Error output

error: internal compiler error: src\librustc_middle\ty\subst.rs:568:17: const parameter `N/#0` (Const { ty: usize, val: Param(N/#0) }/0) out of range when substituting substs=[]

thread 'rustc' panicked at 'Box<Any>', /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\src\librustc_errors\lib.rs:873:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

note: 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: rustc 1.47.0 (18bf6b4f0 2020-10-07) running on x86_64-pc-windows-msvc

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

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


Backtrace

error: internal compiler error: src\librustc_middle\ty\subst.rs:568:17: const parameter `N/#0` (Const { ty: usize, val: Param(N/#0) }/0) out of range when substituting substs=[]

thread 'rustc' panicked at 'Box<Any>', /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39\src\librustc_errors\lib.rs:873:9
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

note: 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: rustc 1.47.0 (18bf6b4f0 2020-10-07) running on x86_64-pc-windows-msvc

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

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

query stack during panic:
#0 [const_eval_raw] const-evaluating `<[u8; N] as Bruh>::{{constant}}#0`
#1 [const_eval_validated] const-evaluating + checking `<[u8; N] as Bruh>::{{constant}}#0`
#2 [const_eval_validated] const-evaluating + checking `<[u8; N] as Bruh>::{{constant}}#0`
#3 [param_env] computing normalized predicates of `<[u8; N] as Bruh>`
#4 [check_item_well_formed] checking that `<[u8; N] as Bruh>` is well-formed
#5 [analysis] running analysis passes on this crate
end of query stack

A-const-eval A-const-generics C-bug F-const_evaluatable_checked I-ICE T-compiler const-generics-fixed-by-const_generics const-generics-fixed-by-min_const_generics

Most helpful comment

@jonas-schievink

Ah, maybe not, with type generics it errors properly

Did you instead get a "type parameter has to be Sized" error? The following does ICE

trait Ice{}
impl<T> Ice for T where [(); 2 * std::mem::size_of::<*mut T>()]:{}

While it may not be a direct duplicate of #43408 it does have the same underlying issue and can't be fixed before the stabilization of min_const_generics. Therefore closing as duplicate

All 6 comments

Ah, maybe not, with type generics it errors properly

@rustbot modify labels: +const-generics-fixed-by-min-const-generics, +const-generics-fixed-by-const-generics, +A-const-generics, +F-const_evaluatable_checked

Error: Label const-generics-fixed-by-min-const-generics can only be set by Rust team members

Please let @rust-lang/release know if you're having trouble with this bot.

@workingjubilee Applied the labels you suggested.

@jonas-schievink

Ah, maybe not, with type generics it errors properly

Did you instead get a "type parameter has to be Sized" error? The following does ICE

trait Ice{}
impl<T> Ice for T where [(); 2 * std::mem::size_of::<*mut T>()]:{}

While it may not be a direct duplicate of #43408 it does have the same underlying issue and can't be fixed before the stabilization of min_const_generics. Therefore closing as duplicate

Was this page helpful?
0 / 5 - 0 ratings