-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesL-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestions
Description
clippy 0.0.212 (b1d0343 2018-10-19)
fn main() {}
type SomeType = Vec<String>;
pub fn do_not_eat(a: &SomeType) -> SomeType {
for i in a {
println!("{}", i);
}
a.to_vec()
}
clippy warns
warning: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices.
--> src/main.rs:5:22
|
5 | pub fn do_not_eat(a: &SomeType) -> SomeType {
| ^^^^^^^^^
|
= note: #[warn(clippy::ptr_arg)] on by default
but I think the message looks like a false positive if we don't see (as in this example) that the type SomeType
is actually just a Vec<_>
in disguise.
Can we perhaps print some detail on what the actual type is in case of newtypes to make this slightly more clear?
I found similar code in rls where syntax::ast::GenericBounds
is actually just type GenericBounds = Vec<GenericBound>;
iago-lito, arnauorriols, cjhopman and kgrech
Metadata
Metadata
Assignees
Labels
C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesL-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestions