-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Use span of impl/trait in len_without_is_empty error message, rather … #1559
Conversation
…than the span of the len method
11 | | 1 | ||
12 | | } | ||
| |_____^ ...ending here | ||
13 | | } | ||
| |_^ ...ending here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes me wonder what happens when there is more than one impl
for a type.
Can you also had a test that checks that this actually fixes #1532?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. The current lint has a false positive if len
and is_empty
are defined in separate impl blocks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've pushed a change which:
- adds an extra, irrelevant impl block to PubOne to check that we this doesn't generate any errors
- adds a PubAllowed struct equivalent to PubOne but with an
allow
attribution on the relevant impl.
Are you happy to merge this as is, or do you want to wait for a fix to the impls-in-different-blocks issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you happy to merge this as is, or do you want to wait for a fix to the impls-in-different-blocks issue?
That's a different issue. I reported it as #1562
…ences len_without_is_empty. Add extra impl block to PubOne to check that this doesn't get flagged@
thanks! |
`len_without_is_empty` will now consider multiple impl blocks fixes #1562 This also reverts #1559 as the `#[allow]` now works on the `len` method. A note has also been added to point out where the `empty` method is, if it exists. changelog: `len_without_is_empty` will now consider multiple impl blocks changelog: `len_without_is_empty` will now consider `#[allow]` on both the `len` method, and the type definition
…than the span of the len method. (Fixes https://github.com/Manishearth/rust-clippy/issues/1532)