Skip to content

Commit a58682d

Browse files
Specify what 'this' actually is
1 parent 8f55d60 commit a58682d

File tree

68 files changed

+193
-187
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+193
-187
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -2784,7 +2784,13 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
27842784
_ => true,
27852785
};
27862786
if ident.span.is_visible(sm) && !ident.span.overlaps(span) && !same_line {
2787-
multispan.push_span_label(ident.span, "required by a bound in this");
2787+
multispan.push_span_label(
2788+
ident.span,
2789+
format!(
2790+
"required by a bound in this {}",
2791+
tcx.def_kind(item_def_id).descr(item_def_id)
2792+
),
2793+
);
27882794
}
27892795
}
27902796
let descr = format!("required by a bound in `{item_name}`");

tests/ui/associated-types/associated-types-eq-hr.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ note: required by a bound in `foo`
1515
--> $DIR/associated-types-eq-hr.rs:45:36
1616
|
1717
LL | fn foo<T>()
18-
| --- required by a bound in this
18+
| --- required by a bound in this function
1919
LL | where
2020
LL | T: for<'x> TheTrait<&'x isize, A = &'x isize>,
2121
| ^^^^^^^^^^^^^ required by this bound in `foo`
@@ -37,7 +37,7 @@ note: required by a bound in `bar`
3737
--> $DIR/associated-types-eq-hr.rs:52:36
3838
|
3939
LL | fn bar<T>()
40-
| --- required by a bound in this
40+
| --- required by a bound in this function
4141
LL | where
4242
LL | T: for<'x> TheTrait<&'x isize, A = &'x usize>,
4343
| ^^^^^^^^^^^^^ required by this bound in `bar`

