-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ICE: write_immediate_to_mplace: invalid ScalarPair layout: TyAndLayout
with feature adt_const_params
#126272
Comments
searched nightlies: from nightly-2023-01-01 to nightly-2024-05-30 bisected with cargo-bisect-rustc v0.6.8Host triple: x86_64-unknown-linux-gnu cargo bisect-rustc --start=2023-01-01 --end=2024-05-30 --regress=ice --script=rustc --preserve -- 126272.rs |
Slight minimization: #![feature(adt_const_params)]
#![allow(incomplete_features)]
use std::marker::ConstParamTy;
#[derive(Debug, PartialEq, Eq, ConstParamTy)]
struct Foo {
nested: &'static Bar<dyn std::fmt::Debug>,
}
#[derive(Debug, PartialEq, Eq, ConstParamTy)]
struct Bar<T>(T);
struct Test<const F: Foo>;
fn main() {
let x: Test<{ Foo { nested: &Bar(4) } }> = Test;
} |
It appears what's happening is that due to the implicit Note that the error at the usage site is not reported in non-const code either:struct Foo {
nested: &'static Bar<dyn std::fmt::Debug>,
}
struct Bar<T>(T);
fn main() {
let x = Foo { nested: &Bar(4) };
}
cc @oli-obk since this relates to typeck tainting |
WF-check struct field types at construction site Fixes rust-lang#126272. Fixes rust-lang#127299. Rustc of course already WF-checked the field types at the definition site, but for error tainting of consts to work properly, there needs to be an error emitted at the use site. Previously, with no use-site error, we proceeded with CTFE and ran into ICEs since we are running code with type errors. Emitting use-site errors also brings struct-like constructors more in line with fn-like constructors since they already emit use-site errors for WF issues. r? `@BoxyUwU`
Code
(hand-reduced)
It seems that the above example may not be minimal, as it generates multiple errors.
(original)
Meta
rustc --version --verbose
:Error output
Command:
rustc
Backtrace
Notes
rustc_const_eval/src/interpret/place.rs L710
rust/compiler/rustc_const_eval/src/interpret/place.rs
Lines 708 to 715 in b5b1356
tests/ui/const-generics/issue-66451.rs
@rustbot label +F-adt_const_params +requires-incomplete-features
The text was updated successfully, but these errors were encountered: