-
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
Duplicate bounds lint #88096
Duplicate bounds lint #88096
Changes from all commits
c90f42a
9bc2526
d560008
46868a7
ab0a962
9e7c714
c416b99
e644826
ccc2b18
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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); | ||
|
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() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
error: this trait bound has already been specified | ||
--> $DIR/duplicate_bounds.rs:6:8 | ||
| | ||
LL | T: DupDirectAndWhere, | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/duplicate_bounds.rs:1:9 | ||
| | ||
LL | #![deny(duplicate_bounds)] | ||
| ^^^^^^^^^^^^^^^^ | ||
= help: consider removing this trait bound | ||
|
||
error: this trait bound has already been specified | ||
--> $DIR/duplicate_bounds.rs:8:8 | ||
| | ||
LL | T: DupDirectAndWhere, | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: consider removing this trait bound | ||
|
||
error: this trait bound has already been specified | ||
--> $DIR/duplicate_bounds.rs:15:30 | ||
| | ||
LL | fn dup_direct<T: DupDirect + DupDirect>(t: T) { | ||
| ^^^^^^^^^ | ||
| | ||
= help: consider removing this trait bound | ||
|
||
error: this trait bound has already been specified | ||
--> $DIR/duplicate_bounds.rs:23:19 | ||
| | ||
LL | T: DupWhere + DupWhere, | ||
| ^^^^^^^^ | ||
| | ||
= help: consider removing this trait bound | ||
|
||
error: this lifetime bound has already been specified | ||
--> $DIR/duplicate_bounds.rs:34:31 | ||
| | ||
LL | fn dup_lifetimes<'a, 'b: 'a + 'a>() | ||
| ^^ | ||
| | ||
= help: consider removing this lifetime bound | ||
|
||
error: this lifetime bound has already been specified | ||
--> $DIR/duplicate_bounds.rs:37:9 | ||
| | ||
LL | 'b: 'a, | ||
| ^^ | ||
| | ||
= help: consider removing this lifetime bound | ||
|
||
error: this lifetime bound has already been specified | ||
--> $DIR/duplicate_bounds.rs:42:38 | ||
| | ||
LL | fn dup_lifetimes_generic<'a, T: 'a + 'a>() | ||
| ^^ | ||
| | ||
= help: consider removing this lifetime bound | ||
|
||
error: this lifetime bound has already been specified | ||
--> $DIR/duplicate_bounds.rs:45:8 | ||
| | ||
LL | T: 'a, | ||
| ^^ | ||
| | ||
= help: consider removing this lifetime bound | ||
|
||
error: this trait bound has already been specified | ||
--> $DIR/duplicate_bounds.rs:51:31 | ||
| | ||
LL | fn everything<T: Everything + Everything, U: Everything + Everything>((t, u): (T, U)) | ||
| ^^^^^^^^^^ | ||
| | ||
= help: consider removing this trait bound | ||
|
||
error: this trait bound has already been specified | ||
--> $DIR/duplicate_bounds.rs:51:59 | ||
| | ||
LL | fn everything<T: Everything + Everything, U: Everything + Everything>((t, u): (T, U)) | ||
| ^^^^^^^^^^ | ||
| | ||
= help: consider removing this trait bound | ||
|
||
error: this trait bound has already been specified | ||
--> $DIR/duplicate_bounds.rs:55:8 | ||
| | ||
LL | T: Everything + Everything + Everything, | ||
| ^^^^^^^^^^ | ||
| | ||
= help: consider removing this trait bound | ||
|
||
error: this trait bound has already been specified | ||
--> $DIR/duplicate_bounds.rs:55:21 | ||
| | ||
LL | T: Everything + Everything + Everything, | ||
| ^^^^^^^^^^ | ||
| | ||
= help: consider removing this trait bound | ||
|
||
error: this trait bound has already been specified | ||
--> $DIR/duplicate_bounds.rs:55:34 | ||
| | ||
LL | T: Everything + Everything + Everything, | ||
| ^^^^^^^^^^ | ||
| | ||
= help: consider removing this trait bound | ||
|
||
error: this trait bound has already been specified | ||
--> $DIR/duplicate_bounds.rs:59:8 | ||
| | ||
LL | U: Everything, | ||
| ^^^^^^^^^^ | ||
| | ||
= help: consider removing this trait bound | ||
|
||
error: this trait bound has already been specified | ||
--> $DIR/duplicate_bounds.rs:66:38 | ||
| | ||
LL | struct DupStruct<T: DupStructBound + DupStructBound>(T) | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= help: consider removing this trait bound | ||
|
||
error: this trait bound has already been specified | ||
--> $DIR/duplicate_bounds.rs:69:8 | ||
| | ||
LL | T: DupStructBound; | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= help: consider removing this trait bound | ||
|
||
error: this trait bound has already been specified | ||
--> $DIR/duplicate_bounds.rs:72:35 | ||
| | ||
LL | impl<'a, T: 'a + DupStructBound + DupStructBound> DupStruct<T> | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= help: consider removing this trait bound | ||
|
||
error: this lifetime bound has already been specified | ||
--> $DIR/duplicate_bounds.rs:75:8 | ||
| | ||
LL | T: 'a + DupStructBound, | ||
| ^^ | ||
| | ||
= help: consider removing this lifetime bound | ||
|
||
error: this trait bound has already been specified | ||
--> $DIR/duplicate_bounds.rs:75:13 | ||
| | ||
LL | T: 'a + DupStructBound, | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= help: consider removing this trait bound | ||
|
||
error: aborting due to 19 previous errors | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -925,7 +925,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: | |||||
temporary_assignment::TEMPORARY_ASSIGNMENT, | ||||||
to_digit_is_some::TO_DIGIT_IS_SOME, | ||||||
to_string_in_display::TO_STRING_IN_DISPLAY, | ||||||
trait_bounds::TRAIT_DUPLICATION_IN_BOUNDS, | ||||||
trait_bounds::TYPE_REPETITION_IN_BOUNDS, | ||||||
transmute::CROSSPOINTER_TRANSMUTE, | ||||||
transmute::TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS, | ||||||
|
@@ -1133,7 +1132,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: | |||||
LintId::of(semicolon_if_nothing_returned::SEMICOLON_IF_NOTHING_RETURNED), | ||||||
LintId::of(shadow::SHADOW_UNRELATED), | ||||||
LintId::of(strings::STRING_ADD_ASSIGN), | ||||||
LintId::of(trait_bounds::TRAIT_DUPLICATION_IN_BOUNDS), | ||||||
LintId::of(trait_bounds::TYPE_REPETITION_IN_BOUNDS), | ||||||
LintId::of(transmute::TRANSMUTE_PTR_TO_PTR), | ||||||
LintId::of(types::LINKEDLIST), | ||||||
|
@@ -2182,6 +2180,7 @@ pub fn register_renamed(ls: &mut rustc_lint::LintStore) { | |||||
ls.register_renamed("clippy::panic_params", "non_fmt_panics"); | ||||||
ls.register_renamed("clippy::unknown_clippy_lints", "unknown_lints"); | ||||||
ls.register_renamed("clippy::invalid_atomic_ordering", "invalid_atomic_ordering"); | ||||||
ls.register_renamed("clippy::trait_duplication_in_bounds", "trait_duplication_in_bounds"); | ||||||
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.
Suggested change
|
||||||
} | ||||||
|
||||||
// only exists to let the dogfood integration test works. | ||||||
|
This file was deleted.
This file was deleted.
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