1
Fork 0

Point at source of trait bound obligations in more places

Be more thorough in using `ItemObligation` and `BindingObligation` when
evaluating obligations so that we can point at trait bounds that
introduced unfulfilled obligations. We no longer incorrectly point at
unrelated trait bounds (`substs-ppaux.verbose.stderr`).

In particular, we now point at trait bounds on method calls.

We no longer point at "obvious" obligation sources (we no longer have a
note pointing at `Trait` saying "required by a bound in `Trait`", like
in `associated-types-no-suitable-supertrait*`).

Address part of #89418.
This commit is contained in:
Esteban Kuber 2021-10-05 23:04:09 +00:00
parent 93542a8240
commit 6b9d910639
101 changed files with 550 additions and 421 deletions

View file

@ -4,11 +4,11 @@ error[E0277]: the trait bound `T: Bar` is not satisfied
LL | T::b();
| ^^^^ the trait `Bar` is not implemented for `T`
|
note: required by `Foo::b`
--> $DIR/trait-where-clause.rs:8:5
note: required by a bound in `Foo::b`
--> $DIR/trait-where-clause.rs:8:24
|
LL | fn b() where Self: ~const Bar;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^ required by this bound in `Foo::b`
help: consider further restricting this bound
|
LL | const fn test1<T: ~const Foo + Bar + Bar>() {
@ -20,11 +20,11 @@ error[E0277]: the trait bound `T: Bar` is not satisfied
LL | T::c::<T>();
| ^^^^^^^^^ the trait `Bar` is not implemented for `T`
|
note: required by `Foo::c`
--> $DIR/trait-where-clause.rs:9:5
note: required by a bound in `Foo::c`
--> $DIR/trait-where-clause.rs:9:13
|
LL | fn c<T: ~const Bar>();
| ^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^ required by this bound in `Foo::c`
help: consider further restricting this bound
|
LL | const fn test1<T: ~const Foo + Bar + Bar>() {
@ -36,11 +36,11 @@ error[E0277]: the trait bound `T: Bar` is not satisfied
LL | T::b();
| ^^^^ the trait `Bar` is not implemented for `T`
|
note: required by `Foo::b`
--> $DIR/trait-where-clause.rs:8:5
note: required by a bound in `Foo::b`
--> $DIR/trait-where-clause.rs:8:24
|
LL | fn b() where Self: ~const Bar;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^ required by this bound in `Foo::b`
help: consider further restricting this bound
|
LL | fn test3<T: Foo + Bar>() {
@ -52,11 +52,11 @@ error[E0277]: the trait bound `T: Bar` is not satisfied
LL | T::c::<T>();
| ^^^^^^^^^ the trait `Bar` is not implemented for `T`
|
note: required by `Foo::c`
--> $DIR/trait-where-clause.rs:9:5
note: required by a bound in `Foo::c`
--> $DIR/trait-where-clause.rs:9:13
|
LL | fn c<T: ~const Bar>();
| ^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^ required by this bound in `Foo::c`
help: consider further restricting this bound
|
LL | fn test3<T: Foo + Bar>() {