Skip to content

Handle macro invocation in attribute during parse#146579

Merged
bors merged 4 commits intorust-lang:mainfrom
estebank:issue-146325
Dec 10, 2025
Merged

Handle macro invocation in attribute during parse#146579
bors merged 4 commits intorust-lang:mainfrom
estebank:issue-146325

Conversation

@estebank
Copy link
Copy Markdown
Contributor

@estebank estebank commented Sep 15, 2025

error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found macro `concat`
  --> $DIR/macro-in-attribute.rs:4:21
   |
LL | #[deprecated(note = concat!("a", "b"))]
   |                     ^^^^^^^^^^^^^^^^^ macros are not allowed here

Fix #146325.

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Sep 15, 2025

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

@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 Sep 15, 2025
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Sep 15, 2025

r? @davidtwco

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

let before = self.parser.token.span.shrink_to_lo();
while let token::Ident(..) = self.parser.token.kind {
self.parser.bump();
if self.parser.look_ahead(1, |t| matches!(t.kind, token::TokenKind::Bang)) {
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.

What if we meet:

#[deprecated(note = a!=b)]
struct X;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Silly me, I organized things thinking of only parsing a macro and not a statement. I think that parse_stmt_without_recovery will fail because of a lack of ;, but I can look at the stmt.kind instead. It should give the error with no note or structured suggestion.

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.

I'll wait with further review for this

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.

generally looking good though :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed

@jdonszelmann
Copy link
Copy Markdown
Contributor

r? jdonszelmann

@rustbot rustbot assigned jdonszelmann and unassigned davidtwco Sep 15, 2025
@jdonszelmann
Copy link
Copy Markdown
Contributor

r? author

@rustbot

This comment was marked as resolved.

@jdonszelmann jdonszelmann 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 Sep 16, 2025
@rustbot

This comment has been minimized.

@estebank estebank added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 28, 2025
@jdonszelmann
Copy link
Copy Markdown
Contributor

@rustbot author

@rustbot rustbot 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 Sep 29, 2025
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Sep 29, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@bors

This comment was marked as outdated.

@rustbot

This comment has been minimized.

@estebank
Copy link
Copy Markdown
Contributor Author

estebank commented Nov 3, 2025

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 3, 2025
@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 Nov 10, 2025
ChrisDenton added a commit to ChrisDenton/rust that referenced this pull request Nov 10, 2025
Handle macro invocation in attribute during parse

```
error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found macro `concat`
  --> $DIR/macro-in-attribute.rs:4:21
   |
LL | #[deprecated(note = concat!("a", "b"))]
   |                     ^^^^^^^^^^^^^^^^^ macros are not allowed here
```

Fix rust-lang#146325.
ChrisDenton added a commit to ChrisDenton/rust that referenced this pull request Nov 10, 2025
Handle macro invocation in attribute during parse

```
error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found macro `concat`
  --> $DIR/macro-in-attribute.rs:4:21
   |
LL | #[deprecated(note = concat!("a", "b"))]
   |                     ^^^^^^^^^^^^^^^^^ macros are not allowed here
```

Fix rust-lang#146325.
@JonathanBrouwer
Copy link
Copy Markdown
Contributor

@bors r-

Conflict with #148712
Please rebase on that after it merges

#148800 (comment)

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 10, 2025
@JonathanBrouwer
Copy link
Copy Markdown
Contributor

The conflicting PR merged, @estebank could you rebase?

estebank and others added 4 commits December 9, 2025 01:16
```
error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found macro `concat`
  --> $DIR/macro-in-attribute.rs:4:21
   |
LL | #[deprecated(note = concat!("a", "b"))]
   |                     ^^^^^^^^^^^^^^^^^ macros are not allowed here
```
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Dec 9, 2025

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.

@JonathanBrouwer
Copy link
Copy Markdown
Contributor

@bors r=jdonszelmann rollup

@bors
Copy link
Copy Markdown
Collaborator

bors commented Dec 9, 2025

📌 Commit 761cb57 has been approved by jdonszelmann

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 9, 2025
bors added a commit that referenced this pull request Dec 9, 2025
Rollup of 5 pull requests

Successful merges:

 - #144938 (Enable `outline-atomics` by default on more AArch64 platforms)
 - #146579 (Handle macro invocation in attribute during parse)
 - #149400 (unstable proc_macro tracked::* rename/restructure)
 - #149664 (attempt to fix unreachable code regression )
 - #149806 (Mirror `ubuntu:24.04` on ghcr)

Failed merges:

 - #149789 (Cleanup in the attribute parsers)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Dec 9, 2025
Rollup of 5 pull requests

Successful merges:

 - #144938 (Enable `outline-atomics` by default on more AArch64 platforms)
 - #146579 (Handle macro invocation in attribute during parse)
 - #149400 (unstable proc_macro tracked::* rename/restructure)
 - #149664 (attempt to fix unreachable code regression )
 - #149806 (Mirror `ubuntu:24.04` on ghcr)

Failed merges:

 - #149789 (Cleanup in the attribute parsers)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 90dc2b6 into rust-lang:main Dec 10, 2025
11 checks passed
@rustbot rustbot added this to the 1.94.0 milestone Dec 10, 2025
rust-timer added a commit that referenced this pull request Dec 10, 2025
Rollup merge of #146579 - estebank:issue-146325, r=jdonszelmann

Handle macro invocation in attribute during parse

```
error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found macro `concat`
  --> $DIR/macro-in-attribute.rs:4:21
   |
LL | #[deprecated(note = concat!("a", "b"))]
   |                     ^^^^^^^^^^^^^^^^^ macros are not allowed here
```

Fix #146325.
github-actions bot pushed a commit to rust-lang/compiler-builtins that referenced this pull request Dec 11, 2025
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#144938 (Enable `outline-atomics` by default on more AArch64 platforms)
 - rust-lang/rust#146579 (Handle macro invocation in attribute during parse)
 - rust-lang/rust#149400 (unstable proc_macro tracked::* rename/restructure)
 - rust-lang/rust#149664 (attempt to fix unreachable code regression )
 - rust-lang/rust#149806 (Mirror `ubuntu:24.04` on ghcr)

Failed merges:

 - rust-lang/rust#149789 (Cleanup in the attribute parsers)

r? `@ghost`
`@rustbot` modify labels: rollup
@Kobzol
Copy link
Copy Markdown
Member

Kobzol commented Dec 16, 2025

@rust-timer build baf3ab6

Trying if this regressed perf. in #149818 (although quite unlikely).

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (baf3ab6): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.5% [-1.0%, -0.3%] 3
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary 3.2%, secondary -3.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
3.2% [3.2%, 3.2%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.2% [-3.2%, -3.2%] 1
All ❌✅ (primary) 3.2% [3.2%, 3.2%] 1

Cycles

Results (primary 2.1%, secondary -2.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.1% [2.1%, 2.1%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.2% [-2.2%, -2.2%] 1
All ❌✅ (primary) 2.1% [2.1%, 2.1%] 1

Binary size

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

Bootstrap: 471.772s -> 471.951s (0.04%)
Artifact size: 389.00 MiB -> 389.01 MiB (0.00%)

tgross35 pushed a commit to rust-lang/compiler-builtins that referenced this pull request Jan 31, 2026
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#144938 (Enable `outline-atomics` by default on more AArch64 platforms)
 - rust-lang/rust#146579 (Handle macro invocation in attribute during parse)
 - rust-lang/rust#149400 (unstable proc_macro tracked::* rename/restructure)
 - rust-lang/rust#149664 (attempt to fix unreachable code regression )
 - rust-lang/rust#149806 (Mirror `ubuntu:24.04` on ghcr)

Failed merges:

 - rust-lang/rust#149789 (Cleanup in the attribute parsers)

r? `@ghost`
`@rustbot` modify labels: rollup
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.

#[deprecated(note = concat!("a", "b"))] suggestion gets nowhere

9 participants