Skip to content

useless-transmute doesn't take lifetimes into account #5668

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ndmitchell opened this issue May 31, 2020 · 1 comment
Closed

useless-transmute doesn't take lifetimes into account #5668

ndmitchell opened this issue May 31, 2020 · 1 comment

Comments

@ndmitchell
Copy link

Given:

use std::cell::Cell;
pub struct V<'v>(Cell<&'v ()>);

pub unsafe fn downcast_v<'v>(x: V<'static>) -> V<'v> {
    std::mem::transmute(x)
}

If you enable -D clippy::useless-transmute then Clippy warns:

error: transmute from a type (`foo:V`) to itself

But it's actually V<'static> to V<'v>, so a transmute is required.

$ cargo clippy -V
clippy 0.0.212 (891e1a85 2020-04-18)
@flip1995
Copy link
Member

Duplicate of #5343

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants