|
| 1 | +error: creating a intermediate reference implies aliasing requirements even when immediately casting to raw pointers |
| 2 | + --> $DIR/lint-unnecessary-refs.rs:9:14 |
| 3 | + | |
| 4 | +LL | unsafe { &(*x).0 as *const i32 } |
| 5 | + | ^^^^^^^^^^^^^^^^^^^^^ |
| 6 | + | |
| 7 | +note: the lint level is defined here |
| 8 | + --> $DIR/lint-unnecessary-refs.rs:1:9 |
| 9 | + | |
| 10 | +LL | #![deny(unnecessary_refs)] |
| 11 | + | ^^^^^^^^^^^^^^^^ |
| 12 | +help: consider using `&raw const` for a safer and more explicit raw pointer |
| 13 | + | |
| 14 | +LL - unsafe { &(*x).0 as *const i32 } |
| 15 | +LL + unsafe { &raw const (*x).0 } |
| 16 | + | |
| 17 | + |
| 18 | +error: creating a intermediate reference implies aliasing requirements even when immediately casting to raw pointers |
| 19 | + --> $DIR/lint-unnecessary-refs.rs:14:14 |
| 20 | + | |
| 21 | +LL | unsafe { &(*x).b as *const u8 } |
| 22 | + | ^^^^^^^^^^^^^^^^^^^^ |
| 23 | + | |
| 24 | +help: consider using `&raw const` for a safer and more explicit raw pointer |
| 25 | + | |
| 26 | +LL - unsafe { &(*x).b as *const u8 } |
| 27 | +LL + unsafe { &raw const (*x).b } |
| 28 | + | |
| 29 | + |
| 30 | +error: creating a intermediate reference implies aliasing requirements even when immediately casting to raw pointers |
| 31 | + --> $DIR/lint-unnecessary-refs.rs:19:14 |
| 32 | + | |
| 33 | +LL | unsafe { &mut (*x).0 as *mut i32 } |
| 34 | + | ^^^^^^^^^^^^^^^^^^^^^^^ |
| 35 | + | |
| 36 | +help: consider using `&raw const` for a safer and more explicit raw pointer |
| 37 | + | |
| 38 | +LL - unsafe { &mut (*x).0 as *mut i32 } |
| 39 | +LL + unsafe { &raw mut (*x).0 } |
| 40 | + | |
| 41 | + |
| 42 | +error: creating a intermediate reference implies aliasing requirements even when immediately casting to raw pointers |
| 43 | + --> $DIR/lint-unnecessary-refs.rs:24:14 |
| 44 | + | |
| 45 | +LL | unsafe { &mut (*x).a as *mut i32 } |
| 46 | + | ^^^^^^^^^^^^^^^^^^^^^^^ |
| 47 | + | |
| 48 | +help: consider using `&raw const` for a safer and more explicit raw pointer |
| 49 | + | |
| 50 | +LL - unsafe { &mut (*x).a as *mut i32 } |
| 51 | +LL + unsafe { &raw mut (*x).a } |
| 52 | + | |
| 53 | + |
| 54 | +error: aborting due to 4 previous errors |
| 55 | + |
0 commit comments