Skip to content

Conversation

@oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Dec 9, 2025

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

Remove the custom special case rejecting const stability on macros as it is now handled by the general check
@rustbot
Copy link
Collaborator

rustbot commented Dec 9, 2025

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

Some changes occurred to constck

cc @fee1-dead

Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter
gets adapted for the changes, if necessary.

cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

⚠️ #[rustc_intrinsic_const_stable_indirect] controls whether intrinsics can be exposed to stable const
code; adding it needs t-lang approval.

cc @rust-lang/wg-const-eval

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Dec 9, 2025
#[rustc_intrinsic]
#[miri::intrinsic_fallback_is_spec]
#[rustc_intrinsic_const_stable_indirect]
pub const unsafe fn const_allocate(_size: usize, _align: usize) -> *mut u8 {
Copy link
Contributor Author

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

let alloc: *mut u8 = const_allocate(alloc_size, alloc_align);

Copy link
Member

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.

Copy link
Member

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.

@oli-obk oli-obk force-pushed the stable_inline_const_using_unstable_intrinsics branch from 5640606 to 8666a33 Compare December 9, 2025 16:34
@RalfJung
Copy link
Member

RalfJung commented Dec 9, 2025

Is this a fix for #132536? Or only a partial fix since it "just" applies to inline consts, not const items?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants