Add regression test
This commit is contained in:
parent
2899b58832
commit
791e8001d1
15
src/test/ui/cast/issue-84213.fixed
Normal file
15
src/test/ui/cast/issue-84213.fixed
Normal file
@ -0,0 +1,15 @@
|
||||
// run-rustfix
|
||||
|
||||
struct Something {
|
||||
pub field: u32,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut something = Something { field: 1337 };
|
||||
|
||||
let _pointer_to_something = &something as *const Something;
|
||||
//~^ ERROR: non-primitive cast
|
||||
|
||||
let _mut_pointer_to_something = &mut something as *mut Something;
|
||||
//~^ ERROR: non-primitive cast
|
||||
}
|
15
src/test/ui/cast/issue-84213.rs
Normal file
15
src/test/ui/cast/issue-84213.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// run-rustfix
|
||||
|
||||
struct Something {
|
||||
pub field: u32,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut something = Something { field: 1337 };
|
||||
|
||||
let _pointer_to_something = something as *const Something;
|
||||
//~^ ERROR: non-primitive cast
|
||||
|
||||
let _mut_pointer_to_something = something as *mut Something;
|
||||
//~^ ERROR: non-primitive cast
|
||||
}
|
25
src/test/ui/cast/issue-84213.stderr
Normal file
25
src/test/ui/cast/issue-84213.stderr
Normal file
@ -0,0 +1,25 @@
|
||||
error[E0605]: non-primitive cast: `Something` as `*const Something`
|
||||
--> $DIR/issue-84213.rs:10:33
|
||||
|
|
||||
LL | let _pointer_to_something = something as *const Something;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid cast
|
||||
|
|
||||
help: borrow the value for the cast to be valid
|
||||
|
|
||||
LL | let _pointer_to_something = &something as *const Something;
|
||||
| ^
|
||||
|
||||
error[E0605]: non-primitive cast: `Something` as `*mut Something`
|
||||
--> $DIR/issue-84213.rs:13:37
|
||||
|
|
||||
LL | let _mut_pointer_to_something = something as *mut Something;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid cast
|
||||
|
|
||||
help: borrow the value for the cast to be valid
|
||||
|
|
||||
LL | let _mut_pointer_to_something = &mut something as *mut Something;
|
||||
| ^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0605`.
|
Loading…
Reference in New Issue
Block a user