Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ptr-arg warning on reference to type alias #7699

Closed
asg0451 opened this issue Sep 21, 2021 · 0 comments · Fixed by #7890
Closed

ptr-arg warning on reference to type alias #7699

asg0451 opened this issue Sep 21, 2021 · 0 comments · Fixed by #7890
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@asg0451
Copy link

asg0451 commented Sep 21, 2021

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)
@asg0451 asg0451 added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Sep 21, 2021
@bors bors closed this as completed in dbe167d Oct 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant