Skip to content

Document that t-lang does not need involvement for unobservable intrinsics - #161675

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
RalfJung:intrinsic-approval
Sep 14, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
RalfJung:intrinsic-approval

Conversation

@RalfJung

@RalfJung RalfJung commented Aug 24, 2026 •

Copy link
Copy Markdown
Member

This turns the FCP (completed here) about intrinsics that could already be written on stable into documentation.

Also use this opportunity to document miri::intrinsic_fallback_is_spec.

r? @tgross35
Cc @rust-lang/lang

@rustbot

rustbot commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

⚠️ #[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

⚠️ #[miri::intrinsic_fallback_is_spec] must only be used if the function actively checks for all UB cases,
and explores the possible non-determinism of the intrinsic.

cc @rust-lang/miri

Any special-casing of Miri in the standard library requires review.

cc @rust-lang/miri

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

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

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 24, 2026
@rustbot

rustbot commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

tgross35 is currently at their maximum review capacity.
They may take a while to respond.

@RalfJung
RalfJung force-pushed the intrinsic-approval branch from e04e762 to 453be15 Compare August 24, 2026 14:12
@rust-log-analyzer

This comment has been minimized.

@RalfJung
RalfJung force-pushed the intrinsic-approval branch from 453be15 to 93c8b74 Compare August 24, 2026 14:23
Comment on lines +13 to +35
//! Intrinsics don't need a body. However, they optionally can have a body, which we call the
//! "fallback body". This will be used by codegen backends that do not have a dedicated
//! implementation of the intrinsic, making it easier to add new intrinsics for specific operations
//! without having to implement them in each codegen backend. The fallback body obviously has to be
//! a valid implementation of the documented specification of the intrinsic. In some cases, the
//! fallback body will be *equivalent* to the specification. Note that this is a strong requirement:
//! if the spec says "UB if input `x` is even", then a valid implementation can just ignore this and
//! do whatever it wants in that case; an *equivalent* implementation needs to actually check this
//! condition and trigger UB in that case (e.g. by using `hint::assert_unchecked()`). Similar, if
//! the spec says "returns `x` or `y` non-deterministically", then an *equivalent* implementation
//! must actually do non-deterministic choice and return either value (e.g. by invoking some other
//! language operation that has the same non-determinism). Intrinsics with such a fallback body that
//! is equivalent to the spec may be marked with `#[miri::intrinsic_fallback_is_spec]`; the fallback
//! body will then also be used by Miri for UB checking. When in doubt, do not use this attribute or
//! ask the Miri maintainers for advice.
//!
//! Intrinsics are, in general, language extensions. Therefore, t-lang should be involved whenever a
//! new intrinsic is exposed to stable code. However, if an intrinsic is marked
//! `#[miri::intrinsic_fallback_is_spec]` with a fallback body that only uses stable features (or if
//! such a fallback body could be written, but for one reason or another the actual fallback body is
//! different), and if it also does not make other promises that go beyond observable program
//! behavior (such as steering the optimizer in a particular direction), then an intrinsic may be
//! used without t-lang involvement.

@Urgau Urgau Aug 24, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a remark on my side, no need to do anything about it. This is quite a lot a word to say that if a intrinsic does something new (language wise, ie not using existing language features) it should be validated by T-lang, and everything else just need T-compiler approval.

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first paragraph explains a lot more than that. It explains the intrinsic_fallback_is_spec which is non-trivial, that's why I used so many words for it.

The second paragraph explains what you summarized. Happy to make it shorter if you have suggestions for how to concretely do that. It's non-trivial to say precisely what "something new" means.

@traviscross traviscross added T-lang Relevant to the language team I-lang-radar Items that are on lang's radar and will need eventual work or consideration. labels Aug 25, 2026

