Skip to content

allow repeated repr attributes#156856

Open
ettolrach wants to merge 1 commit into
rust-lang:mainfrom
ettolrach:allow-repeated-reprs
Open

allow repeated repr attributes#156856
ettolrach wants to merge 1 commit into
rust-lang:mainfrom
ettolrach:allow-repeated-reprs

Conversation

@ettolrach
Copy link
Copy Markdown

@ettolrach ettolrach commented May 23, 2026

In principle, fixes #156029. That issue does mention the "inconsistency" of multiple "C" reprs mixed with a single integer repr being accepted, while multiple "Rust" reprs mixed with a single integer repr aren't. I do believe this is intentional, since the Rust repr cannot be mixed with integer reprs.

Also, I'm not sure whether the current behaviour regarding multiple align reprs should be changed. While it's inconsistent that multiple, mixed aligns are accepted (and the largest is used), multiple packed repr aren't allowed. I don't want to change this since it's making the compiler less permissive, not more, like the rest of my changes.

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 23, 2026

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

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 May 23, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 23, 2026

r? @mejrs

rustbot has assigned @mejrs.
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 17 candidates

@qaijuang
Copy link
Copy Markdown
Contributor

Thanks for the contribution! Would you mind adding tests? You can use the relevant repro examples from the issue as the basis for the tests.

See: https://rustc-dev-guide.rust-lang.org/tests/intro.html

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

4 participants