-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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: expected Box to contain Unique #98372
Comments
Isn't this expected ? The definition of rust/library/alloc/src/boxed.rs Lines 194 to 197 in 3d829a0
The fix here would be to add a definition of for |
This ICEs since #95576 |
reduced. #![feature(
no_core, lang_items, intrinsics, unboxed_closures, type_ascription, extern_types,
untagged_unions, decl_macro, rustc_attrs, transparent_unions, auto_traits,
thread_local
)]
#![no_core]
#[lang = "sized"]
pub trait Sized {}
#[lang = "unsize"]
pub trait Unsize<T: ?Sized> {}
#[lang = "coerce_unsized"]
pub trait CoerceUnsized<T> {}
#[lang = "copy"]
pub trait Copy {}
#[lang = "sync"]
pub unsafe trait Sync {}
unsafe impl Sync for [u8; 16] {}
pub trait Allocator {
}
pub struct Global;
impl Allocator for Global {}
#[lang = "owned_box"]
pub struct Box<
T: ?Sized,
A: Allocator = Global,
>(*mut T, A); |
I agree that this is an expected ICE (misuse of lang items), and minicore needs to define a For a worse ICE that doesn't give context, try ending with
|
Hm, so is it wrong that the code compiler before? 🤔 |
cg_clif's mini_core already uses |
@matthiaskrgr It just so happened that previously it compiled. Lang items are very easy to misuse as they the compiler expects specific definitions, but doesn't do much checks that the actual definitions match the expectations. |
Not sure how much we should be doing here beyond improving the ICEs. We can replicate the entire lang item structure inside the compiler, but that's just complex code duplication. The standard library is already the code that defines it. What we could try is to pull out the relevant definitions so that all the minicore crates are just a bunch of |
How would that work with subtrees? Both rustc_codegen_cranelift and rustc_codegen_gcc can be compiled outside of the main rust repo. This means that they can't |
Hm... yea. that won't work :( |
If we wanted, we could publish a minicore to crates-io. (In fact, the minicore name is available.) However, the benefit of minicores for testing is mostly in having it inline and highly domain specific, so that might cancel out nearly all of the benefits. (For this specific case, the eventual “correct” solution is “just” to stop directly codegening box deref and rely on its Rambling about future possibilitiesIn the future, it might be nice to incrementally extract the "I know X about the shape of lang item Z" earlier into the compiler, rather than having it scattered about the compiler. Doing so would have a twofold benefit:
For this case, you'd have a derived lang item for the projection However, this is probably overengineering for a failure case which is inherently an unsafe violation of preconditions, and just marking and using the one lang item system is simpler. |
closing as wontfix |
Code
./compiler/rustc_codegen_gcc/example/mini_core.rs
Don't have time to reduce right now, sorry
reduced: #98372 (comment)
Meta
rustc --version --verbose
:Error output
Backtrace
The text was updated successfully, but these errors were encountered: