Skip to content
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

mark is_val_statically_known intrinsic as stably const-callable #132449

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented Nov 1, 2024

The intrinsic doesn't actually "do" anything in terms of language semantics, and we are already using it in stable const fn. So let's just properly mark it as stably const-callable to avoid needing rustc_allow_const_fn_unstable (and thus reducing noise and keeping the remaining rustc_allow_const_fn_unstable as a more clear signal).

Cc @rust-lang/lang usually you have to approve exposing intrinsics in const, but this intrinsic is basically just a compiler implementation detail. So FCP doesn't seem necessary.
Cc @rust-lang/wg-const-eval

@rustbot
Copy link
Collaborator

rustbot commented Nov 1, 2024

r? @ibraheemdev

rustbot has assigned @ibraheemdev.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@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 Nov 1, 2024
@RalfJung RalfJung added the I-lang-easy-decision Issue: The decision needed by the team is conjectured to be easy. label Nov 1, 2024
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@traviscross
Copy link
Contributor

@rustbot labels +I-lang-nominated

Purported easy items must still be nominated to make it onto our agenda.

@rustbot rustbot added the I-lang-nominated Nominated for discussion during a lang team meeting. label Nov 2, 2024
@@ -2802,7 +2802,6 @@ where
/// In other words, the following code has *Undefined Behavior*:
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this intrinsic be unsafe?

Copy link
Contributor

Choose a reason for hiding this comment

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

pub const fn is_val_statically_known<T: Copy>(_arg: T) -> bool {

it doesn't appear to be...?

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, discussed a bit in the meeting, I see that the unsafe thing is the use of unreachable, but it still feels like the user has a kind of obligation to use the result of this value to produce an "equivalent" results (i.e., it's intended for "performance specialization"). I suppose that we no longer guarantee deterministic results so maybe that's par for the course and not unsafe

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, we made const_eval_select safe with the same reasoning -- it's not UB-inducing, just undesired.

@traviscross
Copy link
Contributor

@rfcbot fcp merge

Thanks @RalfJung for working to clean this sort of thing up.

@traviscross traviscross added T-lang Relevant to the language team, which will review and decide on the PR/issue. and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Nov 6, 2024
@traviscross
Copy link
Contributor

@rfcbot fcp merge

@rfcbot
Copy link

rfcbot commented Nov 6, 2024

Team member @traviscross has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns.
See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Nov 6, 2024
@rfcbot
Copy link

rfcbot commented Nov 6, 2024

🔔 This is now entering its final comment period, as per the review above. 🔔

@nikomatsakis
Copy link
Contributor

@rfcbot reviewed

@compiler-errors
Copy link
Member

r=me after fcp

@RalfJung
Copy link
Member Author

RalfJung commented Nov 6, 2024

@rust-lang/lang I heard questions about the new stability attributes came up in the meeting today. If you are curious you can read the docs at https://rustc-dev-guide.rust-lang.org/stability.html#rustc_const_unstable. :)

@RalfJung
Copy link
Member Author

RalfJung commented Nov 6, 2024

Thanks for working to clean this sort of thing up.

I went over all the rustc_allow_const_fn_unstable and this was the last one, so we're all cleaned up there now. :)
Same for rustc_const_unstable, those are all either in FCP or still very fresh (except for HashMap::with_hasher, I am working on that one). So we are ready for the next wave of unstable experimentation, with const traits. :)

@traviscross traviscross removed the I-lang-nominated Nominated for discussion during a lang team meeting. label Nov 6, 2024
@bors
Copy link
Contributor

bors commented Nov 8, 2024

☔ The latest upstream changes (presumably #132756) made this pull request unmergeable. Please resolve the merge conflicts.

@rustbot
Copy link
Collaborator

rustbot commented Nov 8, 2024

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

cc @rust-lang/miri, @rust-lang/wg-const-eval

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. I-lang-easy-decision Issue: The decision needed by the team is conjectured to be easy. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants