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

Add #[rustc_safe_intrinsic] #100719

Merged
merged 4 commits into from
Sep 28, 2022

Conversation

CohenArthur
Copy link
Contributor

This PR adds the #[rustc_safe_intrinsic] attribute as mentionned on Zulip. The goal of this attribute is to avoid keeping a list of symbols as the source for stable intrinsics, and instead rely on an attribute. This is similar to #[rustc_const_stable] and #[rustc_const_unstable], which among other things, are used to mark the constness of intrinsic functions.

@rustbot rustbot added 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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Aug 18, 2022
@rust-highfive
Copy link
Collaborator

r? @compiler-errors

(rust-highfive has picked a reviewer for you, use r? to override)

@rustbot
Copy link
Collaborator

rustbot commented Aug 18, 2022

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

Some changes occurred in src/librustdoc/clean/types.rs

cc @camelid

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 18, 2022
@compiler-errors
Copy link
Member

Hm, Does this need a compiler MCP?

@compiler-errors
Copy link
Member

r? @wesleywiser since you said you would review the patches :)

@bors
Copy link
Contributor

bors commented Aug 28, 2022

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

@rust-log-analyzer

This comment has been minimized.

@CohenArthur
Copy link
Contributor Author

Following the discussion around the MCP, I've added the logic for checking the presence of the attribute on top of the existing "safe intrinsic list". This allows consumers of the core library to rely on the presence of the attribute, but keeps the compiler as the source of trust for which intrinsics are safe

@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added the T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. label Sep 10, 2022
@bjorn3
Copy link
Member

bjorn3 commented Sep 10, 2022

The first commit is a spurious duplicate of a commit that has already landed on master.

@bors
Copy link
Contributor

bors commented Sep 10, 2022

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

@CohenArthur CohenArthur force-pushed the rust-safe-intrinsic-attribute branch 2 times, most recently from d880fd4 to bb2d43d Compare September 13, 2022 13:49
@CohenArthur
Copy link
Contributor Author

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

This was fixed in 9192089 and bb2d43d by the way

Copy link
Member

@wesleywiser wesleywiser left a comment

Choose a reason for hiding this comment

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

Would you mind also adding a UI test for the compiler error? It would be good to test both #[rustc_safe_intrinsic] on an intrinsic that isn't safe and not having the attribute on an intrinsic that is safe. Since we call err and not fatal, I think you should be able to put both cases in the test.

Other than that, this looks good to me! 🙂

compiler/rustc_typeck/src/check/intrinsic.rs Outdated Show resolved Hide resolved
@bors
Copy link
Contributor

bors commented Sep 26, 2022

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

@CohenArthur
Copy link
Contributor Author

I've fixed the formatting, added the test and fixed the merge conflicts. The error does not have any location info at the moment, so I don't mind spending a little more time on that if you think it'd be worth it @wesleywiser

@bors
Copy link
Contributor

bors commented Sep 27, 2022

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

Copy link
Member

@wesleywiser wesleywiser left a comment

Choose a reason for hiding this comment

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

It should be easy enough to get a nice span associated with the error (I believe the suggestion I left is sufficient for that to happen) so let's go ahead and do that. The rest of this looks good to me!

compiler/rustc_hir_analysis/src/check/intrinsic.rs Outdated Show resolved Hide resolved
@wesleywiser
Copy link
Member

Thanks @CohenArthur!

@bors r+

@bors
Copy link
Contributor

bors commented Sep 28, 2022

📌 Commit b1b8649 has been approved by wesleywiser

It is now in the queue for this repository.

@bors bors 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 28, 2022
@bors
Copy link
Contributor

bors commented Sep 28, 2022

⌛ Testing commit b1b8649 with merge ce7f0f1...

@bors
Copy link
Contributor

bors commented Sep 28, 2022

☀️ Test successful - checks-actions
Approved by: wesleywiser
Pushing ce7f0f1 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 28, 2022
@bors bors merged commit ce7f0f1 into rust-lang:master Sep 28, 2022
@rustbot rustbot added this to the 1.66.0 milestone Sep 28, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ce7f0f1): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.4% [1.2%, 1.6%] 6
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.9% [3.9%, 3.9%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

This benchmark run did not return any relevant results for this metric.

Footnotes

  1. the arithmetic mean of the percent change 2

  2. number of relevant changes 2

@CohenArthur CohenArthur deleted the rust-safe-intrinsic-attribute branch September 29, 2022 07:26
Aaron1011 pushed a commit to Aaron1011/rust that referenced this pull request Jan 6, 2023
…ibute, r=wesleywiser

Add `#[rustc_safe_intrinsic]`

This PR adds the `#[rustc_safe_intrinsic]` attribute as mentionned on Zulip. The goal of this attribute is to avoid keeping a list of symbols as the source for stable intrinsics, and instead rely on an attribute. This is similar to `#[rustc_const_stable]` and `#[rustc_const_unstable]`, which among other things, are used to mark the constness of intrinsic functions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-infra Relevant to the infrastructure 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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants