@@ -2,22 +2,50 @@ error: under strict provenance it is considered bad style to cast pointer `*cons
22 --> $DIR/lint-strict-provenance-lossy-casts.rs:6:23
33 |
44LL | let addr: usize = &x as *const u8 as usize;
5- | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.addr()` to obtain the address of a pointer: `(&x as *const u8).addr()`
5+ | ^^^^^^^^^^^^^^^^^^^^^^^^
66 |
77note: the lint level is defined here
88 --> $DIR/lint-strict-provenance-lossy-casts.rs:2:9
99 |
1010LL | #![deny(lossy_provenance_casts)]
1111 | ^^^^^^^^^^^^^^^^^^^^^^
1212 = help: if you can't comply with strict provenance and need to expose the pointer provenance you can use `.expose_addr()` instead
13+ help: use `.addr()` to obtain the address of a pointer
14+ |
15+ LL | let addr: usize = (&x as *const u8).addr();
16+ | + ~~~~~~~~
1317
1418error: under strict provenance it is considered bad style to cast pointer `*const u8` to integer `u32`
1519 --> $DIR/lint-strict-provenance-lossy-casts.rs:9:22
1620 |
1721LL | let addr_32bit = &x as *const u8 as u32;
18- | ^^^^^^^^^^^^^^^^^^^^^^ help: use `.addr()` to obtain the address of a pointer: `(&x as *const u8).addr() as u32`
22+ | ^^^^^^^^^^^^^^^^^^^^^^
23+ |
24+ = help: if you can't comply with strict provenance and need to expose the pointer provenance you can use `.expose_addr()` instead
25+ help: use `.addr()` to obtain the address of a pointer
26+ |
27+ LL | let addr_32bit = (&x as *const u8).addr() as u32;
28+ | + ~~~~~~~~~~~~~~~
29+
30+ error: under strict provenance it is considered bad style to cast pointer `*const u8` to integer `usize`
31+ --> $DIR/lint-strict-provenance-lossy-casts.rs:14:20
32+ |
33+ LL | let ptr_addr = ptr as usize;
34+ | ^^^---------
35+ | |
36+ | help: use `.addr()` to obtain the address of a pointer: `.addr()`
37+ |
38+ = help: if you can't comply with strict provenance and need to expose the pointer provenance you can use `.expose_addr()` instead
39+
40+ error: under strict provenance it is considered bad style to cast pointer `*const u8` to integer `u32`
41+ --> $DIR/lint-strict-provenance-lossy-casts.rs:16:26
42+ |
43+ LL | let ptr_addr_32bit = ptr as u32;
44+ | ^^^-------
45+ | |
46+ | help: use `.addr()` to obtain the address of a pointer: `.addr() as u32`
1947 |
2048 = help: if you can't comply with strict provenance and need to expose the pointer provenance you can use `.expose_addr()` instead
2149
22- error: aborting due to 2 previous errors
50+ error: aborting due to 4 previous errors
2351
0 commit comments