-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 #83054 - tmiasko:rustc_layout_scalar_valid_range, r=d…
…avidtwco Validate rustc_layout_scalar_valid_range_{start,end} attributes Fixes #82251, fixes #82981.
- Loading branch information
Showing
4 changed files
with
91 additions
and
1 deletion.
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
23 changes: 23 additions & 0 deletions
23
src/test/ui/invalid/invalid_rustc_layout_scalar_valid_range.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#![feature(rustc_attrs)] | ||
|
||
#[rustc_layout_scalar_valid_range_start(u32::MAX)] //~ ERROR | ||
pub struct A(u32); | ||
|
||
#[rustc_layout_scalar_valid_range_end(1, 2)] //~ ERROR | ||
pub struct B(u8); | ||
|
||
#[rustc_layout_scalar_valid_range_end(a = "a")] //~ ERROR | ||
pub struct C(i32); | ||
|
||
#[rustc_layout_scalar_valid_range_end(1)] //~ ERROR | ||
enum E { | ||
X = 1, | ||
Y = 14, | ||
} | ||
|
||
fn main() { | ||
let _ = A(0); | ||
let _ = B(0); | ||
let _ = C(0); | ||
let _ = E::X; | ||
} |
31 changes: 31 additions & 0 deletions
31
src/test/ui/invalid/invalid_rustc_layout_scalar_valid_range.stderr
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,31 @@ | ||
error: expected exactly one integer literal argument | ||
--> $DIR/invalid_rustc_layout_scalar_valid_range.rs:3:1 | ||
| | ||
LL | #[rustc_layout_scalar_valid_range_start(u32::MAX)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: expected exactly one integer literal argument | ||
--> $DIR/invalid_rustc_layout_scalar_valid_range.rs:6:1 | ||
| | ||
LL | #[rustc_layout_scalar_valid_range_end(1, 2)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: expected exactly one integer literal argument | ||
--> $DIR/invalid_rustc_layout_scalar_valid_range.rs:9:1 | ||
| | ||
LL | #[rustc_layout_scalar_valid_range_end(a = "a")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: attribute should be applied to a struct | ||
--> $DIR/invalid_rustc_layout_scalar_valid_range.rs:12:1 | ||
| | ||
LL | #[rustc_layout_scalar_valid_range_end(1)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | / enum E { | ||
LL | | X = 1, | ||
LL | | Y = 14, | ||
LL | | } | ||
| |_- not a struct | ||
|
||
error: aborting due to 4 previous errors | ||
|