Skip to content

not_unsafe_ptr_arg_deref does not trigger on type aliases and trait methods #8092

@SeeSpring

Description

@SeeSpring

Summary

If the raw pointer is used behind a type alias or the function is part of a trait, not_unsafe_ptr_arg_deref is not triggered.

Lint Name

not_unsafe_ptr_arg_deref

Reproducer

I tried this code:

trait Bad {
    fn f(x: *const u8) -> u8 {
        unsafe { *x }
    }
}

type Alias = *const u8;
pub fn bad(x: Alias) -> u8 {
    unsafe { *x }
}

pub fn main() {
    bad(0 as _);
}

Playground

I expected to see this happen: Lint for not_unsafe_ptr_arg_deref is triggered

Instead, this happened: Lint is not triggered

Version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn't

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions