Skip to content

Move "macro only" check for #[allow_internal_unsafe/unstable] to attribute parser - #160034

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
sethryanrollins:sethr/issue-153101/check_macro_only_attr
Jul 31, 2026
Merged

Move "macro only" check for #[allow_internal_unsafe/unstable] to attribute parser#160034
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
sethryanrollins:sethr/issue-153101/check_macro_only_attr

Conversation

@sethryanrollins

@sethryanrollins sethryanrollins commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Part of #131229 which is the parent issue of #153101

@JonathanBrouwer

@rustbot

rustbot commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann, @JonathanBrouwer

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann, @JonathanBrouwer

@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. labels Jul 28, 2026
@rustbot

rustbot commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @mati865 (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue
Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 74 candidates
  • Random selection from 20 candidates

@rustbot

This comment has been minimized.

@rustbot rustbot added has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 28, 2026
@sethryanrollins
sethryanrollins force-pushed the sethr/issue-153101/check_macro_only_attr branch from 1d88cdc to b8cbe9a Compare July 28, 2026 13:58
@rustbot

This comment has been minimized.

@rustbot rustbot removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. has-merge-commits PR has merge commits, merge with caution. labels Jul 28, 2026
@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@rustbot rustbot added has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 29, 2026
@mati865

mati865 commented Jul 30, 2026

Copy link
Copy Markdown
Member

@rustbot reroll

@rustbot rustbot assigned TaKO8Ki and unassigned mati865 Jul 30, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Contributor

r? me
I'm happy to review this after the merge commit is fixed

@rustbot rustbot assigned JonathanBrouwer and unassigned TaKO8Ki Jul 30, 2026
@sethryanrollins

Copy link
Copy Markdown
Contributor Author

I can fix the conflict within the hour once I get into work

@sethryanrollins
sethryanrollins force-pushed the sethr/issue-153101/check_macro_only_attr branch from c7bce2c to ccc55c3 Compare July 30, 2026 13:37
@rustbot

rustbot commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rustbot rustbot removed has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 30, 2026
@JonathanBrouwer JonathanBrouwer changed the title Sethr/issue 153101/check macro only attr Move "macro only" check for #[allow_internal_unsafe/unstable] to attribute parser Jul 31, 2026
/// Applying them to a function is only allowed if that function is a procedural macro, i.e. it
/// also carries `#[proc_macro]`, `#[proc_macro_attribute]`, or `#[proc_macro_derive]`.
pub(crate) fn check_macro_only(cx: &FinalizeCheckContext<'_, '_>, attr_span: Span) {
if cx.target == Target::Fn

@JonathanBrouwer JonathanBrouwer Jul 31, 2026

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.

Is this cx.target == Target::Fn check necessary? Does the finalize_check run if target checking fails?

View changes since the review

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.

Oh right it's necessary because these attributes are also valid on Target::MacroDef, this makes sense

@JonathanBrouwer JonathanBrouwer 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.

@bors r+ rollup
Thanks! (also made your title a bit clearer :3)

View changes since this review

@rust-bors

rust-bors Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

📌 Commit ccc55c3 has been approved by JonathanBrouwer

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 Jul 31, 2026
@sethryanrollins

Copy link
Copy Markdown
Contributor Author

@JonathanBrouwer ahah many thanks!

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 31, 2026
…/check_macro_only_attr, r=JonathanBrouwer

Move "macro only" check for `#[allow_internal_unsafe/unstable]` to attribute parser

Part of rust-lang#131229 which is the parent issue of rust-lang#153101

@JonathanBrouwer
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 31, 2026
…/check_macro_only_attr, r=JonathanBrouwer

Move "macro only" check for `#[allow_internal_unsafe/unstable]` to attribute parser

Part of rust-lang#131229 which is the parent issue of rust-lang#153101

@JonathanBrouwer
rust-bors Bot pushed a commit that referenced this pull request Jul 31, 2026
…uwer

Rollup of 21 pull requests

Successful merges:

 - #160100 (Add "system" option to `override-allocator` directive)
 - #159675 (rustc: Support `--jobs` options for limiting parallelism in various parts of the compiler)
 - #159999 (Fix invalidation of stdlib in bootstrap when using non-LLVM codegen backends)
 - #160233 (Bubble bad path error while parsing field to avoid unecessary second error)
 - #160272 (rustc_metadata: Move native library search code to `rustc_codegen_ssa`)
 - #154202 (rustfmt: Format `cfg_select!`)
 - #158835 (rustc_passes: lint unused `#[path]` attributes on inline modules)
 - #159520 (Suggest `Vec<T>` instead of `[T]`)
 - #160034 (Move "macro only" check for `#[allow_internal_unsafe/unstable]` to attribute parser)
 - #160066 (rustc_middle: lint attribute cleanups)
 - #160085 (Remove various superfluous lint attributes)
 - #160113 (Coalesce `rustc_on_unimplemented` attributes and lint malformed filters)
 - #160119 (fix query cycle in `coroutine_hidden_types` for the next solver)
 - #160147 (tests: Remove `-Zthreads` options from tests in `ui/parallel-rustc`)
 - #160157 (Remove outdated comments from `va_list.rs`)
 - #160159 (More accurately check for interior mutability in `invalid_reference_casting` lint)
 - #160208 (rustdoc: Fix crash when trying to list attributes on an opaque type)
 - #160244 (Rename splat to rustc_splat in error messages)
 - #160246 (dont fire `unused_mut` on `&pin mut self`)
 - #160247 (Configure backport nominations for rustfmt)
 - #160274 (renovate: update lock files weekly)
rust-bors Bot pushed a commit that referenced this pull request Jul 31, 2026
…uwer

Rollup of 22 pull requests

Successful merges:

 - #160100 (Add "system" option to `override-allocator` directive)
 - #160220 (Refactor: shrink region ext traits)
 - #159675 (rustc: Support `--jobs` options for limiting parallelism in various parts of the compiler)
 - #159999 (Fix invalidation of stdlib in bootstrap when using non-LLVM codegen backends)
 - #160233 (Bubble bad path error while parsing field to avoid unecessary second error)
 - #160272 (rustc_metadata: Move native library search code to `rustc_codegen_ssa`)
 - #154202 (rustfmt: Format `cfg_select!`)
 - #159520 (Suggest `Vec<T>` instead of `[T]`)
 - #159710 (Add rustdoc/cargo PGO profiles to reproducible artifacts)
 - #160034 (Move "macro only" check for `#[allow_internal_unsafe/unstable]` to attribute parser)
 - #160066 (rustc_middle: lint attribute cleanups)
 - #160085 (Remove various superfluous lint attributes)
 - #160113 (Coalesce `rustc_on_unimplemented` attributes and lint malformed filters)
 - #160119 (fix query cycle in `coroutine_hidden_types` for the next solver)
 - #160147 (tests: Remove `-Zthreads` options from tests in `ui/parallel-rustc`)
 - #160157 (Remove outdated comments from `va_list.rs`)
 - #160159 (More accurately check for interior mutability in `invalid_reference_casting` lint)
 - #160208 (rustdoc: Fix crash when trying to list attributes on an opaque type)
 - #160244 (Rename splat to rustc_splat in error messages)
 - #160246 (dont fire `unused_mut` on `&pin mut self`)
 - #160247 (Configure backport nominations for rustfmt)
 - #160274 (renovate: update lock files weekly)
@rust-bors
rust-bors Bot merged commit 6b1aa7a into rust-lang:main Jul 31, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Jul 31, 2026
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-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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants