-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make #[repr(Rust)]
incompatible with other (non-modifier) representation hints like C
and simd
#116829
Merged
Merged
Make #[repr(Rust)]
incompatible with other (non-modifier) representation hints like C
and simd
#116829
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -558,9 +558,16 @@ pub struct ReprIdent { | |
pub span: Span, | ||
} | ||
|
||
#[derive(Diagnostic)] | ||
#[diag(passes_repr_conflicting, code = "E0566")] | ||
pub struct ReprConflicting { | ||
#[primary_span] | ||
pub hint_spans: Vec<Span>, | ||
} | ||
|
||
#[derive(LintDiagnostic)] | ||
#[diag(passes_repr_conflicting, code = "E0566")] | ||
pub struct ReprConflicting; | ||
pub struct ReprConflictingLint; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you're interested in a follow-up, it's probably time to bump this lint up to a hard-error 😸 |
||
|
||
#[derive(Diagnostic)] | ||
#[diag(passes_used_static)] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#[repr(C, Rust)] //~ ERROR conflicting representation hints | ||
struct S { | ||
a: i32, | ||
} | ||
|
||
|
||
#[repr(Rust)] //~ ERROR conflicting representation hints | ||
#[repr(C)] | ||
struct T { | ||
a: i32, | ||
} | ||
|
||
#[repr(Rust, u64)] //~ ERROR conflicting representation hints | ||
enum U { | ||
V, | ||
} | ||
|
||
#[repr(Rust, simd)] | ||
//~^ ERROR conflicting representation hints | ||
//~| ERROR SIMD types are experimental and possibly buggy | ||
struct F32x4(f32, f32, f32, f32); | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
error[E0658]: SIMD types are experimental and possibly buggy | ||
--> $DIR/explicit-rust-repr-conflicts.rs:18:1 | ||
| | ||
LL | #[repr(Rust, simd)] | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #27731 <https://github.com/rust-lang/rust/issues/27731> for more information | ||
= help: add `#![feature(repr_simd)]` to the crate attributes to enable | ||
|
||
error[E0566]: conflicting representation hints | ||
--> $DIR/explicit-rust-repr-conflicts.rs:1:8 | ||
| | ||
LL | #[repr(C, Rust)] | ||
| ^ ^^^^ | ||
|
||
error[E0566]: conflicting representation hints | ||
--> $DIR/explicit-rust-repr-conflicts.rs:7:8 | ||
| | ||
LL | #[repr(Rust)] | ||
| ^^^^ | ||
LL | #[repr(C)] | ||
| ^ | ||
|
||
error[E0566]: conflicting representation hints | ||
--> $DIR/explicit-rust-repr-conflicts.rs:13:8 | ||
| | ||
LL | #[repr(Rust, u64)] | ||
| ^^^^ ^^^ | ||
|
||
error[E0566]: conflicting representation hints | ||
--> $DIR/explicit-rust-repr-conflicts.rs:18:8 | ||
| | ||
LL | #[repr(Rust, simd)] | ||
| ^^^^ ^^^^ | ||
|
||
error: aborting due to 5 previous errors | ||
|
||
Some errors have detailed explanations: E0566, E0658. | ||
For more information about an error, try `rustc --explain E0566`. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could also turn the bools into a bitfield and check if the difference between the set bitflags and {Rust, align, packed} is empty to address “but not necessarily limited to” part of
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think refactoring this function would be a lot of good, as the current code seems to be error-prone and confusing. But obv this refactoring can come as a follow-up, which does not need a backport. (cc me if you'll do it please)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the things that would be nice is to default to disallowing, so that no changes can accidentally allow new combinations.