Skip to content

ptr-arg warning on reference to type alias #7699

@asg0451

Description

@asg0451

Lint name: ptr_arg

I have a type alias somewhere:

type DocumentMap = Vec<Vec<Something>>;

and I have a function that takes a refence to one:

fn foo(map: &DocumentMap) { .. }

Clippy, run with -Dwarnings, returns this suggestion:

error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices
   --> etc
    |
193 |     map: &DocumentMap,
    |                   ^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg

I think this suggestion is bad -- I want to keep this type alias. I have to pepper each function that receives such an arg with #[allow(clippy::ptr_arg)] and a comment explaining why.

Meta

Rust version (rustc -Vv):

rustc 1.55.0 (c8dfcfe04 2021-09-06)
binary: rustc
commit-hash: c8dfcfe046a7680554bf4eb612bad840e7631c4b
commit-date: 2021-09-06
host: x86_64-unknown-linux-gnu
release: 1.55.0
LLVM version: 12.0.1

clippy version:

clippy 0.1.55 (c8dfcfe 2021-09-06)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-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