use find_ancestor_inside to get right span in CastCheck
This commit is contained in:
parent
18f32b73bd
commit
d2b1bb8a9b
3 changed files with 42 additions and 18 deletions
12
src/test/ui/cast/cast-macro-lhs.rs
Normal file
12
src/test/ui/cast/cast-macro-lhs.rs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// Test to make sure we suggest "consider casting" on the right span
|
||||
|
||||
macro_rules! foo {
|
||||
() => { 0 }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = foo!() as *const [u8];
|
||||
//~^ ERROR cannot cast `usize` to a pointer that is wide
|
||||
//~| NOTE creating a `*const [u8]` requires both an address and a length
|
||||
//~| NOTE consider casting this expression to `*const ()`, then using `core::ptr::from_raw_parts`
|
||||
}
|
||||
11
src/test/ui/cast/cast-macro-lhs.stderr
Normal file
11
src/test/ui/cast/cast-macro-lhs.stderr
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
error[E0606]: cannot cast `usize` to a pointer that is wide
|
||||
--> $DIR/cast-macro-lhs.rs:8:23
|
||||
|
|
||||
LL | let x = foo!() as *const [u8];
|
||||
| ------ ^^^^^^^^^^^ creating a `*const [u8]` requires both an address and a length
|
||||
| |
|
||||
| consider casting this expression to `*const ()`, then using `core::ptr::from_raw_parts`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0606`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue