summaryrefslogtreecommitdiffstats
path: root/tests/ui/lint/lint-strict-provenance-lossy-casts.stderr
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
commit218caa410aa38c29984be31a5229b9fa717560ee (patch)
treec54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/ui/lint/lint-strict-provenance-lossy-casts.stderr
parentReleasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz
rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/lint/lint-strict-provenance-lossy-casts.stderr')
-rw-r--r--tests/ui/lint/lint-strict-provenance-lossy-casts.stderr51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/ui/lint/lint-strict-provenance-lossy-casts.stderr b/tests/ui/lint/lint-strict-provenance-lossy-casts.stderr
new file mode 100644
index 000000000..aa151fe2d
--- /dev/null
+++ b/tests/ui/lint/lint-strict-provenance-lossy-casts.stderr
@@ -0,0 +1,51 @@
+error: under strict provenance it is considered bad style to cast pointer `*const u8` to integer `usize`
+ --> $DIR/lint-strict-provenance-lossy-casts.rs:6:23
+ |
+LL | let addr: usize = &x as *const u8 as usize;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = help: if you can't comply with strict provenance and need to expose the pointer provenance you can use `.expose_addr()` instead
+note: the lint level is defined here
+ --> $DIR/lint-strict-provenance-lossy-casts.rs:2:9
+ |
+LL | #![deny(lossy_provenance_casts)]
+ | ^^^^^^^^^^^^^^^^^^^^^^
+help: use `.addr()` to obtain the address of a pointer
+ |
+LL | let addr: usize = (&x as *const u8).addr();
+ | + ~~~~~~~~
+
+error: under strict provenance it is considered bad style to cast pointer `*const u8` to integer `u32`
+ --> $DIR/lint-strict-provenance-lossy-casts.rs:9:22
+ |
+LL | let addr_32bit = &x as *const u8 as u32;
+ | ^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = help: if you can't comply with strict provenance and need to expose the pointer provenance you can use `.expose_addr()` instead
+help: use `.addr()` to obtain the address of a pointer
+ |
+LL | let addr_32bit = (&x as *const u8).addr() as u32;
+ | + ~~~~~~~~~~~~~~~
+
+error: under strict provenance it is considered bad style to cast pointer `*const u8` to integer `usize`
+ --> $DIR/lint-strict-provenance-lossy-casts.rs:14:20
+ |
+LL | let ptr_addr = ptr as usize;
+ | ^^^---------
+ | |
+ | help: use `.addr()` to obtain the address of a pointer: `.addr()`
+ |
+ = help: if you can't comply with strict provenance and need to expose the pointer provenance you can use `.expose_addr()` instead
+
+error: under strict provenance it is considered bad style to cast pointer `*const u8` to integer `u32`
+ --> $DIR/lint-strict-provenance-lossy-casts.rs:16:26
+ |
+LL | let ptr_addr_32bit = ptr as u32;
+ | ^^^-------
+ | |
+ | help: use `.addr()` to obtain the address of a pointer: `.addr() as u32`
+ |
+ = help: if you can't comply with strict provenance and need to expose the pointer provenance you can use `.expose_addr()` instead
+
+error: aborting due to 4 previous errors
+