Skip to content

Undo accidental duplication checking for attributes on macro calls - #166374

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
JonathanBrouwer:undo-regression
Nov 24, 2026
Merged

rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
JonathanBrouwer:undo-regression

Conversation

@JonathanBrouwer

Copy link
Copy Markdown
Member

@rustbot rustbot added 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 Nov 23, 2026
@mejrs

mejrs commented Nov 23, 2026

Copy link
Copy Markdown
Member

Hmm, are there actually attributes that are both allowed on macro invocations and produce errors when combined?

If not then this PR actually isn't necessary.

@mejrs

mejrs commented Nov 23, 2026

Copy link
Copy Markdown
Member

Ah, found one:

#[link_ordinal(2)]
#[link_ordinal(3)]
println!();

Can you add this as a test?

@JonathanBrouwer

Copy link
Copy Markdown
Member Author

Deprecated also works, I will use that as link_ordinal has platform dependant behavior

Comment thread compiler/rustc_expand/src/expand.rs Outdated
} else {
attrs.split_at(1)
};
attrs = rest;

@mejrs mejrs Nov 23, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's not obvious to me that this handles cases like

/// doc
#[abd]
/// doc2
#[edf] 

correctly, I'd just create a vec of doc attributes and then parse those together,
like

let doc_attrs = vec![];
for attr in attrs{
    if is_doc_attr{
           doc_attrs.push(attr);
    } else {
         parse(slice::from_ref(attr))
    }
}
parse(doc_attrs)

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Changed the implementation, makes sense

@mejrs mejrs left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

r=me, up to you if you wanna investigate the perf thing

View changes since this review

Comment thread compiler/rustc_expand/src/expand.rs Outdated

// Parse all doc comments together in a group, to prevent a group of
// unused doc comments from emitting multiple lints
parse(doc_attrs.as_slice());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Parsing nothing isn't zero cost, so you might be able to undo the (small) perf regressions in #166093 (comment) with

Suggested change
parse(doc_attrs.as_slice());
if !doc_attrs.is_empty() {
parse(doc_attrs.as_slice());
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'd be surprised if that is measurable, but also yeah makes sense to check it

@JonathanBrouwer

Copy link
Copy Markdown
Member Author

@bors r=mejrs

@rust-bors

rust-bors Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 0df0070 has been tentatively approved by mejrs

It will be put into the queue for this repository once PR CI succeeds.

@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 Nov 23, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 23, 2026
…=mejrs

Undo accidental duplication checking for attributes on macro calls

one of r? @mejrs @GuillaumeGomez
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 23, 2026
…=mejrs

Undo accidental duplication checking for attributes on macro calls

one of r? @mejrs @GuillaumeGomez
rust-bors Bot pushed a commit that referenced this pull request Nov 23, 2026
…uwer

Rollup of 5 pull requests

Successful merges:

 - #164918 (Move lint validation to attribute parsing)
 - #166381 (`rust-analyzer` subtree update)
 - #166191 (Enable static-pie on all Musl targets)
 - #166250 (Add a reason suggestion for malformed lint attributes)
 - #166365 (Drop references to codebuild)

Failed merges:

 - #166374 (Undo accidental duplication checking for attributes on macro calls)
rust-bors Bot pushed a commit that referenced this pull request Nov 23, 2026
…uwer

Rollup of 6 pull requests

Successful merges:

 - #164918 (Move lint validation to attribute parsing)
 - #166381 (`rust-analyzer` subtree update)
 - #166191 (Enable static-pie on all Musl targets)
 - #166390 (Turn `gca` into a macro 2.0 that expands to `k#gca(..)`)
 - #165764 (view-types: handle field accesses)
 - #166250 (Add a reason suggestion for malformed lint attributes)

Failed merges:

 - #166374 (Undo accidental duplication checking for attributes on macro calls)
@rust-bors rust-bors Bot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Nov 23, 2026
@rust-bors

This comment has been minimized.

@rust-bors rust-bors Bot removed the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Nov 23, 2026
@rustbot

rustbot commented Nov 23, 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.

@JonathanBrouwer

Copy link
Copy Markdown
Member Author

@bors r=mejrs

@rust-bors

rust-bors Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 035ee3f has been tentatively approved by mejrs

It will be put into the queue for this repository once PR CI succeeds.

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 23, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 24, 2026
Rollup of 11 pull requests

Successful merges:

 - #165769 (Fix invalid instantiation of fake intrinsic bodies)
 - #166374 (Undo accidental duplication checking for attributes on macro calls)
 - #166386 (Replace manual `AttributeParser` construction by `parse_limited_all`)
 - #162565 (Add `c_buffer_length` lint helper)
 - #166096 (llvm-wrapper: Pass more arguments to PreCodeGenCallback)
 - #166395 (std: fix positioned read/write on VxWorks)
 - #166404 (Change `ChildExt::kill_process_group` to be `&self`)
 - #166405 (Check for errors before encoding metadata)
 - #166412 (std: Fix locking test on GNU/Hurd)
 - #166413 (std: Fix symlink chmod test on GNU/Hurd)
 - #166421 (core: Stabilize `float_bits_const`)
@rust-bors
rust-bors Bot merged commit 2bd73e8 into rust-lang:main Nov 24, 2026
14 checks passed
@rustbot rustbot added this to the 1.102.0 milestone Nov 24, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 24, 2026
Rollup merge of #166374 - JonathanBrouwer:undo-regression, r=mejrs

Undo accidental duplication checking for attributes on macro calls

one of r? @mejrs @GuillaumeGomez
@rust-timer

Copy link
Copy Markdown
Collaborator

Note

This PR was benchmarked as part of triage of its containing rollup: triage URL.

Finished benchmarking commit (359f812): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -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.3% [-0.3%, -0.2%] 9
Improvements ✅
(secondary)
-0.3% [-0.3%, -0.2%] 4
All ❌✅ (primary) -0.3% [-0.3%, -0.2%] 9

Max RSS (memory usage)

This perf run didn't have relevant results for this metric.

Cycles

This perf run didn't have relevant results for this metric.

Binary size

This perf run didn't have relevant results for this metric.

Artifact size: 406.38 MiB -> 405.72 MiB (-0.16%)

@JonathanBrouwer

JonathanBrouwer commented Nov 24, 2026 •

Copy link
Copy Markdown
Member Author

???

From looking at the changes it does seem real

@mejrs

mejrs commented Nov 24, 2026

Copy link
Copy Markdown
Member

He's beginning to believe...

I wonder how this composes with your inline pr, it would be nice if these empty checks wouldnt be necessary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

4 participants