Skip to content

not_unsafe_ptr_arg_deref false positives #3045

Open
@gnzlbg

Description

@gnzlbg

Playground:

pub struct X2<T>(T, T);

impl<T> X2<*mut T> {
    pub fn foo(self, a: *mut T) -> Self {
        unsafe { self.bar(a) }
    }
    
    pub unsafe fn bar(self, _a: *mut T) -> Self {
        self
    }
}
fn main() {}

produces

error: this public function dereferences a raw pointer but is not marked `unsafe`
 --> src/main.rs:5:27
  |
5 |         unsafe { self.bar(a) }
  |                           ^
  |
  = note: #[deny(not_unsafe_ptr_arg_deref)] on by default
  = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#not_unsafe_ptr_arg_deref

which is incorrect since no raw pointer is ever dereferenced anywhere.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions