Skip to content

ptr_arg should trigger for Option<&PathBuf> #15504

@BenjaminBrienen

Description

@BenjaminBrienen

Summary

A parameter of type Option<&PathBuf> could instead of of type Option<&Path>.

Lint Name

ptr_arg

Reproducer

I tried this code:

fn foo(maybe_path: Option<&PathBuf>) {
    if let Some(path) = maybe_path {
        File::create(path).unwrap();
    }
}

I expected to see this happen:

ptr_arg triggers

Instead, this happened:

It doesn't

Version

rustc 1.89.0 (29483883e 2025-08-04)
binary: rustc
commit-hash: 29483883eed69d5fb4db01964cdf2af4d86e9cb2
commit-date: 2025-08-04
host: x86_64-unknown-linux-gnu
release: 1.89.0
LLVM version: 20.1.7

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