Skip to content

Commit 46868a7

Browse files
committed
trait_duplication_in_bounds => duplicate_bounds
1 parent d560008 commit 46868a7

File tree

6 files changed

+31
-39
lines changed

6 files changed

+31
-39
lines changed

compiler/rustc_lint/src/builtin.rs

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3143,17 +3143,15 @@ impl<'tcx> LateLintPass<'tcx> for DerefNullPtr {
31433143
}
31443144

31453145
declare_lint! {
3146-
/// ### what it does
3147-
/// checks for cases where generics are being used and multiple
3148-
/// syntax specifications for trait bounds are used simultaneously.
3146+
/// ### What it does
3147+
/// Checks for cases where the same trait bound is specified more than once.
31493148
///
3150-
/// ### why is this bad?
3151-
/// duplicate bounds makes the code
3152-
/// less readable than specifing them only once.
3149+
/// ### Why is this bad?
3150+
/// Duplicate bounds makes the code less readable than specifing them only once.
31533151
///
3154-
/// ### example
3152+
/// ### Example
31553153
/// ```rust
3156-
/// fn func<t: clone + default>(arg: t) where t: clone + default {}
3154+
/// fn func<T: Clone + Default>(arg: T) where T: Clone + Default {}
31573155
/// ```
31583156
///
31593157
/// could be written as:
@@ -3166,14 +3164,14 @@ declare_lint! {
31663164
/// ```rust
31673165
/// fn func<T>(arg: T) where T: Clone + Default {}
31683166
/// ```
3169-
pub TRAIT_DUPLICATION_IN_BOUNDS,
3167+
pub DUPLICATE_BOUNDS,
31703168
Warn,
3171-
"Check if the same trait bounds are specified twice during a function declaration"
3169+
"Check if the same bounds is specified more than once"
31723170
}
31733171

3174-
declare_lint_pass!(TraitDuplicationInBounds => [TRAIT_DUPLICATION_IN_BOUNDS]);
3172+
declare_lint_pass!(DuplicateBounds => [DUPLICATE_BOUNDS]);
31753173

3176-
impl<'tcx> LateLintPass<'tcx> for TraitDuplicationInBounds {
3174+
impl<'tcx> LateLintPass<'tcx> for DuplicateBounds {
31773175
fn check_generics(&mut self, cx: &LateContext<'tcx>, gen: &'tcx hir::Generics<'_>) {
31783176
struct TraitRes {
31793177
res: Res,
@@ -3216,7 +3214,7 @@ impl<'tcx> LateLintPass<'tcx> for TraitDuplicationInBounds {
32163214
for res in param.bounds.iter().filter_map(TraitRes::from_bound) {
32173215
let span = res.span.clone();
32183216
if !uniq.insert(res) {
3219-
cx.struct_span_lint(TRAIT_DUPLICATION_IN_BOUNDS, span, |lint| {
3217+
cx.struct_span_lint(DUPLICATE_BOUNDS, span, |lint| {
32203218
lint.build("this trait bound has already been specified")
32213219
.help("consider removing this trait bound")
32223220
.emit()
@@ -3240,17 +3238,11 @@ impl<'tcx> LateLintPass<'tcx> for TraitDuplicationInBounds {
32403238
{
32413239
let span = res.span.clone();
32423240
if !trait_resolutions.insert(res) {
3243-
cx.struct_span_lint(
3244-
TRAIT_DUPLICATION_IN_BOUNDS,
3245-
span,
3246-
|lint| {
3247-
lint.build(
3248-
"this trait bound has already been specified",
3249-
)
3241+
cx.struct_span_lint(DUPLICATE_BOUNDS, span, |lint| {
3242+
lint.build("this trait bound has already been specified")
32503243
.help("consider removing this trait bound")
32513244
.emit()
3252-
},
3253-
);
3245+
});
32543246
}
32553247
}
32563248
}

compiler/rustc_lint/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ macro_rules! late_lint_mod_passes {
197197
// Depends on referenced function signatures in expressions
198198
MutableTransmutes: MutableTransmutes,
199199
TypeAliasBounds: TypeAliasBounds,
200-
TraitDuplicationInBounds: TraitDuplicationInBounds,
200+
DuplicateBounds: DuplicateBounds,
201201
TrivialConstraints: TrivialConstraints,
202202
TypeLimits: TypeLimits::new(),
203203
NonSnakeCase: NonSnakeCase,

library/core/src/iter/traits/iterator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2434,7 +2434,7 @@ pub trait Iterator {
24342434
/// assert!(result.is_err());
24352435
/// ```
24362436
#[inline]
2437-
#[cfg_attr(not(bootstrap), allow(trait_duplication_in_bounds))]
2437+
#[cfg_attr(not(bootstrap), allow(duplicate_bounds))]
24382438
#[unstable(feature = "try_find", reason = "new API", issue = "63178")]
24392439
fn try_find<F, R, E>(&mut self, f: F) -> Result<Option<Self::Item>, E>
24402440
where

library/proc_macro/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,7 @@ pub mod tracked_env {
12331233
/// Besides the dependency tracking this function should be equivalent to `env::var` from the
12341234
/// standard library, except that the argument must be UTF-8.
12351235
#[unstable(feature = "proc_macro_tracked_env", issue = "74690")]
1236-
#[cfg_attr(not(bootstrap), allow(trait_duplication_in_bounds))]
1236+
#[cfg_attr(not(bootstrap), allow(duplicate_bounds))]
12371237
pub fn var<K: AsRef<OsStr> + AsRef<str>>(key: K) -> Result<String, VarError> {
12381238
let key: &str = key.as_ref();
12391239
let value = env::var(key);

src/test/ui/lint/trait_duplication_in_bounds.rs renamed to src/test/ui/lint/duplicate_bounds.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(trait_duplication_in_bounds)]
1+
#![deny(duplicate_bounds)]
22

33
trait DupDirectAndWhere {}
44
fn dup_direct_and_where<T: DupDirectAndWhere>(t: T)

src/test/ui/lint/trait_duplication_in_bounds.stderr renamed to src/test/ui/lint/duplicate_bounds.stderr

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,82 @@
11
error: this trait bound has already been specified
2-
--> $DIR/trait_duplication_in_bounds.rs:6:8
2+
--> $DIR/duplicate_bounds.rs:6:8
33
|
44
LL | T: DupDirectAndWhere,
55
| ^^^^^^^^^^^^^^^^^
66
|
77
note: the lint level is defined here
8-
--> $DIR/trait_duplication_in_bounds.rs:1:9
8+
--> $DIR/duplicate_bounds.rs:1:9
99
|
10-
LL | #![deny(trait_duplication_in_bounds)]
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
10+
LL | #![deny(duplicate_bounds)]
11+
| ^^^^^^^^^^^^^^^^
1212
= help: consider removing this trait bound
1313

1414
error: this trait bound has already been specified
15-
--> $DIR/trait_duplication_in_bounds.rs:8:8
15+
--> $DIR/duplicate_bounds.rs:8:8
1616
|
1717
LL | T: DupDirectAndWhere,
1818
| ^^^^^^^^^^^^^^^^^
1919
|
2020
= help: consider removing this trait bound
2121

2222
error: this trait bound has already been specified
23-
--> $DIR/trait_duplication_in_bounds.rs:15:30
23+
--> $DIR/duplicate_bounds.rs:15:30
2424
|
2525
LL | fn dup_direct<T: DupDirect + DupDirect>(t: T) {
2626
| ^^^^^^^^^
2727
|
2828
= help: consider removing this trait bound
2929

3030
error: this trait bound has already been specified
31-
--> $DIR/trait_duplication_in_bounds.rs:23:19
31+
--> $DIR/duplicate_bounds.rs:23:19
3232
|
3333
LL | T: DupWhere + DupWhere,
3434
| ^^^^^^^^
3535
|
3636
= help: consider removing this trait bound
3737

3838
error: this trait bound has already been specified
39-
--> $DIR/trait_duplication_in_bounds.rs:35:31
39+
--> $DIR/duplicate_bounds.rs:35:31
4040
|
4141
LL | fn everything<T: Everything + Everything, U: Everything + Everything>((t, u): (T, U))
4242
| ^^^^^^^^^^
4343
|
4444
= help: consider removing this trait bound
4545

4646
error: this trait bound has already been specified
47-
--> $DIR/trait_duplication_in_bounds.rs:35:59
47+
--> $DIR/duplicate_bounds.rs:35:59
4848
|
4949
LL | fn everything<T: Everything + Everything, U: Everything + Everything>((t, u): (T, U))
5050
| ^^^^^^^^^^
5151
|
5252
= help: consider removing this trait bound
5353

5454
error: this trait bound has already been specified
55-
--> $DIR/trait_duplication_in_bounds.rs:39:8
55+
--> $DIR/duplicate_bounds.rs:39:8
5656
|
5757
LL | T: Everything + Everything + Everything,
5858
| ^^^^^^^^^^
5959
|
6060
= help: consider removing this trait bound
6161

6262
error: this trait bound has already been specified
63-
--> $DIR/trait_duplication_in_bounds.rs:39:21
63+
--> $DIR/duplicate_bounds.rs:39:21
6464
|
6565
LL | T: Everything + Everything + Everything,
6666
| ^^^^^^^^^^
6767
|
6868
= help: consider removing this trait bound
6969

7070
error: this trait bound has already been specified
71-
--> $DIR/trait_duplication_in_bounds.rs:39:34
71+
--> $DIR/duplicate_bounds.rs:39:34
7272
|
7373
LL | T: Everything + Everything + Everything,
7474
| ^^^^^^^^^^
7575
|
7676
= help: consider removing this trait bound
7777

7878
error: this trait bound has already been specified
79-
--> $DIR/trait_duplication_in_bounds.rs:43:8
79+
--> $DIR/duplicate_bounds.rs:43:8
8080
|
8181
LL | U: Everything,
8282
| ^^^^^^^^^^

0 commit comments

Comments
 (0)