-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #121270 - clubby789:more-unnamed-fields-checks, r=<try>
Check for accessing unnamed field in `find_field` Fixes #121263 I'm not entirely sure this is the right solution, but it seems to work 😓
- Loading branch information
Showing
8 changed files
with
149 additions
and
37 deletions.
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
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
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
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,29 @@ | ||
#![allow(incomplete_features)] | ||
#![feature(unnamed_fields)] | ||
|
||
#[derive(Clone, Copy, Debug)] | ||
#[repr(C)] | ||
struct Foo { | ||
a: u8, | ||
} | ||
|
||
#[repr(C)] | ||
#[derive(Debug)] //~ ERROR only `Copy` and `Clone` may be derived on structs with unnamed fields | ||
struct TestUnsupported { | ||
_: Foo, | ||
} | ||
|
||
#[repr(C)] | ||
#[derive(Clone, Copy)] | ||
struct Test { | ||
_: Foo, | ||
} | ||
|
||
#[repr(C)] | ||
#[derive(Clone)] //~ ERROR deriving `Clone` on a type with unnamed fields requires also deriving `Copy` | ||
struct TestClone { | ||
_: Foo, | ||
} | ||
|
||
|
||
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,23 @@ | ||
error: only `Copy` and `Clone` may be derived on structs with unnamed fields | ||
--> $DIR/derive.rs:11:10 | ||
| | ||
LL | #[derive(Debug)] | ||
| ^^^^^ | ||
| | ||
note: unnamed field | ||
--> $DIR/derive.rs:13:5 | ||
| | ||
LL | _: Foo, | ||
| ^^^^^^ | ||
= note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: deriving `Clone` on a type with unnamed fields requires also deriving `Copy` | ||
--> $DIR/derive.rs:23:10 | ||
| | ||
LL | #[derive(Clone)] | ||
| ^^^^^ | ||
| | ||
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: aborting due to 2 previous errors | ||
|