Skip to content

Associated Types + Const Evaluatable Checked ICE #78246

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
beepster4096 opened this issue Oct 22, 2020 · 1 comment · Fixed by #82009
Closed

Associated Types + Const Evaluatable Checked ICE #78246

beepster4096 opened this issue Oct 22, 2020 · 1 comment · Fixed by #82009
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) A-const-generics Area: const generics (parameters and arguments) A-trait-system Area: Trait system C-bug Category: This is a bug. F-const_generics `#![feature(const_generics)]` F-generic_const_exprs `#![feature(generic_const_exprs)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@beepster4096
Copy link
Contributor

Code

#![feature(const_generics, const_evaluatable_checked)]

pub trait Ice {
	type Array;

	fn into_bytes(self) -> Self::Array;
}

impl<T: Ice, const N: usize> Ice for [T; N] where
	[(); std::mem::size_of::<T::Array>() * N]:
{
	type Array = [(); std::mem::size_of::<T::Array>() * N];

	fn into_bytes(self) -> Self::Array {}
}

Meta

rustc --version --verbose:

rustc 1.49.0-nightly (31530e5d1 2020-10-20)
binary: rustc
commit-hash: 31530e5d132ebcc3654baf2e5460599681520af0
commit-date: 2020-10-20
host: x86_64-pc-windows-msvc
release: 1.49.0-nightly
LLVM version: 11.0

Error output

error: internal compiler error: compiler\rustc_traits\src\normalize_erasing_regions.rs:37:32: could not fully normalize `Const { ty: fn() -> usize {std::mem::size_of::<<T as Ice>::Array>}, val: Value(Scalar(<ZST>)) }`

thread 'rustc' panicked at 'Box<Any>', compiler\rustc_errors\src\lib.rs:945: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.49.0-nightly (31530e5d1 2020-10-20) 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 [normalize_generic_arg_after_erasing_regions] normalizing `std::mem::size_of::<<T as Ice>::Array>`
#1 [eval_to_allocation_raw] const-evaluating + checking `<[T; N] as Ice>::Array::{constant#0}`
end of query stack
Backtrace

error: internal compiler error: compiler\rustc_traits\src\normalize_erasing_regions.rs:37:32: could not fully normalize `Const { ty: fn() -> usize {std::mem::size_of::<<T as Ice>::Array>}, val: Value(Scalar(<ZST>)) }`

thread 'rustc' panicked at 'Box<Any>', compiler\rustc_errors\src\lib.rs:945: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.49.0-nightly (31530e5d1 2020-10-20) 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 [normalize_generic_arg_after_erasing_regions] normalizing `std::mem::size_of::<<T as Ice>::Array>`
#1 [eval_to_allocation_raw] const-evaluating + checking `<[T; N] as Ice>::Array::{constant#0}`
#2 [eval_to_const_value_raw] simplifying constant for the type system `<[T; N] as Ice>::Array::{constant#0}`
#3 [eval_to_const_value_raw] simplifying constant for the type system `<[T; N] as Ice>::Array::{constant#0}`
#4 [typeck] type-checking `<[T; N] as Ice>::into_bytes`
#5 [typeck_item_bodies] type-checking all item bodies
#6 [analysis] running analysis passes on this crate
end of query stack

I think I'm an ICE magnet; this is my fourth one.

@beepster4096 beepster4096 added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 22, 2020
@beepster4096
Copy link
Contributor Author

I'd like to note that it only ICEs with the wrong return type. The following does not ICE

#![feature(const_generics, const_evaluatable_checked)]

pub trait Ice {
	type Array;

	fn into_bytes(self) -> Self::Array;
}

impl<T: Ice, const N: usize> Ice for [T; N] where
	[(); std::mem::size_of::<T::Array>() * N]:
{
	type Array = [(); std::mem::size_of::<T::Array>() * N];

	fn into_bytes(self) -> Self::Array {
	    todo!()
	}
}

@camelid camelid added A-trait-system Area: Trait system A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) A-const-generics Area: const generics (parameters and arguments) requires-nightly This issue requires a nightly compiler in some way. F-generic_const_exprs `#![feature(generic_const_exprs)]` F-const_generics `#![feature(const_generics)]` labels Oct 22, 2020
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Oct 23, 2020
JohnTitor added a commit to JohnTitor/rust that referenced this issue Feb 15, 2021
const_generics: Dont evaluate array length const when handling errors

Fixes rust-lang#79518
Fixes rust-lang#78246

cc `@lcnr`

This was ICE'ing because we dont pass in the correct ``ParamEnv`` which meant that there was no ``Self: Foo`` predicate to make ``Self::Assoc`` well formed which caused an ICE when trying to normalize ``Self::Assoc`` in the mir interpreter

r? `@varkor`
JohnTitor added a commit to JohnTitor/rust that referenced this issue Feb 15, 2021
const_generics: Dont evaluate array length const when handling errors

Fixes rust-lang#79518
Fixes rust-lang#78246

cc ``@lcnr``

This was ICE'ing because we dont pass in the correct ``ParamEnv`` which meant that there was no ``Self: Foo`` predicate to make ``Self::Assoc`` well formed which caused an ICE when trying to normalize ``Self::Assoc`` in the mir interpreter

r? ``@varkor``
@bors bors closed this as completed in 6fde3c5 Feb 16, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) A-const-generics Area: const generics (parameters and arguments) A-trait-system Area: Trait system C-bug Category: This is a bug. F-const_generics `#![feature(const_generics)]` F-generic_const_exprs `#![feature(generic_const_exprs)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants