Skip to content

missing_transmute_annotations suggests impl Future which is not allowed #14984

Open
@matthiaskrgr

Description

@matthiaskrgr

Using the following flags

--force-warn clippy::missing_transmute_annotations

this code:

async fn empty() {}

async fn meow(a: [u8; 100]) {
	empty().await;
	dbg!(a);
}

fn main() {
	let v = meow([0; 100]);
	let e = [0u8; 202];
	let _ = || unsafe {
		use std::{mem, ptr};
		let mut copy = ptr::read(&v);
		ptr::write(&mut copy, mem::transmute(ptr::read(&e)));
		mem::forget(copy);
	};
}

caused the following diagnostics:

    Checking _110151 v0.1.0 (/tmp/icemaker_global_tempdir.t8dYaH8PqaqW/icemaker_clippyfix_tempdir.QCq7tmv8PvKz/_110151)
warning: transmute used without annotations
  --> src/main.rs:14:30
   |
14 |         ptr::write(&mut copy, mem::transmute(ptr::read(&e)));
   |                                    ^^^^^^^^^ help: consider adding missing annotations: `transmute::<[u8; 202], impl std::future::Future<Output = ()>>`
   |
   = 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: `_110151` (bin "_110151") generated 1 warning
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.14s

However after applying these diagnostics, the resulting code:

async fn empty() {}

async fn meow(a: [u8; 100]) {
	empty().await;
	dbg!(a);
}

fn main() {
	let v = meow([0; 100]);
	let e = [0u8; 202];
	let _ = || unsafe {
		use std::{mem, ptr};
		let mut copy = ptr::read(&v);
		ptr::write(&mut copy, mem::transmute::<[u8; 202], impl std::future::Future<Output = ()>>(ptr::read(&e)));
		mem::forget(copy);
	};
}

no longer compiled:

    Checking _110151 v0.1.0 (/tmp/icemaker_global_tempdir.t8dYaH8PqaqW/icemaker_clippyfix_tempdir.QCq7tmv8PvKz/_110151)
error[E0562]: `impl Trait` is not allowed in paths
  --> src/main.rs:14:53
   |
14 |         ptr::write(&mut copy, mem::transmute::<[u8; 202], impl std::future::Future<Output = ()>>(ptr::read(&e)));
   |                                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `impl Trait` is only allowed in arguments and return types of functions and methods

For more information about this error, try `rustc --explain E0562`.
error: could not compile `_110151` (bin "_110151") due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `_110151` (bin "_110151" test) due to 1 previous error

Version:

rustc 1.89.0-nightly (076ec59ff 2025-06-05)
binary: rustc
commit-hash: 076ec59ff1dcf538b9d3a0b8e0d7f4edd0559959
commit-date: 2025-06-05
host: x86_64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.5

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedT-async-awaitType: Issues related to async/await

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions