Skip to content

Use DefKind to give more item kind information during BindingObligation note #108295

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

Merged
merged 1 commit into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2784,7 +2784,13 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
_ => true,
};
if ident.span.is_visible(sm) && !ident.span.overlaps(span) && !same_line {
multispan.push_span_label(ident.span, "required by a bound in this");
multispan.push_span_label(
ident.span,
format!(
"required by a bound in this {}",
tcx.def_kind(item_def_id).descr(item_def_id)
),
);
}
}
let descr = format!("required by a bound in `{item_name}`");
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/associated-types/associated-types-eq-hr.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ note: required by a bound in `foo`
--> $DIR/associated-types-eq-hr.rs:45:36
|
LL | fn foo<T>()
| --- required by a bound in this
| --- required by a bound in this function
LL | where
LL | T: for<'x> TheTrait<&'x isize, A = &'x isize>,
| ^^^^^^^^^^^^^ required by this bound in `foo`
Expand All @@ -37,7 +37,7 @@ note: required by a bound in `bar`
--> $DIR/associated-types-eq-hr.rs:52:36
|
LL | fn bar<T>()
| --- required by a bound in this
| --- required by a bound in this function
LL | where
LL | T: for<'x> TheTrait<&'x isize, A = &'x usize>,
| ^^^^^^^^^^^^^ required by this bound in `bar`
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/associated-types/defaults-suitability.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ LL | Self::Ty: Clone,
| ^^^^^ required by this bound in `Tr2::Ty`
LL | {
LL | type Ty = NotClone;
| -- required by a bound in this
| -- required by a bound in this associated type
help: consider annotating `NotClone` with `#[derive(Clone)]`
|
LL | #[derive(Clone)]
Expand Down Expand Up @@ -75,7 +75,7 @@ LL | Self::Assoc: IsU8<Self::Assoc>,
| ^^^^^^^^^^^^^^^^^ required by this bound in `D::Assoc`
...
LL | type Assoc = NotClone;
| ----- required by a bound in this
| ----- required by a bound in this associated type

error[E0277]: the trait bound `<Self as Foo2<T>>::Baz: Clone` is not satisfied
--> $DIR/defaults-suitability.rs:65:23
Expand Down Expand Up @@ -124,7 +124,7 @@ LL | Self::Baz: Clone,
| ^^^^^ required by this bound in `Foo3::Baz`
...
LL | type Baz = T;
| --- required by a bound in this
| --- required by a bound in this associated type
help: consider further restricting type parameter `T`
|
LL | Self::Baz: Clone, T: std::clone::Clone
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ note: required by a bound in `X`
--> $DIR/hr-associated-type-bound-1.rs:3:33
|
LL | trait X<'a>
| - required by a bound in this
| - required by a bound in this trait
LL | where
LL | for<'b> <Self as X<'b>>::U: Clone,
| ^^^^^ required by this bound in `X`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ note: required by a bound in `X`
--> $DIR/hr-associated-type-bound-object.rs:3:33
|
LL | trait X<'a>
| - required by a bound in this
| - required by a bound in this trait
LL | where
LL | for<'b> <Self as X<'b>>::U: Clone,
| ^^^^^ required by this bound in `X`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ note: required by a bound in `Y`
--> $DIR/hr-associated-type-bound-param-1.rs:4:36
|
LL | trait Y<'a, T: ?Sized>
| - required by a bound in this
| - required by a bound in this trait
...
LL | for<'b> <Self as Y<'b, T>>::V: Clone,
| ^^^^^ required by this bound in `Y`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ note: required by a bound in `Z`
--> $DIR/hr-associated-type-bound-param-2.rs:6:35
|
LL | trait Z<'a, T: ?Sized>
| - required by a bound in this
| - required by a bound in this trait
...
LL | for<'b> <T as Z<'b, u16>>::W: Clone,
| ^^^^^ required by this bound in `Z`
Expand All @@ -25,7 +25,7 @@ note: required by a bound in `Z`
--> $DIR/hr-associated-type-bound-param-2.rs:6:35
|
LL | trait Z<'a, T: ?Sized>
| - required by a bound in this
| - required by a bound in this trait
...
LL | for<'b> <T as Z<'b, u16>>::W: Clone,
| ^^^^^ required by this bound in `Z`
Expand All @@ -41,7 +41,7 @@ note: required by a bound in `Z`
--> $DIR/hr-associated-type-bound-param-2.rs:6:35
|
LL | trait Z<'a, T: ?Sized>
| - required by a bound in this
| - required by a bound in this trait
...
LL | for<'b> <T as Z<'b, u16>>::W: Clone,
| ^^^^^ required by this bound in `Z`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ note: required by a bound in `X`
--> $DIR/hr-associated-type-bound-param-3.rs:4:33
|
LL | trait X<'a, T>
| - required by a bound in this
| - required by a bound in this trait
...
LL | for<'b> <T as X<'b, T>>::U: Clone,
| ^^^^^ required by this bound in `X`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ note: required by a bound in `X`
--> $DIR/hr-associated-type-bound-param-4.rs:4:36
|
LL | trait X<'a, T>
| - required by a bound in this
| - required by a bound in this trait
...
LL | for<'b> <(T,) as X<'b, T>>::U: Clone,
| ^^^^^ required by this bound in `X`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ note: required by a bound in `X`
--> $DIR/hr-associated-type-bound-param-5.rs:17:45
|
LL | trait X<'a, T: Cycle + for<'b> X<'b, T>>
| - required by a bound in this
| - required by a bound in this trait
...
LL | for<'b> <T::Next as X<'b, T::Next>>::U: Clone,
| ^^^^^ required by this bound in `X`
Expand All @@ -25,7 +25,7 @@ note: required by a bound in `X`
--> $DIR/hr-associated-type-bound-param-5.rs:17:45
|
LL | trait X<'a, T: Cycle + for<'b> X<'b, T>>
| - required by a bound in this
| - required by a bound in this trait
...
LL | for<'b> <T::Next as X<'b, T::Next>>::U: Clone,
| ^^^^^ required by this bound in `X`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ note: required by a bound in `UnsafeCopy`
--> $DIR/hr-associated-type-projection-1.rs:3:64
|
LL | trait UnsafeCopy<'a, T: Copy>
| ---------- required by a bound in this
| ---------- required by a bound in this trait
LL | where
LL | for<'b> <Self as UnsafeCopy<'b, T>>::Item: std::ops::Deref<Target = T>,
| ^^^^^^^^^^ required by this bound in `UnsafeCopy`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ LL | Self::Assoc: Bar,
| ^^^ required by this bound in `Baz::Assoc`
LL | {
LL | type Assoc;
| ----- required by a bound in this
| ----- required by a bound in this associated type

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

error: aborting due to 3 previous errors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ note: required by a bound in `with_closure`
--> $DIR/expect-infer-var-appearing-twice.rs:2:14
|
LL | fn with_closure<F, A>(_: F)
| ------------ required by a bound in this
| ------------ required by a bound in this function
LL | where F: FnOnce(A, A)
| ^^^^^^^^^^^^ required by this bound in `with_closure`

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/const-generics/defaults/wfness.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ note: required by a bound in `WhereClause`
--> $DIR/wfness.rs:8:9
|
LL | struct WhereClause<const N: u8 = 2>
| ----------- required by a bound in this
| ----------- required by a bound in this struct
LL | where
LL | (): Trait<N>;
| ^^^^^^^^ required by this bound in `WhereClause`
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/const-generics/ensure_is_evaluatable.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ note: required by a bound in `bar`
--> $DIR/ensure_is_evaluatable.rs:15:10
|
LL | fn bar<const N: usize>() -> [(); N]
| --- required by a bound in this
| --- required by a bound in this function
LL | where
LL | [(); N + 1]:,
| ^^^^^ required by this bound in `bar`
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/const-generics/fn_with_two_const_inputs.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ note: required by a bound in `bar`
--> $DIR/fn_with_two_const_inputs.rs:18:10
|
LL | fn bar<const N: usize>() -> [(); N]
| --- required by a bound in this
| --- required by a bound in this function
LL | where
LL | [(); N + 1]:,
| ^^^^^ required by this bound in `bar`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ note: required by a bound in `Arr`
--> $DIR/issue-72819-generic-in-const-eval.rs:8:39
|
LL | struct Arr<const N: usize>
| --- required by a bound in this
| --- required by a bound in this struct
LL | where Assert::<{N < usize::MAX / 2}>: IsTrue,
| ^^^^^^ required by this bound in `Arr`

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ note: required by a bound in `g`
--> $DIR/obligation-cause.rs:13:44
|
LL | fn g<T>()
| - required by a bound in this
| - required by a bound in this function
...
LL | Is<{ std::mem::size_of::<T>() == 0 }>: True,
| ^^^^ required by this bound in `g`
Expand Down
8 changes: 4 additions & 4 deletions tests/ui/const-generics/issues/issue-67185-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ note: required by a bound in `Foo`
--> $DIR/issue-67185-2.rs:15:25
|
LL | trait Foo
| --- required by a bound in this
| --- required by a bound in this trait
...
LL | <u8 as Baz>::Quaks: Bar,
| ^^^ required by this bound in `Foo`
Expand All @@ -53,7 +53,7 @@ note: required by a bound in `Foo`
--> $DIR/issue-67185-2.rs:14:30
|
LL | trait Foo
| --- required by a bound in this
| --- required by a bound in this trait
LL | where
LL | [<u8 as Baz>::Quaks; 2]: Bar,
| ^^^ required by this bound in `Foo`
Expand All @@ -71,7 +71,7 @@ note: required by a bound in `Foo`
--> $DIR/issue-67185-2.rs:14:30
|
LL | trait Foo
| --- required by a bound in this
| --- required by a bound in this trait
LL | where
LL | [<u8 as Baz>::Quaks; 2]: Bar,
| ^^^ required by this bound in `Foo`
Expand All @@ -89,7 +89,7 @@ note: required by a bound in `Foo`
--> $DIR/issue-67185-2.rs:15:25
|
LL | trait Foo
| --- required by a bound in this
| --- required by a bound in this trait
...
LL | <u8 as Baz>::Quaks: Bar,
| ^^^ required by this bound in `Foo`
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/const-generics/issues/issue-73260.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ note: required by a bound in `Arr`
--> $DIR/issue-73260.rs:5:37
|
LL | struct Arr<const N: usize>
| --- required by a bound in this
| --- required by a bound in this struct
LL | where
LL | Assert::<{N < usize::MAX / 2}>: IsTrue,
| ^^^^^^ required by this bound in `Arr`
Expand All @@ -27,7 +27,7 @@ note: required by a bound in `Arr`
--> $DIR/issue-73260.rs:5:37
|
LL | struct Arr<const N: usize>
| --- required by a bound in this
| --- required by a bound in this struct
LL | where
LL | Assert::<{N < usize::MAX / 2}>: IsTrue,
| ^^^^^^ required by this bound in `Arr`
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/const-generics/issues/issue-79674.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ note: required by a bound in `requires_distinct`
--> $DIR/issue-79674.rs:23:37
|
LL | fn requires_distinct<A, B>(_a: A, _b: B) where
| ----------------- required by a bound in this
| ----------------- required by a bound in this function
LL | A: MiniTypeId, B: MiniTypeId,
LL | Lift<{is_same_type::<A, B>()}>: IsFalse {}
| ^^^^^^^ required by this bound in `requires_distinct`
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/const-generics/issues/issue-86530.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ note: required by a bound in `z`
--> $DIR/issue-86530.rs:10:8
|
LL | fn z<T>(t: T)
| - required by a bound in this
| - required by a bound in this function
LL | where
LL | T: X,
| ^ required by this bound in `z`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ note: required by a bound in `A`
--> $DIR/unused-substs-1.rs:9:11
|
LL | struct A<const N: usize>
| - required by a bound in this
| - required by a bound in this unit struct
LL | where
LL | A<N>: Bar<N>;
| ^^^^^^ required by this bound in `A`
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/const-generics/unify_with_nested_expr.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ note: required by a bound in `bar`
--> $DIR/unify_with_nested_expr.rs:14:10
|
LL | fn bar<const N: usize>()
| --- required by a bound in this
| --- required by a bound in this function
LL | where
LL | [(); N + 1]:,
| ^^^^^ required by this bound in `bar`
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/consts/ct-var-in-collect_all_mismatches.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ note: required by a bound in `Foo::<T, N>::unsatisfied`
--> $DIR/ct-var-in-collect_all_mismatches.rs:15:12
|
LL | fn unsatisfied(self)
| ----------- required by a bound in this
| ----------- required by a bound in this associated function
LL | where
LL | T: Bar<N>,
| ^^^^^^ required by this bound in `Foo::<T, N>::unsatisfied`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ note: required by a bound in `want_cyclic_generator_return`
--> $DIR/generator-yielding-or-returning-itself.rs:10:36
|
LL | pub fn want_cyclic_generator_return<T>(_: T)
| ---------------------------- required by a bound in this
| ---------------------------- required by a bound in this function
LL | where T: Generator<Yield = (), Return = T>
| ^^^^^^^^^^ required by this bound in `want_cyclic_generator_return`

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

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/generic-associated-types/bugs/issue-88460.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ note: required by a bound in `test`
--> $DIR/issue-88460.rs:15:27
|
LL | fn test<T>(value: T)
| ---- required by a bound in this
| ---- required by a bound in this function
...
LL | for<'a> T::Assoc<'a>: Marker,
| ^^^^^^ required by this bound in `test`
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/generic-associated-types/issue-101020.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ note: required by a bound in `LendingIterator::consume`
--> $DIR/issue-101020.rs:9:33
|
LL | fn consume<F>(self, _f: F)
| ------- required by a bound in this
| ------- required by a bound in this associated function
...
LL | for<'a> Self::Item<'a>: FuncInput<'a, Self::Item<'a>>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `LendingIterator::consume`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ note: required by a bound in `want_bar_for_any_ccx`
--> $DIR/hrtb-higher-ranker-supertraits-transitive.rs:32:15
|
LL | fn want_bar_for_any_ccx<B>(b: &B)
| -------------------- required by a bound in this
| -------------------- required by a bound in this function
LL | where B : for<'ccx> Bar<'ccx>
| ^^^^^^^^^^^^^^^^^^^ required by this bound in `want_bar_for_any_ccx`
help: consider further restricting this bound
Expand Down
Loading