Skip to content

Useless transmute lint throws false positive when transmuting lifetimes #6899

Closed
@ghost

Description

This code triggers a false positive for the "useless transmute" lint:

struct Example<'a> {
    phdata: core::marker::PhantomData<&'a ()>
}

fn useless_transmute_false_positive<'a, 'b>(ex: Example<'a>) -> Example<'b> where 'a: 'b {
    unsafe {
        core::mem::transmute(ex)
    }
}

This should not be considered useless because it changes information about the type, but for some reason the type is considered the same by clippy as shown in this message: transmute from a type (Example) to itself

Meta

Clippy Version: 0.1.52

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.I-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions