-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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: clarify about original type when newtype is just a Vec<_> #3381
Comments
I thought this might be a false positive but what the lint is trying to tell you here is that for the sake of your interface you don't need to be as specific as e.g. this code avoids the lint.
AFAICT this issue should be closed. The type alias is not important here. I will concede that when I saw this lint message, I was a little confused. I also had a type alias like in this example, but that didn't confuse me quite as much as "...involves one more reference...". It wasn't immediately obvious that the fix was to specify a slice here. |
Defining another type just for function arguments seems a little bit off IMO. For type definitions like
A hint how to fix this warning is always nice. Clippy only wants to annoy users, but doesn't want to confuse them! As a site note: struct SomeType(Vec<String>);
impl Deref for SomeType {
type Target = Vec<String>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl SomeType {
pub fn do_not_eat(&self) -> Self {
// ...
}
} |
Maybe we could also move the user-defined type part of this lint into a pedantic lint? |
This also applies to This pattern seems valuable to me when things are represented as Strings, but are not equivalent at all (like different types of id's) |
clippy 0.0.212 (b1d0343 2018-10-19)
clippy warns
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 aVec<_>
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 justtype GenericBounds = Vec<GenericBound>;
The text was updated successfully, but these errors were encountered: