-
Notifications
You must be signed in to change notification settings - Fork 13.3k
ICE during validation of ill-typed static: assertion left == right
failed at rustc_const_eval/src/interpret/validity.rs
#124164
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
ICE during validation of ill-typed static: assertion left == right
failed at rustc_const_eval/src/interpret/validity.rs
#124164
Comments
searched nightlies: from nightly-2024-04-01 to nightly-2024-04-19 bisected with cargo-bisect-rustc v0.6.8Host triple: aarch64-apple-darwin cargo bisect-rustc --start=2024-04-01 --end=2024-04-19 --preserve --regress=ice -vv It points to #122684 |
Oh, this is the usual -- there's an error that should make us not evaluate the static. It doesn't even have a type, how on earth are we trying to evaluate that?!? |
Probably because of fallback typeck figuring out that the static's type is |
I apologize for maybe just contributing noise since I don't have a reproducer, but I just hit this myself with a slightly different stack trace. I didn't even realize the compiler ICE'd, but the code that triggered this was when I was trying to accomplish the following: use core::cell::LazyCell;
#[repr(transparent)]
struct CachedPtr<T, F = fn() -> T>(LazyCell<T, F>);
unsafe impl<T, F> Sync for CachedPtr<T, F> {}
impl<T, F: FnOnce() -> T> CachedPtr<T, F> {
#[inline]
pub const fn new(f: F) -> CachedPtr<T, F> {
CachedPtr(LazyCell::new(f))
}
}
pub fn get_kernel32() -> PVOID {
static KERNEL32: CachedPtr<PVOID> = CachedPtr::new(|| {
let KERNEL32_STR: [u16; 13] = [75, 69, 82, 78, 69, 76, 51, 50, 46, 68, 76, 76, 0];
crate::get_module_by_name(KERNEL32_STR.as_ptr())
});
*KERNEL32.0
} Backtrace
|
left == right
failed at rustc_const_eval/src/interpret/validity.rs
left == right
failed at rustc_const_eval/src/interpret/validity.rs
@landaire This issue occurs when a static containing interior mutability doesn't have a type annotation. Your issue appears to be different. Could you produce a reproducer and open a new issue? |
…m-const, r=lcnr fix ICE when `asm_const` and `const_refs_to_static` are combined fixes rust-lang#129462 fixes rust-lang#126896 fixes rust-lang#124164 I think this is a case that was missed in the fix for rust-lang#125558, which inserts a type error in the case of an invalid (that is, non-integer) type being passed to an asm `const` operand. I'm not 100% sure that `span_mirbug_and_err` is the right macro here, but it is used earlier with `builtin_deref` and seems to do the trick. r? `@lcnr`
…m-const, r=lcnr fix ICE when `asm_const` and `const_refs_to_static` are combined fixes rust-lang#129462 fixes rust-lang#126896 fixes rust-lang#124164 I think this is a case that was missed in the fix for rust-lang#125558, which inserts a type error in the case of an invalid (that is, non-integer) type being passed to an asm `const` operand. I'm not 100% sure that `span_mirbug_and_err` is the right macro here, but it is used earlier with `builtin_deref` and seems to do the trick. r? ```@lcnr```
…m-const, r=lcnr fix ICE when `asm_const` and `const_refs_to_static` are combined fixes rust-lang#129462 fixes rust-lang#126896 fixes rust-lang#124164 I think this is a case that was missed in the fix for rust-lang#125558, which inserts a type error in the case of an invalid (that is, non-integer) type being passed to an asm `const` operand. I'm not 100% sure that `span_mirbug_and_err` is the right macro here, but it is used earlier with `builtin_deref` and seems to do the trick. r? ````@lcnr````
Rollup merge of rust-lang#129472 - folkertdev:const-refs-to-static-asm-const, r=lcnr fix ICE when `asm_const` and `const_refs_to_static` are combined fixes rust-lang#129462 fixes rust-lang#126896 fixes rust-lang#124164 I think this is a case that was missed in the fix for rust-lang#125558, which inserts a type error in the case of an invalid (that is, non-integer) type being passed to an asm `const` operand. I'm not 100% sure that `span_mirbug_and_err` is the right macro here, but it is used earlier with `builtin_deref` and seems to do the trick. r? ``@lcnr``
Code
(minimized)
EDIT:
static S_COUNT = std::sync::atomic::AtomicUsize::new(0);
also causes ICE.Original Code
Meta
rustc --version --verbose
:Command
rustc
Error output
Backtrace
Note
ICE-loc:
compiler/rustc_const_eval/src/interpret/validity.rs:727:21
rust/compiler/rustc_const_eval/src/interpret/validity.rs
Lines 726 to 728 in e3181b0
Original ICE-triggering code is mutated from test-file
dropck_trait_cycle_checked.rs
rust/tests/ui/dropck/dropck_trait_cycle_checked.rs
Line 12 in 07d0d7c
The text was updated successfully, but these errors were encountered: