Skip to content

fix macro attribute feature-gate span#158110

Open
pbkx wants to merge 2 commits into
rust-lang:mainfrom
pbkx:issue-147135-macro-attr-feature-gate-span
Open

fix macro attribute feature-gate span#158110
pbkx wants to merge 2 commits into
rust-lang:mainfrom
pbkx:issue-147135-macro-attr-feature-gate-span

Conversation

@pbkx

@pbkx pbkx commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Fixes #147135.

Issue #147135 reports a misleading feature-gate diagnostic for cross-crate macro_rules! macro attributes. This misleading feature-gate diagnostic causes rustc to point at the macro definition instead of user’s attribute call site.

My PR makes sure externally defined macro_rules! attributes are gated at the invocation span. Regression test verifies that the primary error points at the downstream #[foo::identity] attribute use

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 19, 2026
@rust-log-analyzer

This comment has been minimized.

@pbkx pbkx marked this pull request as ready for review June 19, 2026 05:54
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 19, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jun 19, 2026
@rustbot

rustbot commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

r? @Kivooeo

rustbot has assigned @Kivooeo.
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

Why was this reviewer chosen?

The reviewer was selected based on:

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

@Kivooeo

Kivooeo commented Jun 24, 2026

Copy link
Copy Markdown
Member

I wonder if we also should add a check for this check below?

if !features.macro_derive() {
feature_err(sess, sym::macro_derive, span, "`macro_rules!` derives are unstable")
.emit();
}

@Kivooeo Kivooeo added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

macro_attr feature gate error is spanned to the declaration of the macro when it should be the call site

4 participants