tests/ui/associated-types/defaults-suitability.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ LL | Self::Ty: Clone,
2727
| ^^^^^ required by this bound in `Tr2::Ty`
2828
LL | {
2929
LL | type Ty = NotClone;
30-
| -- required by a bound in this
30+
| -- required by a bound in this associated type
3131
help: consider annotating `NotClone` with `#[derive(Clone)]`
3232
|
3333
LL | #[derive(Clone)]
@@ -75,7 +75,7 @@ LL | Self::Assoc: IsU8<Self::Assoc>,
7575
| ^^^^^^^^^^^^^^^^^ required by this bound in `D::Assoc`
7676
...
7777
LL | type Assoc = NotClone;
78-
| ----- required by a bound in this
78+
| ----- required by a bound in this associated type
7979

8080
error[E0277]: the trait bound `<Self as Foo2<T>>::Baz: Clone` is not satisfied
8181
--> $DIR/defaults-suitability.rs:65:23
@@ -124,7 +124,7 @@ LL | Self::Baz: Clone,
124124
| ^^^^^ required by this bound in `Foo3::Baz`
125125
...
126126
LL | type Baz = T;
127-
| --- required by a bound in this
127+
| --- required by a bound in this associated type
128128
help: consider further restricting type parameter `T`
129129
|
130130
LL | Self::Baz: Clone, T: std::clone::Clone

tests/ui/associated-types/hr-associated-type-bound-1.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ note: required by a bound in `X`
99
--> $DIR/hr-associated-type-bound-1.rs:3:33
1010
|
1111
LL | trait X<'a>
12-
| - required by a bound in this
12+
| - required by a bound in this trait
1313
LL | where
1414
LL | for<'b> <Self as X<'b>>::U: Clone,
1515
| ^^^^^ required by this bound in `X`

tests/ui/associated-types/hr-associated-type-bound-object.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ note: required by a bound in `X`
88
--> $DIR/hr-associated-type-bound-object.rs:3:33
99
|
1010
LL | trait X<'a>
11-
| - required by a bound in this
11+
| - required by a bound in this trait
1212
LL | where
1313
LL | for<'b> <Self as X<'b>>::U: Clone,
1414
| ^^^^^ required by this bound in `X`

tests/ui/associated-types/hr-associated-type-bound-param-1.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ note: required by a bound in `Y`
99
--> $DIR/hr-associated-type-bound-param-1.rs:4:36
1010
|
1111
LL | trait Y<'a, T: ?Sized>
12-
| - required by a bound in this
12+
| - required by a bound in this trait
1313
...
1414
LL | for<'b> <Self as Y<'b, T>>::V: Clone,
1515
| ^^^^^ required by this bound in `Y`

tests/ui/associated-types/hr-associated-type-bound-param-2.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ note: required by a bound in `Z`
99
--> $DIR/hr-associated-type-bound-param-2.rs:6:35
1010
|
1111
LL | trait Z<'a, T: ?Sized>
12-
| - required by a bound in this
12+
| - required by a bound in this trait
1313
...
1414
LL | for<'b> <T as Z<'b, u16>>::W: Clone,
1515
| ^^^^^ required by this bound in `Z`
@@ -25,7 +25,7 @@ note: required by a bound in `Z`
2525
--> $DIR/hr-associated-type-bound-param-2.rs:6:35
2626
|
2727
LL | trait Z<'a, T: ?Sized>
28-
| - required by a bound in this
28+
| - required by a bound in this trait
2929
...
3030
LL | for<'b> <T as Z<'b, u16>>::W: Clone,
3131
| ^^^^^ required by this bound in `Z`
@@ -41,7 +41,7 @@ note: required by a bound in `Z`
4141
--> $DIR/hr-associated-type-bound-param-2.rs:6:35
4242
|
4343
LL | trait Z<'a, T: ?Sized>
44-
| - required by a bound in this
44+
| - required by a bound in this trait
4545
...
4646
LL | for<'b> <T as Z<'b, u16>>::W: Clone,
4747
| ^^^^^ required by this bound in `Z`

tests/ui/associated-types/hr-associated-type-bound-param-3.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ note: required by a bound in `X`
99
--> $DIR/hr-associated-type-bound-param-3.rs:4:33
1010
|
1111
LL | trait X<'a, T>
12-
| - required by a bound in this
12+
| - required by a bound in this trait
1313
...
1414
LL | for<'b> <T as X<'b, T>>::U: Clone,
1515
| ^^^^^ required by this bound in `X`

tests/ui/associated-types/hr-associated-type-bound-param-4.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ note: required by a bound in `X`
99
--> $DIR/hr-associated-type-bound-param-4.rs:4:36
1010
|
1111
LL | trait X<'a, T>
12-
| - required by a bound in this
12+
| - required by a bound in this trait
1313
...
1414
LL | for<'b> <(T,) as X<'b, T>>::U: Clone,
1515
| ^^^^^ required by this bound in `X`

tests/ui/associated-types/hr-associated-type-bound-param-5.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ note: required by a bound in `X`
99
--> $DIR/hr-associated-type-bound-param-5.rs:17:45
1010
|
1111
LL | trait X<'a, T: Cycle + for<'b> X<'b, T>>
12-
| - required by a bound in this
12+
| - required by a bound in this trait
1313
...
1414
LL | for<'b> <T::Next as X<'b, T::Next>>::U: Clone,
1515
| ^^^^^ required by this bound in `X`
@@ -25,7 +25,7 @@ note: required by a bound in `X`
2525
--> $DIR/hr-associated-type-bound-param-5.rs:17:45
2626
|
2727
LL | trait X<'a, T: Cycle + for<'b> X<'b, T>>
28-
| - required by a bound in this
28+
| - required by a bound in this trait
2929
...
3030
LL | for<'b> <T::Next as X<'b, T::Next>>::U: Clone,
3131
| ^^^^^ required by this bound in `X`

tests/ui/associated-types/hr-associated-type-projection-1.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ note: required by a bound in `UnsafeCopy`
1010
--> $DIR/hr-associated-type-projection-1.rs:3:64
1111
|
1212
LL | trait UnsafeCopy<'a, T: Copy>
13-
| ---------- required by a bound in this
13+
| ---------- required by a bound in this trait
1414
LL | where
1515
LL | for<'b> <Self as UnsafeCopy<'b, T>>::Item: std::ops::Deref<Target = T>,
1616
| ^^^^^^^^^^ required by this bound in `UnsafeCopy`

tests/ui/associated-types/point-at-type-on-obligation-failure-2.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ LL | Self::Assoc: Bar,
2323
| ^^^ required by this bound in `Baz::Assoc`
2424
LL | {
2525
LL | type Assoc;
26-
| ----- required by a bound in this
26+
| ----- required by a bound in this associated type
2727

2828
error[E0277]: the trait bound `bool: Bar` is not satisfied
2929
--> $DIR/point-at-type-on-obligation-failure-2.rs:30:18
@@ -38,7 +38,7 @@ LL | <Self as Bat>::Assoc: Bar,
3838
| ^^^ required by this bound in `Bat::Assoc`
3939
LL | {
4040
LL | type Assoc;
41-
| ----- required by a bound in this
41+
| ----- required by a bound in this associated type
4242

4343
error: aborting due to 3 previous errors
4444

tests/ui/closure-expected-type/expect-infer-var-appearing-twice.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ note: required by a bound in `with_closure`
1212
--> $DIR/expect-infer-var-appearing-twice.rs:2:14
1313
|
1414
LL | fn with_closure<F, A>(_: F)
15-
| ------------ required by a bound in this
15+
| ------------ required by a bound in this function
1616
LL | where F: FnOnce(A, A)
1717
| ^^^^^^^^^^^^ required by this bound in `with_closure`
1818

tests/ui/const-generics/defaults/wfness.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ note: required by a bound in `WhereClause`
2323
--> $DIR/wfness.rs:8:9
2424
|
2525
LL | struct WhereClause<const N: u8 = 2>
26-
| ----------- required by a bound in this
26+
| ----------- required by a bound in this struct
2727
LL | where
2828
LL | (): Trait<N>;
2929
| ^^^^^^^^ required by this bound in `WhereClause`

tests/ui/const-generics/ensure_is_evaluatable.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ note: required by a bound in `bar`
99
--> $DIR/ensure_is_evaluatable.rs:15:10
1010
|
1111
LL | fn bar<const N: usize>() -> [(); N]
12-
| --- required by a bound in this
12+
| --- required by a bound in this function
1313
LL | where
1414
LL | [(); N + 1]:,
1515
| ^^^^^ required by this bound in `bar`

tests/ui/const-generics/fn_with_two_const_inputs.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ note: required by a bound in `bar`
99
--> $DIR/fn_with_two_const_inputs.rs:18:10
1010
|
1111
LL | fn bar<const N: usize>() -> [(); N]
12-
| --- required by a bound in this
12+
| --- required by a bound in this function
1313
LL | where
1414
LL | [(); N + 1]:,
1515
| ^^^^^ required by this bound in `bar`

tests/ui/const-generics/generic_const_exprs/issue-72819-generic-in-const-eval.full.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ note: required by a bound in `Arr`
1010
--> $DIR/issue-72819-generic-in-const-eval.rs:8:39
1111
|
1212
LL | struct Arr<const N: usize>
13-
| --- required by a bound in this
13+
| --- required by a bound in this struct
1414
LL | where Assert::<{N < usize::MAX / 2}>: IsTrue,
1515
| ^^^^^^ required by this bound in `Arr`
1616

@@ -26,7 +26,7 @@ note: required by a bound in `Arr`
2626
--> $DIR/issue-72819-generic-in-const-eval.rs:8:39
2727
|
2828
LL | struct Arr<const N: usize>
29-
| --- required by a bound in this
29+
| --- required by a bound in this struct
3030
LL | where Assert::<{N < usize::MAX / 2}>: IsTrue,
3131
| ^^^^^^ required by this bound in `Arr`
3232

tests/ui/const-generics/generic_const_exprs/obligation-cause.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ note: required by a bound in `g`
1010
--> $DIR/obligation-cause.rs:13:44
1111
|
1212
LL | fn g<T>()
13-
| - required by a bound in this
13+
| - required by a bound in this function
1414
...
1515
LL | Is<{ std::mem::size_of::<T>() == 0 }>: True,
1616
| ^^^^ required by this bound in `g`

tests/ui/const-generics/issues/issue-67185-2.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ note: required by a bound in `Foo`
3535
--> $DIR/issue-67185-2.rs:15:25
3636
|
3737
LL | trait Foo
38-
| --- required by a bound in this
38+
| --- required by a bound in this trait
3939
...
4040
LL | <u8 as Baz>::Quaks: Bar,
4141
| ^^^ required by this bound in `Foo`
@@ -53,7 +53,7 @@ note: required by a bound in `Foo`
5353
--> $DIR/issue-67185-2.rs:14:30
5454
|
5555
LL | trait Foo
56-
| --- required by a bound in this
56+
| --- required by a bound in this trait
5757
LL | where
5858
LL | [<u8 as Baz>::Quaks; 2]: Bar,
5959
| ^^^ required by this bound in `Foo`
@@ -71,7 +71,7 @@ note: required by a bound in `Foo`
7171
--> $DIR/issue-67185-2.rs:14:30
7272
|
7373
LL | trait Foo
74-
| --- required by a bound in this
74+
| --- required by a bound in this trait
7575
LL | where
7676
LL | [<u8 as Baz>::Quaks; 2]: Bar,
7777
| ^^^ required by this bound in `Foo`
@@ -89,7 +89,7 @@ note: required by a bound in `Foo`
8989
--> $DIR/issue-67185-2.rs:15:25
9090
|
9191
LL | trait Foo
92-
| --- required by a bound in this
92+
| --- required by a bound in this trait
9393
...
9494
LL | <u8 as Baz>::Quaks: Bar,
9595
| ^^^ required by this bound in `Foo`

tests/ui/const-generics/issues/issue-73260.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ note: required by a bound in `Arr`
1010
--> $DIR/issue-73260.rs:5:37
1111
|
1212
LL | struct Arr<const N: usize>
13-
| --- required by a bound in this
13+
| --- required by a bound in this struct
1414
LL | where
1515
LL | Assert::<{N < usize::MAX / 2}>: IsTrue,
1616
| ^^^^^^ required by this bound in `Arr`
@@ -27,7 +27,7 @@ note: required by a bound in `Arr`
2727
--> $DIR/issue-73260.rs:5:37
2828
|
2929
LL | struct Arr<const N: usize>
30-
| --- required by a bound in this
30+
| --- required by a bound in this struct
3131
LL | where
3232
LL | Assert::<{N < usize::MAX / 2}>: IsTrue,
3333
| ^^^^^^ required by this bound in `Arr`

tests/ui/const-generics/issues/issue-79674.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ note: required by a bound in `requires_distinct`
1010
--> $DIR/issue-79674.rs:23:37
1111
|
1212
LL | fn requires_distinct<A, B>(_a: A, _b: B) where
13-
| ----------------- required by a bound in this
13+
| ----------------- required by a bound in this function
1414
LL | A: MiniTypeId, B: MiniTypeId,
1515
LL | Lift<{is_same_type::<A, B>()}>: IsFalse {}
1616
| ^^^^^^^ required by this bound in `requires_distinct`

tests/ui/const-generics/issues/issue-86530.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ note: required by a bound in `z`
1010
--> $DIR/issue-86530.rs:10:8
1111
|
1212
LL | fn z<T>(t: T)
13-
| - required by a bound in this
13+
| - required by a bound in this function
1414
LL | where
1515
LL | T: X,
1616
| ^ required by this bound in `z`

tests/ui/const-generics/occurs-check/unused-substs-1.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ note: required by a bound in `A`
99
--> $DIR/unused-substs-1.rs:9:11
1010
|
1111
LL | struct A<const N: usize>
12-
| - required by a bound in this
12+
| - required by a bound in this unit struct
1313
LL | where
1414
LL | A<N>: Bar<N>;
1515
| ^^^^^^ required by this bound in `A`

tests/ui/const-generics/unify_with_nested_expr.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ note: required by a bound in `bar`
88
--> $DIR/unify_with_nested_expr.rs:14:10
99
|
1010
LL | fn bar<const N: usize>()
11-
| --- required by a bound in this
11+
| --- required by a bound in this function
1212
LL | where
1313
LL | [(); N + 1]:,
1414
| ^^^^^ required by this bound in `bar`

tests/ui/consts/ct-var-in-collect_all_mismatches.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ note: required by a bound in `Foo::<T, N>::unsatisfied`
88
--> $DIR/ct-var-in-collect_all_mismatches.rs:15:12
99
|
1010
LL | fn unsatisfied(self)
11-
| ----------- required by a bound in this
11+
| ----------- required by a bound in this associated function
1212
LL | where
1313
LL | T: Bar<N>,
1414
| ^^^^^^ required by this bound in `Foo::<T, N>::unsatisfied`

tests/ui/generator/generator-yielding-or-returning-itself.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ note: required by a bound in `want_cyclic_generator_return`
1919
--> $DIR/generator-yielding-or-returning-itself.rs:10:36
2020
|
2121
LL | pub fn want_cyclic_generator_return<T>(_: T)
22-
| ---------------------------- required by a bound in this
22+
| ---------------------------- required by a bound in this function
2323
LL | where T: Generator<Yield = (), Return = T>
2424
| ^^^^^^^^^^ required by this bound in `want_cyclic_generator_return`
2525

@@ -44,7 +44,7 @@ note: required by a bound in `want_cyclic_generator_yield`
4444
--> $DIR/generator-yielding-or-returning-itself.rs:23:24
4545
|
4646
LL | pub fn want_cyclic_generator_yield<T>(_: T)
47-
| --------------------------- required by a bound in this
47+
| --------------------------- required by a bound in this function
4848
LL | where T: Generator<Yield = T, Return = ()>
4949
| ^^^^^^^^^ required by this bound in `want_cyclic_generator_yield`
5050

tests/ui/generic-associated-types/bugs/issue-88460.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ note: required by a bound in `test`
1111
--> $DIR/issue-88460.rs:15:27
1212
|
1313
LL | fn test<T>(value: T)
14-
| ---- required by a bound in this
14+
| ---- required by a bound in this function
1515
...
1616
LL | for<'a> T::Assoc<'a>: Marker,
1717
| ^^^^^^ required by this bound in `test`

tests/ui/generic-associated-types/issue-101020.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ note: required by a bound in `LendingIterator::consume`
1313
--> $DIR/issue-101020.rs:9:33
1414
|
1515
LL | fn consume<F>(self, _f: F)
16-
| ------- required by a bound in this
16+
| ------- required by a bound in this associated function
1717
...
1818
LL | for<'a> Self::Item<'a>: FuncInput<'a, Self::Item<'a>>,
1919
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `LendingIterator::consume`

tests/ui/higher-rank-trait-bounds/hrtb-higher-ranker-supertraits-transitive.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ note: required by a bound in `want_bar_for_any_ccx`
1010
--> $DIR/hrtb-higher-ranker-supertraits-transitive.rs:32:15
1111
|
1212
LL | fn want_bar_for_any_ccx<B>(b: &B)
13-
| -------------------- required by a bound in this
13+
| -------------------- required by a bound in this function
1414
LL | where B : for<'ccx> Bar<'ccx>
1515
| ^^^^^^^^^^^^^^^^^^^ required by this bound in `want_bar_for_any_ccx`
1616
help: consider further restricting this bound

0 commit comments

Comments
 (0)