- Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
I-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied
Description
Using the following flags
--force-warn clippy::missing_transmute_annotations
this code:
#![allow(invalid_value)] fn main() { trait T {} #[derive(Debug)] struct S { #[allow(dead_code)] x: *mut dyn T, } dbg!(S { x: unsafe { std::mem::transmute((0usize, 0usize)) } }); //~ ERROR: encountered null pointer, but expected a vtable pointer }
caused the following diagnostics:
Checking _invalid_wide_raw v0.1.0 (/tmp/icemaker_global_tempdir.paNtiJF6jVLU/icemaker_clippyfix_tempdir.dAxmJfUWB4oA/_invalid_wide_raw) warning: transmute used without annotations --> src/main.rs:10:36 | 10 | dbg!(S { x: unsafe { std::mem::transmute((0usize, 0usize)) } }); //~ ERROR: encountered null pointer, but expected a vtable pointer | ^^^^^^^^^ help: consider adding missing annotations: `transmute::<(usize, usize), *mut dyn main::T>` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_transmute_annotations = note: requested on the command line with `--force-warn clippy::missing-transmute-annotations` warning: `_invalid_wide_raw` (bin "_invalid_wide_raw") generated 1 warning Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.28s
However after applying these diagnostics, the resulting code:
#![allow(invalid_value)] fn main() { trait T {} #[derive(Debug)] struct S { #[allow(dead_code)] x: *mut dyn T, } dbg!(S { x: unsafe { std::mem::transmute::<(usize, usize), *mut dyn main::T>((0usize, 0usize)) } }); //~ ERROR: encountered null pointer, but expected a vtable pointer }
no longer compiled:
Checking _invalid_wide_raw v0.1.0 (/tmp/icemaker_global_tempdir.paNtiJF6jVLU/icemaker_clippyfix_tempdir.dAxmJfUWB4oA/_invalid_wide_raw) error[E0433]: failed to resolve: function `main` is not a crate or module --> src/main.rs:10:73 | 10 | dbg!(S { x: unsafe { std::mem::transmute::<(usize, usize), *mut dyn main::T>((0usize, 0usize)) } }); //~ ERROR: encountered null poin... | ^^^^ function `main` is not a crate or module For more information about this error, try `rustc --explain E0433`. error: could not compile `_invalid_wide_raw` (bin "_invalid_wide_raw" test) due to 1 previous error warning: build failed, waiting for other jobs to finish... error: could not compile `_invalid_wide_raw` (bin "_invalid_wide_raw") due to 1 previous error
Version:
rustc 1.92.0-nightly (4a54b26d3 2025-10-07) binary: rustc commit-hash: 4a54b26d30dac43778afb0e503524b763fce0eee commit-date: 2025-10-07 host: x86_64-unknown-linux-gnu release: 1.92.0-nightly LLVM version: 21.1.2
Metadata
Metadata
Assignees
Labels
I-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied