Use span of impl/trait in len_without_is_empty error message, rather …#1559
Merged
oli-obk merged 3 commits intorust-lang:masterfrom Feb 21, 2017
Merged
Use span of impl/trait in len_without_is_empty error message, rather …#1559oli-obk merged 3 commits intorust-lang:masterfrom
oli-obk merged 3 commits intorust-lang:masterfrom
Conversation
…than the span of the len method
mcarton
suggested changes
Feb 19, 2017
| 12 | | } | ||
| | |_____^ ...ending here | ||
| 13 | | } | ||
| | |_^ ...ending here |
Contributor
There was a problem hiding this comment.
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?
Contributor
Author
There was a problem hiding this comment.
Good point. The current lint has a false positive if len and is_empty are defined in separate impl blocks.
Contributor
Author
There was a problem hiding this comment.
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
allowattribution 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?
Contributor
There was a problem hiding this comment.
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@
Contributor
|
thanks! |
bors
added a commit
that referenced
this pull request
Mar 7, 2021
`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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…than the span of the len method. (Fixes https://github.com/Manishearth/rust-clippy/issues/1532)