-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Stable inline const using unstable intrinsics #149817
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
base: main
Are you sure you want to change the base?
Stable inline const using unstable intrinsics #149817
Conversation
Remove the custom special case rejecting const stability on macros as it is now handled by the general check
|
Some changes occurred in compiler/rustc_attr_parsing Some changes occurred to constck cc @fee1-dead Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr Some changes occurred to the CTFE machinery
cc @rust-lang/wg-const-eval |
| #[rustc_intrinsic] | ||
| #[miri::intrinsic_fallback_is_spec] | ||
| #[rustc_intrinsic_const_stable_indirect] | ||
| pub const unsafe fn const_allocate(_size: usize, _align: usize) -> *mut u8 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this and make_global are needed in
rust/library/alloc/src/boxed/thin.rs
Line 334 in e2893f7
| let alloc: *mut u8 = const_allocate(alloc_size, alloc_align); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one really shouldn't be callable-from-stable, it is the very definition of not stable... same for const_make_global.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would strongly prefer to add allow_const_unstable to new_unsize_zst -- and we should consider if it's really safe to use these highly experimental features there.
That said, Thin is entirely unstable, so we can also add allow_const_unstable with a comment saying that this isn't actually stable -- but then we should also add that as a blocker on the tracking issue as it seems easy to miss.
5640606 to
8666a33
Compare
|
Is this a fix for #132536? Or only a partial fix since it "just" applies to inline consts, not const items? |
cc @RalfJung
Having moved several intrinsics from sth that gets invoked directly in a const fn to sth invoked in a const block kind of broke our "indirectly usable intrinsic" logic. So now we're actually checking it again. This required changing some intrinsics to now be indirectly callable
r? @jdonszelmann