Skip to content

(Possibly) confusing message in ptr_arg #6964

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

Closed
ChrisJefferson opened this issue Mar 24, 2021 · 1 comment · Fixed by #8271
Closed

(Possibly) confusing message in ptr_arg #6964

ChrisJefferson opened this issue Mar 24, 2021 · 1 comment · Fixed by #8271
Labels
good first issue These issues are a good way to get started with Clippy L-suggestion Lint: Improving, adding or fixing lint suggestions

Comments

@ChrisJefferson
Copy link

ptr_arg prints the message:

warning: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices

I was confused for a while about the "one more reference", as switching does not seem to remove any references.

After some thought, is this referring to the internal implementation of Vec requiring another indirection? In that case, perhaps replace "involves one more reference" with "may produce slower code", or something like that?

@llogiq
Copy link
Contributor

llogiq commented Mar 24, 2021

Let me make that visible by showing a pointer as o->.

&Vec<T>: o->[len, capacity, o]->[T0, T1, ...]

&[T]: [len, o]->[T0, T1, ...]

@camsteffen camsteffen added good first issue These issues are a good way to get started with Clippy L-suggestion Lint: Improving, adding or fixing lint suggestions labels May 3, 2021
@bors bors closed this as completed in 4992548 Jan 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue These issues are a good way to get started with Clippy L-suggestion Lint: Improving, adding or fixing lint suggestions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants