Skip to content

lint against repeated repr attributes - #157036

Merged
rust-bors[bot] merged 7 commits into
rust-lang:mainfrom
ettolrach:disallow-repeated-reprs
Aug 26, 2026
Merged

lint against repeated repr attributes#157036
rust-bors[bot] merged 7 commits into
rust-lang:mainfrom
ettolrach:disallow-repeated-reprs

Conversation

@ettolrach

@ettolrach ettolrach commented May 27, 2026

Copy link
Copy Markdown
Contributor

View all comments

fixes #156029 by adding a lint against repeated repr attributes.

r? scottmcm

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) 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 May 27, 2026
@rust-log-analyzer

This comment has been minimized.

@traviscross traviscross added T-lang Relevant to the language team needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. I-lang-radar Items that are on lang's radar and will need eventual work or consideration. labels May 27, 2026
@scottmcm

Copy link
Copy Markdown
Member

Wearing my lang hat but not speaking as team consensus (since we've not talked about it):

I think you should start with the "obviously good" version, and we can do future PRs later to expand it or to update severity. Concretely, thus, I'd say it should be a warning (because if it's inert it doesn't need to be deny) when you have a clearly-unnecessary one that wasn't emitted from a macro, or something like that.

(Our bar in the compiler for deny-by-default is pretty high. My personal heuristic is whether it's worth running your unit tests despite the warning, and an inert extra attribute doesn't need to block that.)

We can then look at impacts and ratchet it up over time or over an edition, but those decisions can be made later and don't need to block you making a useful lint in the meantime.


I'm a bad reviewer for lint stuff code-wise, though, so let's try
r? JonathanBrouwer

@rustbot rustbot assigned JonathanBrouwer and unassigned scottmcm May 30, 2026
@traviscross

Copy link
Copy Markdown
Contributor

+1 to what @scottmcm said on how best to approach this.

@rust-bors

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@ettolrach
ettolrach marked this pull request as ready for review June 6, 2026 17:03
@rustbot

rustbot commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator

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

cc @jdonszelmann, @JonathanBrouwer

@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 Jun 6, 2026
@rustbot

This comment has been minimized.

@rustbot rustbot added the has-merge-commits PR has merge commits, merge with caution. label Jun 6, 2026
@ettolrach
ettolrach force-pushed the disallow-repeated-reprs branch from ae3cdee to 314903c Compare June 6, 2026 17:28
@rustbot rustbot removed the has-merge-commits PR has merge commits, merge with caution. label Jun 6, 2026
@jdonszelmann

Copy link
Copy Markdown
Contributor

r? jdonszelmann
I don't mind giving this one a look :)

@jdonszelmann

Copy link
Copy Markdown
Contributor

@ettolrach if you rebase and address what lang asked, let's go merge! :)

@ettolrach
ettolrach force-pushed the disallow-repeated-reprs branch from 224a101 to 9a370ca Compare August 24, 2026 11:58
@rustbot

rustbot commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_attr_ir

cc @jdonszelmann, @JonathanBrouwer

@rustbot

rustbot commented Aug 24, 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.

@ettolrach
ettolrach force-pushed the disallow-repeated-reprs branch from 9a370ca to a363964 Compare August 24, 2026 12:07
@ettolrach

Copy link
Copy Markdown
Contributor Author

that's the merge conflicts fixed. would appreciate a quick look at the latest two commits to make sure that i added the lint to the unused group correctly :)

@jdonszelmann

Copy link
Copy Markdown
Contributor

@ettolrach could you squash the typo commits? Not all of them, I generally like many commits in a PR to show the way its built up, but those tiny ones should probably either be part of the other commits, or all typos together in one commit if you can.

@jdonszelmann

Copy link
Copy Markdown
Contributor

formatting changes you can keep in its own commit, though it's always nicer if you keep every commit formatted. Sometimes the rebase is bad though...

@jdonszelmann

Copy link
Copy Markdown
Contributor

r=me otherwise :) ping me once you reordered some commits and I'll merge it

had to update several tests which used repeated aligns and packeds. they
now produce both a warning and an error where appropriate (e.g. when
using conflicting packeds) which i think is correct.
@ettolrach
ettolrach force-pushed the disallow-repeated-reprs branch from a363964 to e99f23f Compare August 25, 2026 14:43
@ettolrach

Copy link
Copy Markdown
Contributor Author

tests pass, that's ready to be merged now @jdonszelmann

@jdonszelmann

Copy link
Copy Markdown
Contributor

@bors r+

@rust-bors

rust-bors Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

📌 Commit e99f23f has been approved by jdonszelmann

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 Aug 25, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 26, 2026
… r=jdonszelmann

lint against repeated repr attributes

fixes rust-lang#156029 by adding a lint against repeated repr attributes.

r? scottmcm
rust-bors Bot pushed a commit that referenced this pull request Aug 26, 2026
…uwer

Rollup of 7 pull requests

Successful merges:

 - #157036 (lint against repeated repr attributes)
 - #160183 (panic_unwind: Use global_asm! for IMGREL relocations)
 - #161718 (Fix the wasm32-unknown-unknown target feature/cfg bug)
 - #161673 (Fix broken link to lang_items.rs in unstable book)
 - #161744 (Remove `RawDefPathHash`)
 - #161747 (explicitly state that allocations cannot grow to the left)
 - #161796 (Remove dead parse error recovery (underscores in expressions))
@rust-bors
rust-bors Bot merged commit 0230abe into rust-lang:main Aug 26, 2026
13 checks passed
rust-bors Bot pushed a commit that referenced this pull request Aug 26, 2026
Rollup merge of #157036 - ettolrach:disallow-repeated-reprs, r=jdonszelmann

lint against repeated repr attributes

fixes #156029 by adding a lint against repeated repr attributes.

r? scottmcm
@rustbot rustbot added this to the 1.100.0 milestone Aug 26, 2026
@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 (39d59b8): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

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

Max RSS (memory usage)

Results (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)
- - 0
Regressions ❌
(secondary)
2.2% [2.2%, 2.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

Results (primary 0.6%, secondary 2.8%)

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

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

Binary size

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

Bootstrap: 475.812s -> 480.439s (0.97%)
Artifact size: 403.37 MiB -> 402.66 MiB (-0.18%)

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

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. I-lang-radar Items that are on lang's radar and will need eventual work or consideration. 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-lang Relevant to the language team to-announce Announce this issue on triage meeting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

#[repr()] attribute has inconsistent handling of duplicates.

10 participants