-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Add more impls of PartialEq and PartialOrd for strings #135536
Open
joshtriplett
wants to merge
4
commits into
rust-lang:master
Choose a base branch
from
joshtriplett:str-impls
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+128
−51
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ea79b3c
Add more impls of PartialEq and PartialOrd for strings
joshtriplett b6ac0dc
clippy: In cmp_owned, don't use Deref via `*` if non-Deref impl exists
joshtriplett 96492ea
clippy: uibless new test output
joshtriplett 5f3c8ef
Add PartialEq and PartialOrd impls for comparing `String` and `&String`
joshtriplett File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,17 @@ LL | let _: usize = vec.iter().filter(|x| x == &"2").cloned().count(); | |
= note: `-D clippy::redundant-clone` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::redundant_clone)]` | ||
|
||
error: taken reference of right operand | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This lint shouldn't trigger in the test file. Please fix the two new occurrences by removing the ref. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright, will fix. |
||
--> tests/ui/iter_overeager_cloned.rs:16:42 | ||
| | ||
LL | let _: usize = vec.iter().filter(|x| x == &"2").cloned().count(); | ||
| ^^^^^---- | ||
| | | ||
| help: use the right value directly: `"2"` | ||
| | ||
= note: `-D clippy::op-ref` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::op_ref)]` | ||
|
||
error: unnecessarily eager cloning of iterator items | ||
--> tests/ui/iter_overeager_cloned.rs:18:21 | ||
| | ||
|
@@ -52,6 +63,14 @@ LL | let _ = vec.iter().filter(|x| x == &"2").cloned().nth(2); | |
| | | ||
| help: try: `.nth(2).cloned()` | ||
|
||
error: taken reference of right operand | ||
--> tests/ui/iter_overeager_cloned.rs:22:35 | ||
| | ||
LL | let _ = vec.iter().filter(|x| x == &"2").cloned().nth(2); | ||
| ^^^^^---- | ||
| | | ||
| help: use the right value directly: `"2"` | ||
|
||
error: unnecessarily eager cloning of iterator items | ||
--> tests/ui/iter_overeager_cloned.rs:24:13 | ||
| | ||
|
@@ -119,18 +138,18 @@ LL | let _ = vec.iter().cloned().find(f); | |
error: unnecessarily eager cloning of iterator items | ||
--> tests/ui/iter_overeager_cloned.rs:50:9 | ||
| | ||
LL | iter.cloned().filter(move |(&a, b)| a == 1 && b == &target) | ||
| ^^^^------------------------------------------------------- | ||
LL | iter.cloned().filter(move |(&a, b)| a == 1 && b == target) | ||
| ^^^^------------------------------------------------------ | ||
| | | ||
| help: try: `.filter(move |&(&a, b)| a == 1 && b == &target).cloned()` | ||
| help: try: `.filter(move |&(&a, b)| a == 1 && b == target).cloned()` | ||
|
||
error: unnecessarily eager cloning of iterator items | ||
--> tests/ui/iter_overeager_cloned.rs:61:13 | ||
| | ||
LL | iter.cloned().filter(move |S { a, b }| **a == 1 && b == &target) | ||
| ^^^^------------------------------------------------------------ | ||
LL | iter.cloned().filter(move |S { a, b }| **a == 1 && b == target) | ||
| ^^^^----------------------------------------------------------- | ||
| | | ||
| help: try: `.filter(move |&S { a, b }| **a == 1 && b == &target).cloned()` | ||
| help: try: `.filter(move |&S { a, b }| **a == 1 && b == target).cloned()` | ||
|
||
error: unneeded cloning of iterator items | ||
--> tests/ui/iter_overeager_cloned.rs:65:13 | ||
|
@@ -164,5 +183,5 @@ LL | let _ = vec.iter().cloned().any(|x| x.len() == 1); | |
| | | ||
| help: try: `.any(|x| x.len() == 1)` | ||
|
||
error: aborting due to 19 previous errors | ||
error: aborting due to 21 previous errors | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ fn main() { | |
let a = "a".to_string(); | ||
let b = "a"; | ||
|
||
if b < &a { | ||
if b < a { | ||
println!("OK"); | ||
} | ||
|
||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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.
These two impls end up with incorrect stability attributes, which means Clippy msrv autodetection can't be added later.
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.
That's fixable, but is that worth complicating the macro for? There are many other examples of macro-generated instances with the same discrepancy.