@traviscross traviscross left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks @RalfJung. r=me (when FCP completes and with @tgross35' r+).

View changes since this review

@RalfJung

Copy link
Copy Markdown
Member Author

The FCP has completed.
@tgross35 friendly reminder that this has been waiting for a while.
Or should I ask for a different reviewer? @Urgau left a comment, maybe they want to r+.

@Urgau

Urgau commented Sep 14, 2026

Copy link
Copy Markdown
Member

@bors r=traviscross,Urgau rollup

@rust-bors

rust-bors Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 93c8b74 has been approved by traviscross,Urgau

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 14, 2026
Zalathar added a commit to Zalathar/rust that referenced this pull request Sep 14, 2026
…viscross,Urgau

document that t-lang does not need involvement for unobservable intrisics

This turns the [FCP](rust-lang#161081 (comment)) (completed [here](rust-lang#161081 (comment))) about intrinsics that could already be written on stable into documentation.

Also use this opportunity to document `miri::intrinsic_fallback_is_spec`.

r? @tgross35
Cc @rust-lang/lang
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 14, 2026
…viscross,Urgau

document that t-lang does not need involvement for unobservable intrisics

This turns the [FCP](rust-lang#161081 (comment)) (completed [here](rust-lang#161081 (comment))) about intrinsics that could already be written on stable into documentation.

Also use this opportunity to document `miri::intrinsic_fallback_is_spec`.

r? @tgross35
Cc @rust-lang/lang
rust-bors Bot pushed a commit that referenced this pull request Sep 14, 2026
…uwer

Rollup of 11 pull requests

Successful merges:

 - #162752 (`rust-analyzer` subtree update)
 - #161868 (libtest: never iterate over all tests in `--exact` mode)
 - #161903 (Fix initialization cycle in `target_config`)
 - #162240 (Garbage-collect old incremental compilation sessions)
 - #161675 (document that t-lang does not need involvement for unobservable intrisics)
 - #162630 (Simplify the `G` in `Diag<'a, G>`)
 - #162647 (Add regression test for previous overflow evaluating the requirement)
 - #162703 (regression test for valtree leaf const)
 - #162723 (Add regression test for unexpected type for constructor)
 - #162735 (Remove pointless `A: Allocator` bounds in boxed.rs)
 - #162736 (clean up trivial region constraint filtering)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 14, 2026
…viscross,Urgau

document that t-lang does not need involvement for unobservable intrisics

This turns the [FCP](rust-lang#161081 (comment)) (completed [here](rust-lang#161081 (comment))) about intrinsics that could already be written on stable into documentation.

Also use this opportunity to document `miri::intrinsic_fallback_is_spec`.

r? @tgross35
Cc @rust-lang/lang
rust-bors Bot pushed a commit that referenced this pull request Sep 14, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - #162752 (`rust-analyzer` subtree update)
 - #161903 (Fix initialization cycle in `target_config`)
 - #162240 (Garbage-collect old incremental compilation sessions)
 - #162610 (fix tailcall indirect return)
 - #162634 (Implement semantic analysis for named `Fn` trait params)
 - #161675 (document that t-lang does not need involvement for unobservable intrisics)
 - #162160 (turn aligned-in-packed error into lint)
 - #162504 (Stabilize `unsafe_cell_access`)
 - #162516 (tidy: Sort multi-line types by treating `>` as a closing bracket)
 - #162630 (Simplify the `G` in `Diag<'a, G>`)
 - #162647 (Add regression test for previous overflow evaluating the requirement)
 - #162703 (regression test for valtree leaf const)
 - #162723 (Add regression test for unexpected type for constructor)
 - #162735 (Remove pointless `A: Allocator` bounds in boxed.rs)
 - #162736 (clean up trivial region constraint filtering)
rust-bors Bot pushed a commit that referenced this pull request Sep 14, 2026
…uwer

Rollup of 16 pull requests

Successful merges:

 - #162762 (Subtree sync for rustc_codegen_cranelift)
 - #162752 (`rust-analyzer` subtree update)
 - #161903 (Fix initialization cycle in `target_config`)
 - #162240 (Garbage-collect old incremental compilation sessions)
 - #162610 (fix tailcall indirect return)
 - #162634 (Implement semantic analysis for named `Fn` trait params)
 - #161675 (document that t-lang does not need involvement for unobservable intrisics)
 - #162160 (turn aligned-in-packed error into lint)
 - #162504 (Stabilize `unsafe_cell_access`)
 - #162516 (tidy: Sort multi-line types by treating `>` as a closing bracket)
 - #162630 (Simplify the `G` in `Diag<'a, G>`)
 - #162647 (Add regression test for previous overflow evaluating the requirement)
 - #162703 (regression test for valtree leaf const)
 - #162723 (Add regression test for unexpected type for constructor)
 - #162735 (Remove pointless `A: Allocator` bounds in boxed.rs)
 - #162736 (clean up trivial region constraint filtering)
@rust-bors
rust-bors Bot merged commit 41a5222 into rust-lang:main Sep 14, 2026
13 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Sep 14, 2026
rust-bors Bot pushed a commit that referenced this pull request Sep 14, 2026
Rollup merge of #161675 - RalfJung:intrinsic-approval, r=traviscross,Urgau

document that t-lang does not need involvement for unobservable intrisics

This turns the [FCP](#161081 (comment)) (completed [here](#161081 (comment))) about intrinsics that could already be written on stable into documentation.

Also use this opportunity to document `miri::intrinsic_fallback_is_spec`.

r? @tgross35
Cc @rust-lang/lang
@traviscross traviscross changed the title document that t-lang does not need involvement for unobservable intrisics document that t-lang does not need involvement for unobservable intrinsics Sep 15, 2026
@traviscross traviscross changed the title document that t-lang does not need involvement for unobservable intrinsics Document that t-lang does not need involvement for unobservable intrinsics Sep 15, 2026
@RalfJung
RalfJung deleted the intrinsic-approval branch September 16, 2026 06:03
github-actions Bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Sep 17, 2026
…uwer

Rollup of 16 pull requests

Successful merges:

 - rust-lang/rust#162762 (Subtree sync for rustc_codegen_cranelift)
 - rust-lang/rust#162752 (`rust-analyzer` subtree update)
 - rust-lang/rust#161903 (Fix initialization cycle in `target_config`)
 - rust-lang/rust#162240 (Garbage-collect old incremental compilation sessions)
 - rust-lang/rust#162610 (fix tailcall indirect return)
 - rust-lang/rust#162634 (Implement semantic analysis for named `Fn` trait params)
 - rust-lang/rust#161675 (document that t-lang does not need involvement for unobservable intrisics)
 - rust-lang/rust#162160 (turn aligned-in-packed error into lint)
 - rust-lang/rust#162504 (Stabilize `unsafe_cell_access`)
 - rust-lang/rust#162516 (tidy: Sort multi-line types by treating `>` as a closing bracket)
 - rust-lang/rust#162630 (Simplify the `G` in `Diag<'a, G>`)
 - rust-lang/rust#162647 (Add regression test for previous overflow evaluating the requirement)
 - rust-lang/rust#162703 (regression test for valtree leaf const)
 - rust-lang/rust#162723 (Add regression test for unexpected type for constructor)
 - rust-lang/rust#162735 (Remove pointless `A: Allocator` bounds in boxed.rs)
 - rust-lang/rust#162736 (clean up trivial region constraint filtering)
bjorn3 pushed a commit to rust-lang/rustc_codegen_cranelift that referenced this pull request Sep 18, 2026
…uwer

Rollup of 16 pull requests

Successful merges:

 - rust-lang/rust#162762 (Subtree sync for rustc_codegen_cranelift)
 - rust-lang/rust#162752 (`rust-analyzer` subtree update)
 - rust-lang/rust#161903 (Fix initialization cycle in `target_config`)
 - rust-lang/rust#162240 (Garbage-collect old incremental compilation sessions)
 - rust-lang/rust#162610 (fix tailcall indirect return)
 - rust-lang/rust#162634 (Implement semantic analysis for named `Fn` trait params)
 - rust-lang/rust#161675 (document that t-lang does not need involvement for unobservable intrisics)
 - rust-lang/rust#162160 (turn aligned-in-packed error into lint)
 - rust-lang/rust#162504 (Stabilize `unsafe_cell_access`)
 - rust-lang/rust#162516 (tidy: Sort multi-line types by treating `>` as a closing bracket)
 - rust-lang/rust#162630 (Simplify the `G` in `Diag<'a, G>`)
 - rust-lang/rust#162647 (Add regression test for previous overflow evaluating the requirement)
 - rust-lang/rust#162703 (regression test for valtree leaf const)
 - rust-lang/rust#162723 (Add regression test for unexpected type for constructor)
 - rust-lang/rust#162735 (Remove pointless `A: Allocator` bounds in boxed.rs)
 - rust-lang/rust#162736 (clean up trivial region constraint filtering)
pull Bot pushed a commit to xtqqczze/rust-lang-rust-analyzer that referenced this pull request Sep 21, 2026
…uwer

Rollup of 16 pull requests

Successful merges:

 - rust-lang/rust#162762 (Subtree sync for rustc_codegen_cranelift)
 - rust-lang/rust#162752 (`rust-analyzer` subtree update)
 - rust-lang/rust#161903 (Fix initialization cycle in `target_config`)
 - rust-lang/rust#162240 (Garbage-collect old incremental compilation sessions)
 - rust-lang/rust#162610 (fix tailcall indirect return)
 - rust-lang/rust#162634 (Implement semantic analysis for named `Fn` trait params)
 - rust-lang/rust#161675 (document that t-lang does not need involvement for unobservable intrisics)
 - rust-lang/rust#162160 (turn aligned-in-packed error into lint)
 - rust-lang/rust#162504 (Stabilize `unsafe_cell_access`)
 - rust-lang/rust#162516 (tidy: Sort multi-line types by treating `>` as a closing bracket)
 - rust-lang/rust#162630 (Simplify the `G` in `Diag<'a, G>`)
 - rust-lang/rust#162647 (Add regression test for previous overflow evaluating the requirement)
 - rust-lang/rust#162703 (regression test for valtree leaf const)
 - rust-lang/rust#162723 (Add regression test for unexpected type for constructor)
 - rust-lang/rust#162735 (Remove pointless `A: Allocator` bounds in boxed.rs)
 - rust-lang/rust#162736 (clean up trivial region constraint filtering)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

I-lang-radar Items that are on lang's radar and will need eventual work or consideration. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-lang Relevant to the language team 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.

6 participants