]>
Commit | Line | Data |
---|---|---|
04454e1e FG |
1 | #![feature(strict_provenance)] |
2 | #![deny(lossy_provenance_casts)] | |
3 | ||
4 | fn main() { | |
5 | let x: u8 = 37; | |
6 | let addr: usize = &x as *const u8 as usize; | |
7 | //~^ ERROR under strict provenance it is considered bad style to cast pointer `*const u8` to integer `usize` | |
8 | ||
9 | let addr_32bit = &x as *const u8 as u32; | |
10 | //~^ ERROR under strict provenance it is considered bad style to cast pointer `*const u8` to integer `u32` | |
11 | ||
12 | // don't add unnecessary parens in the suggestion | |
13 | let ptr = &x as *const u8; | |
14 | let ptr_addr = ptr as usize; | |
15 | //~^ ERROR under strict provenance it is considered bad style to cast pointer `*const u8` to integer `usize` | |
16 | let ptr_addr_32bit = ptr as u32; | |
17 | //~^ ERROR under strict provenance it is considered bad style to cast pointer `*const u8` to integer `u32` | |
18 | } |