-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #126045 - olafes:master, r=compiler-errors
check_expr_struct_fields: taint context with errors if struct definit… Taint errors while checking `struct { field: 1 }` below if struct definition has duplicated fields so that we don't pass it to const eval. fixes #125842, fixes #124464, fixes #124552 ```rust struct Struct { field: Option<u8>, field: u8, } static STATIC: Struct = Struct { field: 1, }; pub fn main() {} ``` (This was #125947 but i messed something up, sorry) r? `@compiler-errors`
- Loading branch information
Showing
6 changed files
with
68 additions
and
13 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 was deleted.
Oops, something went wrong.
6 changes: 5 additions & 1 deletion
6
tests/crashes/124464.rs → .../static/duplicated-fields-issue-124464.rs
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,22 @@ | ||
error[E0428]: the name `TestSome` is defined multiple times | ||
--> $DIR/duplicated-fields-issue-124464.rs:6:5 | ||
| | ||
LL | TestSome(T), | ||
| ----------- previous definition of the type `TestSome` here | ||
LL | TestSome(T), | ||
| ^^^^^^^^^^^ `TestSome` redefined here | ||
| | ||
= note: `TestSome` must be defined only once in the type namespace of this enum | ||
|
||
error[E0124]: field `bar` is already declared | ||
--> $DIR/duplicated-fields-issue-124464.rs:12:5 | ||
| | ||
LL | bar: TestOption<u64>, | ||
| -------------------- `bar` first declared here | ||
LL | bar: u8, | ||
| ^^^^^^^ field already declared | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0124, E0428. | ||
For more information about an error, try `rustc --explain E0124`. |
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,21 @@ | ||
// Do not try to evaluate static initalizers that reference | ||
// ill-defined types. This used to be an ICE. | ||
// See issues #125842 and #124464. | ||
struct Struct { | ||
field: Option<u8>, | ||
field: u8, | ||
//~^ ERROR field `field` is already declared | ||
} | ||
|
||
static STATIC_A: Struct = Struct { | ||
field: 1 | ||
}; | ||
|
||
static STATIC_B: Struct = { | ||
let field = 1; | ||
Struct { | ||
field, | ||
} | ||
}; | ||
|
||
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,11 @@ | ||
error[E0124]: field `field` is already declared | ||
--> $DIR/duplicated-fields-issue-125842.rs:6:5 | ||
| | ||
LL | field: Option<u8>, | ||
| ----------------- `field` first declared here | ||
LL | field: u8, | ||
| ^^^^^^^^^ field already declared | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0124`. |