-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Duplicate bounds lint #88096
Closed
Closed
Duplicate bounds lint #88096
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c90f42a
uplift `trait_duplication_in_bounds` from clippy to rustc
ibraheemdev 9bc2526
`trait_duplication_in_bounds`: warn on duplicate trait bounds of the …
ibraheemdev d560008
deprecate `clippy::trait_duplication_in_bounds`
ibraheemdev 46868a7
`trait_duplication_in_bounds` => `duplicate_bounds`
ibraheemdev ab0a962
extend `duplicate_bounds` to track lifetimes
ibraheemdev 9e7c714
extend `duplicate_bounds` to handle region where predicates
ibraheemdev c416b99
add `clippy::trait_duplication_in_bounds` to deprecated output
ibraheemdev e644826
remove duplicate trait bound in rustc_data_structures
ibraheemdev ccc2b18
remove duplicate trait bound in `rustc_ast::walk_variant`
ibraheemdev 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1233,6 +1233,7 @@ pub mod tracked_env { | |
/// Besides the dependency tracking this function should be equivalent to `env::var` from the | ||
/// standard library, except that the argument must be UTF-8. | ||
#[unstable(feature = "proc_macro_tracked_env", issue = "74690")] | ||
#[cfg_attr(not(bootstrap), allow(duplicate_bounds))] | ||
pub fn var<K: AsRef<OsStr> + AsRef<str>>(key: K) -> Result<String, VarError> { | ||
Comment on lines
+1236
to
1237
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 seems to be a false positive from the old clippy lint as well: #![deny(clippy::pedantic)]
fn foo<T: AsRef<str>>()
where
T: AsRef<String>,
{
}
I guess I would have to compare |
||
let key: &str = key.as_ref(); | ||
let value = env::var(key); | ||
|
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 |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#![deny(duplicate_bounds)] | ||
|
||
trait DupDirectAndWhere {} | ||
fn dup_direct_and_where<T: DupDirectAndWhere>(t: T) | ||
where | ||
T: DupDirectAndWhere, | ||
//~^ ERROR this trait bound has already been specified | ||
T: DupDirectAndWhere, | ||
//~^ ERROR this trait bound has already been specified | ||
{ | ||
unimplemented!(); | ||
} | ||
|
||
trait DupDirect {} | ||
fn dup_direct<T: DupDirect + DupDirect>(t: T) { | ||
//~^ ERROR this trait bound has already been specified | ||
unimplemented!(); | ||
} | ||
|
||
trait DupWhere {} | ||
fn dup_where<T>(t: T) | ||
where | ||
T: DupWhere + DupWhere, | ||
//~^ ERROR this trait bound has already been specified | ||
{ | ||
unimplemented!(); | ||
} | ||
|
||
trait NotDup {} | ||
fn not_dup<T: NotDup, U: NotDup>((t, u): (T, U)) { | ||
unimplemented!(); | ||
} | ||
|
||
fn dup_lifetimes<'a, 'b: 'a + 'a>() | ||
//~^ ERROR this lifetime bound has already been specified | ||
where | ||
'b: 'a, | ||
//~^ ERROR this lifetime bound has already been specified | ||
{ | ||
} | ||
|
||
fn dup_lifetimes_generic<'a, T: 'a + 'a>() | ||
//~^ ERROR this lifetime bound has already been specified | ||
where | ||
T: 'a, | ||
//~^ ERROR this lifetime bound has already been specified | ||
{ | ||
} | ||
|
||
trait Everything {} | ||
fn everything<T: Everything + Everything, U: Everything + Everything>((t, u): (T, U)) | ||
//~^ ERROR this trait bound has already been specified | ||
//~| ERROR this trait bound has already been specified | ||
where | ||
T: Everything + Everything + Everything, | ||
//~^ ERROR this trait bound has already been specified | ||
//~| ERROR this trait bound has already been specified | ||
//~| ERROR this trait bound has already been specified | ||
U: Everything, | ||
//~^ ERROR this trait bound has already been specified | ||
{ | ||
unimplemented!(); | ||
} | ||
|
||
trait DupStructBound {} | ||
struct DupStruct<T: DupStructBound + DupStructBound>(T) | ||
//~^ ERROR this trait bound has already been specified | ||
where | ||
T: DupStructBound; | ||
//~^ ERROR this trait bound has already been specified | ||
|
||
impl<'a, T: 'a + DupStructBound + DupStructBound> DupStruct<T> | ||
//~^ ERROR this trait bound has already been specified | ||
where | ||
T: 'a + DupStructBound, | ||
//~^ ERROR this lifetime bound has already been specified | ||
//~| ERROR this trait bound has already been specified | ||
{ | ||
fn _x() {} | ||
} | ||
|
||
fn main() {} |
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.
Why is the lint reported 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.
Because
Try
andTryV2
are the same thing now. cc @scottmcmThere 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.
Oh, good point, I never cleaned that alias up after the bootstrap compiler updated. New PR: #88223