diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:50 +0000 |
commit | 2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35 (patch) | |
tree | d325add32978dbdc1db975a438b3a77d571b1ab8 /tests/ui/errors | |
parent | Releasing progress-linux version 1.68.2+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35.tar.xz rustc-2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35.zip |
Merging upstream version 1.69.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
4 files changed, 1053 insertions, 0 deletions
diff --git a/tests/ui/errors/trait-bound-error-spans/blame-trait-error.rs b/tests/ui/errors/trait-bound-error-spans/blame-trait-error.rs new file mode 100644 index 000000000..0fbd85143 --- /dev/null +++ b/tests/ui/errors/trait-bound-error-spans/blame-trait-error.rs @@ -0,0 +1,102 @@ +trait T1 {} +trait T2 {} +trait T3 {} +trait T4 {} + +impl<B: T2> T1 for Wrapper<B> {} + +impl T2 for i32 {} +impl T3 for i32 {} + +impl<A: T3> T2 for Burrito<A> {} + +struct Wrapper<W> { + value: W, +} + +struct Burrito<F> { + filling: F, +} + +impl<It: Iterator> T1 for Option<It> {} + +impl<'a, A: T1> T1 for &'a A {} + +fn want<V: T1>(_x: V) {} + +enum ExampleTuple<T> { + ExampleTupleVariant(T), +} +use ExampleDifferentTupleVariantName as ExampleYetAnotherTupleVariantName; +use ExampleTuple as ExampleOtherTuple; +use ExampleTuple::ExampleTupleVariant as ExampleDifferentTupleVariantName; +use ExampleTuple::*; + +impl<A> T1 for ExampleTuple<A> where A: T3 {} + +enum ExampleStruct<T> { + ExampleStructVariant { field: T }, +} +use ExampleDifferentStructVariantName as ExampleYetAnotherStructVariantName; +use ExampleStruct as ExampleOtherStruct; +use ExampleStruct::ExampleStructVariant as ExampleDifferentStructVariantName; +use ExampleStruct::*; + +impl<A> T1 for ExampleStruct<A> where A: T3 {} + +struct ExampleActuallyTupleStruct<T>(T, i32); +use ExampleActuallyTupleStruct as ExampleActuallyTupleStructOther; + +impl<A> T1 for ExampleActuallyTupleStruct<A> where A: T3 {} + +fn example<Q>(q: Q) { + want(Wrapper { value: Burrito { filling: q } }); + //~^ ERROR the trait bound `Q: T3` is not satisfied [E0277] + + want(Some(())); + //~^ ERROR `()` is not an iterator [E0277] + + want(Some(q)); + //~^ ERROR `Q` is not an iterator [E0277] + + want(&Some(q)); + //~^ ERROR `Q` is not an iterator [E0277] + + want(&ExampleTuple::ExampleTupleVariant(q)); + //~^ ERROR `Q: T3` is not satisfied [E0277] + + want(&ExampleTupleVariant(q)); + //~^ ERROR `Q: T3` is not satisfied [E0277] + + want(&ExampleOtherTuple::ExampleTupleVariant(q)); + //~^ ERROR `Q: T3` is not satisfied [E0277] + + want(&ExampleDifferentTupleVariantName(q)); + //~^ ERROR `Q: T3` is not satisfied [E0277] + + want(&ExampleYetAnotherTupleVariantName(q)); + //~^ ERROR `Q: T3` is not satisfied [E0277] + + want(&ExampleStruct::ExampleStructVariant { field: q }); + //~^ ERROR `Q: T3` is not satisfied [E0277] + + want(&ExampleStructVariant { field: q }); + //~^ ERROR `Q: T3` is not satisfied [E0277] + + want(&ExampleOtherStruct::ExampleStructVariant { field: q }); + //~^ ERROR `Q: T3` is not satisfied [E0277] + + want(&ExampleDifferentStructVariantName { field: q }); + //~^ ERROR `Q: T3` is not satisfied [E0277] + + want(&ExampleYetAnotherStructVariantName { field: q }); + //~^ ERROR `Q: T3` is not satisfied [E0277] + + want(&ExampleActuallyTupleStruct(q, 0)); + //~^ ERROR `Q: T3` is not satisfied [E0277] + + want(&ExampleActuallyTupleStructOther(q, 0)); + //~^ ERROR `Q: T3` is not satisfied [E0277] +} + +fn main() {} diff --git a/tests/ui/errors/trait-bound-error-spans/blame-trait-error.stderr b/tests/ui/errors/trait-bound-error-spans/blame-trait-error.stderr new file mode 100644 index 000000000..9228a047e --- /dev/null +++ b/tests/ui/errors/trait-bound-error-spans/blame-trait-error.stderr @@ -0,0 +1,402 @@ +error[E0277]: the trait bound `Q: T3` is not satisfied + --> $DIR/blame-trait-error.rs:53:46 + | +LL | want(Wrapper { value: Burrito { filling: q } }); + | ---- ^ the trait `T3` is not implemented for `Q` + | | + | required by a bound introduced by this call + | +note: required for `Burrito<Q>` to implement `T2` + --> $DIR/blame-trait-error.rs:11:13 + | +LL | impl<A: T3> T2 for Burrito<A> {} + | -- ^^ ^^^^^^^^^^ + | | + | unsatisfied trait bound introduced here +note: required for `Wrapper<Burrito<Q>>` to implement `T1` + --> $DIR/blame-trait-error.rs:6:13 + | +LL | impl<B: T2> T1 for Wrapper<B> {} + | -- ^^ ^^^^^^^^^^ + | | + | unsatisfied trait bound introduced here +note: required by a bound in `want` + --> $DIR/blame-trait-error.rs:25:12 + | +LL | fn want<V: T1>(_x: V) {} + | ^^ required by this bound in `want` +help: consider restricting type parameter `Q` + | +LL | fn example<Q: T3>(q: Q) { + | ++++ + +error[E0277]: `()` is not an iterator + --> $DIR/blame-trait-error.rs:56:15 + | +LL | want(Some(())); + | ---- ^^ `()` is not an iterator + | | + | required by a bound introduced by this call + | + = help: the trait `Iterator` is not implemented for `()` + = help: the trait `T1` is implemented for `Option<It>` +note: required for `Option<()>` to implement `T1` + --> $DIR/blame-trait-error.rs:21:20 + | +LL | impl<It: Iterator> T1 for Option<It> {} + | -------- ^^ ^^^^^^^^^^ + | | + | unsatisfied trait bound introduced here +note: required by a bound in `want` + --> $DIR/blame-trait-error.rs:25:12 + | +LL | fn want<V: T1>(_x: V) {} + | ^^ required by this bound in `want` + +error[E0277]: `Q` is not an iterator + --> $DIR/blame-trait-error.rs:59:15 + | +LL | want(Some(q)); + | ---- ^ `Q` is not an iterator + | | + | required by a bound introduced by this call + | +note: required for `Option<Q>` to implement `T1` + --> $DIR/blame-trait-error.rs:21:20 + | +LL | impl<It: Iterator> T1 for Option<It> {} + | -------- ^^ ^^^^^^^^^^ + | | + | unsatisfied trait bound introduced here +note: required by a bound in `want` + --> $DIR/blame-trait-error.rs:25:12 + | +LL | fn want<V: T1>(_x: V) {} + | ^^ required by this bound in `want` +help: consider restricting type parameter `Q` + | +LL | fn example<Q: std::iter::Iterator>(q: Q) { + | +++++++++++++++++++++ + +error[E0277]: `Q` is not an iterator + --> $DIR/blame-trait-error.rs:62:16 + | +LL | want(&Some(q)); + | ---- ^ `Q` is not an iterator + | | + | required by a bound introduced by this call + | +note: required for `Option<Q>` to implement `T1` + --> $DIR/blame-trait-error.rs:21:20 + | +LL | impl<It: Iterator> T1 for Option<It> {} + | -------- ^^ ^^^^^^^^^^ + | | + | unsatisfied trait bound introduced here + = note: 1 redundant requirement hidden + = note: required for `&Option<Q>` to implement `T1` +note: required by a bound in `want` + --> $DIR/blame-trait-error.rs:25:12 + | +LL | fn want<V: T1>(_x: V) {} + | ^^ required by this bound in `want` +help: consider restricting type parameter `Q` + | +LL | fn example<Q: std::iter::Iterator>(q: Q) { + | +++++++++++++++++++++ + +error[E0277]: the trait bound `Q: T3` is not satisfied + --> $DIR/blame-trait-error.rs:65:45 + | +LL | want(&ExampleTuple::ExampleTupleVariant(q)); + | ---- ^ the trait `T3` is not implemented for `Q` + | | + | required by a bound introduced by this call + | +note: required for `ExampleTuple<Q>` to implement `T1` + --> $DIR/blame-trait-error.rs:35:9 + | +LL | impl<A> T1 for ExampleTuple<A> where A: T3 {} + | ^^ ^^^^^^^^^^^^^^^ -- unsatisfied trait bound introduced here + = note: 1 redundant requirement hidden + = note: required for `&ExampleTuple<Q>` to implement `T1` +note: required by a bound in `want` + --> $DIR/blame-trait-error.rs:25:12 + | +LL | fn want<V: T1>(_x: V) {} + | ^^ required by this bound in `want` +help: consider restricting type parameter `Q` + | +LL | fn example<Q: T3>(q: Q) { + | ++++ + +error[E0277]: the trait bound `Q: T3` is not satisfied + --> $DIR/blame-trait-error.rs:68:31 + | +LL | want(&ExampleTupleVariant(q)); + | ---- ^ the trait `T3` is not implemented for `Q` + | | + | required by a bound introduced by this call + | +note: required for `ExampleTuple<Q>` to implement `T1` + --> $DIR/blame-trait-error.rs:35:9 + | +LL | impl<A> T1 for ExampleTuple<A> where A: T3 {} + | ^^ ^^^^^^^^^^^^^^^ -- unsatisfied trait bound introduced here + = note: 1 redundant requirement hidden + = note: required for `&ExampleTuple<Q>` to implement `T1` +note: required by a bound in `want` + --> $DIR/blame-trait-error.rs:25:12 + | +LL | fn want<V: T1>(_x: V) {} + | ^^ required by this bound in `want` +help: consider restricting type parameter `Q` + | +LL | fn example<Q: T3>(q: Q) { + | ++++ + +error[E0277]: the trait bound `Q: T3` is not satisfied + --> $DIR/blame-trait-error.rs:71:50 + | +LL | want(&ExampleOtherTuple::ExampleTupleVariant(q)); + | ---- ^ the trait `T3` is not implemented for `Q` + | | + | required by a bound introduced by this call + | +note: required for `ExampleTuple<Q>` to implement `T1` + --> $DIR/blame-trait-error.rs:35:9 + | +LL | impl<A> T1 for ExampleTuple<A> where A: T3 {} + | ^^ ^^^^^^^^^^^^^^^ -- unsatisfied trait bound introduced here + = note: 1 redundant requirement hidden + = note: required for `&ExampleTuple<Q>` to implement `T1` +note: required by a bound in `want` + --> $DIR/blame-trait-error.rs:25:12 + | +LL | fn want<V: T1>(_x: V) {} + | ^^ required by this bound in `want` +help: consider restricting type parameter `Q` + | +LL | fn example<Q: T3>(q: Q) { + | ++++ + +error[E0277]: the trait bound `Q: T3` is not satisfied + --> $DIR/blame-trait-error.rs:74:44 + | +LL | want(&ExampleDifferentTupleVariantName(q)); + | ---- ^ the trait `T3` is not implemented for `Q` + | | + | required by a bound introduced by this call + | +note: required for `ExampleTuple<Q>` to implement `T1` + --> $DIR/blame-trait-error.rs:35:9 + | +LL | impl<A> T1 for ExampleTuple<A> where A: T3 {} + | ^^ ^^^^^^^^^^^^^^^ -- unsatisfied trait bound introduced here + = note: 1 redundant requirement hidden + = note: required for `&ExampleTuple<Q>` to implement `T1` +note: required by a bound in `want` + --> $DIR/blame-trait-error.rs:25:12 + | +LL | fn want<V: T1>(_x: V) {} + | ^^ required by this bound in `want` +help: consider restricting type parameter `Q` + | +LL | fn example<Q: T3>(q: Q) { + | ++++ + +error[E0277]: the trait bound `Q: T3` is not satisfied + --> $DIR/blame-trait-error.rs:77:45 + | +LL | want(&ExampleYetAnotherTupleVariantName(q)); + | ---- ^ the trait `T3` is not implemented for `Q` + | | + | required by a bound introduced by this call + | +note: required for `ExampleTuple<Q>` to implement `T1` + --> $DIR/blame-trait-error.rs:35:9 + | +LL | impl<A> T1 for ExampleTuple<A> where A: T3 {} + | ^^ ^^^^^^^^^^^^^^^ -- unsatisfied trait bound introduced here + = note: 1 redundant requirement hidden + = note: required for `&ExampleTuple<Q>` to implement `T1` +note: required by a bound in `want` + --> $DIR/blame-trait-error.rs:25:12 + | +LL | fn want<V: T1>(_x: V) {} + | ^^ required by this bound in `want` +help: consider restricting type parameter `Q` + | +LL | fn example<Q: T3>(q: Q) { + | ++++ + +error[E0277]: the trait bound `Q: T3` is not satisfied + --> $DIR/blame-trait-error.rs:80:56 + | +LL | want(&ExampleStruct::ExampleStructVariant { field: q }); + | ---- required by a bound introduced by this call ^ the trait `T3` is not implemented for `Q` + | +note: required for `ExampleStruct<Q>` to implement `T1` + --> $DIR/blame-trait-error.rs:45:9 + | +LL | impl<A> T1 for ExampleStruct<A> where A: T3 {} + | ^^ ^^^^^^^^^^^^^^^^ -- unsatisfied trait bound introduced here + = note: 1 redundant requirement hidden + = note: required for `&ExampleStruct<Q>` to implement `T1` +note: required by a bound in `want` + --> $DIR/blame-trait-error.rs:25:12 + | +LL | fn want<V: T1>(_x: V) {} + | ^^ required by this bound in `want` +help: consider restricting type parameter `Q` + | +LL | fn example<Q: T3>(q: Q) { + | ++++ + +error[E0277]: the trait bound `Q: T3` is not satisfied + --> $DIR/blame-trait-error.rs:83:41 + | +LL | want(&ExampleStructVariant { field: q }); + | ---- ^ the trait `T3` is not implemented for `Q` + | | + | required by a bound introduced by this call + | +note: required for `ExampleStruct<Q>` to implement `T1` + --> $DIR/blame-trait-error.rs:45:9 + | +LL | impl<A> T1 for ExampleStruct<A> where A: T3 {} + | ^^ ^^^^^^^^^^^^^^^^ -- unsatisfied trait bound introduced here + = note: 1 redundant requirement hidden + = note: required for `&ExampleStruct<Q>` to implement `T1` +note: required by a bound in `want` + --> $DIR/blame-trait-error.rs:25:12 + | +LL | fn want<V: T1>(_x: V) {} + | ^^ required by this bound in `want` +help: consider restricting type parameter `Q` + | +LL | fn example<Q: T3>(q: Q) { + | ++++ + +error[E0277]: the trait bound `Q: T3` is not satisfied + --> $DIR/blame-trait-error.rs:86:61 + | +LL | want(&ExampleOtherStruct::ExampleStructVariant { field: q }); + | ---- required by a bound introduced by this call ^ the trait `T3` is not implemented for `Q` + | +note: required for `ExampleStruct<Q>` to implement `T1` + --> $DIR/blame-trait-error.rs:45:9 + | +LL | impl<A> T1 for ExampleStruct<A> where A: T3 {} + | ^^ ^^^^^^^^^^^^^^^^ -- unsatisfied trait bound introduced here + = note: 1 redundant requirement hidden + = note: required for `&ExampleStruct<Q>` to implement `T1` +note: required by a bound in `want` + --> $DIR/blame-trait-error.rs:25:12 + | +LL | fn want<V: T1>(_x: V) {} + | ^^ required by this bound in `want` +help: consider restricting type parameter `Q` + | +LL | fn example<Q: T3>(q: Q) { + | ++++ + +error[E0277]: the trait bound `Q: T3` is not satisfied + --> $DIR/blame-trait-error.rs:89:54 + | +LL | want(&ExampleDifferentStructVariantName { field: q }); + | ---- required by a bound introduced by this call ^ the trait `T3` is not implemented for `Q` + | +note: required for `ExampleStruct<Q>` to implement `T1` + --> $DIR/blame-trait-error.rs:45:9 + | +LL | impl<A> T1 for ExampleStruct<A> where A: T3 {} + | ^^ ^^^^^^^^^^^^^^^^ -- unsatisfied trait bound introduced here + = note: 1 redundant requirement hidden + = note: required for `&ExampleStruct<Q>` to implement `T1` +note: required by a bound in `want` + --> $DIR/blame-trait-error.rs:25:12 + | +LL | fn want<V: T1>(_x: V) {} + | ^^ required by this bound in `want` +help: consider restricting type parameter `Q` + | +LL | fn example<Q: T3>(q: Q) { + | ++++ + +error[E0277]: the trait bound `Q: T3` is not satisfied + --> $DIR/blame-trait-error.rs:92:55 + | +LL | want(&ExampleYetAnotherStructVariantName { field: q }); + | ---- required by a bound introduced by this call ^ the trait `T3` is not implemented for `Q` + | +note: required for `ExampleStruct<Q>` to implement `T1` + --> $DIR/blame-trait-error.rs:45:9 + | +LL | impl<A> T1 for ExampleStruct<A> where A: T3 {} + | ^^ ^^^^^^^^^^^^^^^^ -- unsatisfied trait bound introduced here + = note: 1 redundant requirement hidden + = note: required for `&ExampleStruct<Q>` to implement `T1` +note: required by a bound in `want` + --> $DIR/blame-trait-error.rs:25:12 + | +LL | fn want<V: T1>(_x: V) {} + | ^^ required by this bound in `want` +help: consider restricting type parameter `Q` + | +LL | fn example<Q: T3>(q: Q) { + | ++++ + +error[E0277]: the trait bound `Q: T3` is not satisfied + --> $DIR/blame-trait-error.rs:95:38 + | +LL | want(&ExampleActuallyTupleStruct(q, 0)); + | ---- ^ the trait `T3` is not implemented for `Q` + | | + | required by a bound introduced by this call + | +note: required for `ExampleActuallyTupleStruct<Q>` to implement `T1` + --> $DIR/blame-trait-error.rs:50:9 + | +LL | impl<A> T1 for ExampleActuallyTupleStruct<A> where A: T3 {} + | ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- unsatisfied trait bound introduced here + = note: 1 redundant requirement hidden + = note: required for `&ExampleActuallyTupleStruct<Q>` to implement `T1` +note: required by a bound in `want` + --> $DIR/blame-trait-error.rs:25:12 + | +LL | fn want<V: T1>(_x: V) {} + | ^^ required by this bound in `want` +help: consider restricting type parameter `Q` + | +LL | fn example<Q: T3>(q: Q) { + | ++++ + +error[E0277]: the trait bound `Q: T3` is not satisfied + --> $DIR/blame-trait-error.rs:98:43 + | +LL | want(&ExampleActuallyTupleStructOther(q, 0)); + | ---- ^ the trait `T3` is not implemented for `Q` + | | + | required by a bound introduced by this call + | +note: required for `ExampleActuallyTupleStruct<Q>` to implement `T1` + --> $DIR/blame-trait-error.rs:50:9 + | +LL | impl<A> T1 for ExampleActuallyTupleStruct<A> where A: T3 {} + | ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- unsatisfied trait bound introduced here + = note: 1 redundant requirement hidden + = note: required for `&ExampleActuallyTupleStruct<Q>` to implement `T1` +note: required by a bound in `want` + --> $DIR/blame-trait-error.rs:25:12 + | +LL | fn want<V: T1>(_x: V) {} + | ^^ required by this bound in `want` +help: consider restricting type parameter `Q` + | +LL | fn example<Q: T3>(q: Q) { + | ++++ + +error: aborting due to 16 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/errors/traits/blame-trait-error-spans-on-exprs.rs b/tests/ui/errors/traits/blame-trait-error-spans-on-exprs.rs new file mode 100644 index 000000000..6fea409ed --- /dev/null +++ b/tests/ui/errors/traits/blame-trait-error-spans-on-exprs.rs @@ -0,0 +1,137 @@ +// This test examines the error spans reported when a generic `impl` fails. +// For example, if a function wants an `Option<T>` where `T: Copy` but you pass `Some(vec![1, 2])`, +// then we want to point at the `vec![1, 2]` and not the `Some( ... )` expression. + +trait T1 {} +trait T2 {} +trait T3 {} +trait T4 {} + +impl T2 for i32 {} +impl T3 for i32 {} + +struct Wrapper<W> { + value: W, +} +impl<B: T2> T1 for Wrapper<B> {} + +struct Burrito<F> { + spicy: bool, + filling: F, +} +impl<A: T3> T2 for Burrito<A> {} + +struct BurritoTuple<F>(F); +impl<C: T3> T2 for BurritoTuple<C> {} + +enum BurritoKinds<G> { + SmallBurrito { spicy: bool, small_filling: G }, + LargeBurrito { spicy: bool, large_filling: G }, + MultiBurrito { first_filling: G, second_filling: G }, +} +impl<D: T3> T2 for BurritoKinds<D> {} + +struct Taco<H>(bool, H); +impl<E: T3> T2 for Taco<E> {} + +enum TacoKinds<H> { + OneTaco(bool, H), + TwoTacos(bool, H, H), +} +impl<F: T3> T2 for TacoKinds<F> {} + +struct GenericBurrito<Spiciness, Filling> { + spiciness: Spiciness, + filling: Filling, +} +impl<X, Y: T3> T2 for GenericBurrito<X, Y> {} +struct NotSpicy; + +impl<A: T3, B: T3> T2 for (A, B) {} +impl<A: T2, B: T2> T1 for (A, B) {} + +fn want<V: T1>(_x: V) {} + +// Some more-complex examples: +type AliasBurrito<T> = GenericBurrito<T, T>; + +// The following example is fairly confusing. The idea is that we want to "misdirect" the location +// of the error. + +struct Two<A, B> { + a: A, + b: B, +} + +impl<X, Y: T1, Z> T1 for Two<Two<X, Y>, Z> {} + +struct DoubleWrapper<T> { + item: Wrapper<T>, +} + +impl<T: T1> T1 for DoubleWrapper<T> {} + +impl<'a, T: T2> T1 for &'a T {} + +fn example<Q>(q: Q) { + // In each of the following examples, we expect the error span to point at the 'q' variable, + // since the missing constraint is `Q: T3`. + + // Verifies for struct: + want(Wrapper { value: Burrito { spicy: false, filling: q } }); + //~^ ERROR the trait bound `Q: T3` is not satisfied [E0277] + + // Verifies for enum with named fields in variant: + want(Wrapper { value: BurritoKinds::SmallBurrito { spicy: true, small_filling: q } }); + //~^ ERROR the trait bound `Q: T3` is not satisfied [E0277] + + // Verifies for tuple struct: + want(Wrapper { value: Taco(false, q) }); + //~^ ERROR the trait bound `Q: T3` is not satisfied [E0277] + + // Verifies for tuple enum variant: + want(Wrapper { value: TacoKinds::OneTaco(false, q) }); + //~^ ERROR the trait bound `Q: T3` is not satisfied [E0277] + + // Verifies for generic type with multiple parameters: + want(Wrapper { value: GenericBurrito { spiciness: NotSpicy, filling: q } }); + //~^ ERROR the trait bound `Q: T3` is not satisfied [E0277] + + // Verifies for tuple: + want((3, q)); + //~^ ERROR the trait bound `Q: T2` is not satisfied [E0277] + + // Verifies for nested tuple: + want(Wrapper { value: (3, q) }); + //~^ ERROR the trait bound `Q: T3` is not satisfied [E0277] + + // Verifies for nested tuple: + want(((3, q), 5)); + //~^ ERROR the trait bound `Q: T3` is not satisfied [E0277] + + want(DoubleWrapper { item: Wrapper { value: q } }); + //~^ ERROR the trait bound `Q: T1` is not satisfied [E0277] + + want(DoubleWrapper { item: Wrapper { value: DoubleWrapper { item: Wrapper { value: q } } } }); + //~^ ERROR the trait bound `Q: T1` is not satisfied [E0277] + + // Verifies for type alias to struct: + want(Wrapper { value: AliasBurrito { spiciness: q, filling: q } }); + //~^ ERROR the trait bound `Q: T3` is not satisfied [E0277] + + want(Two { a: Two { a: (), b: q }, b: () }); + //~^ ERROR the trait bound `Q: T1` is not satisfied [E0277] + + // We *should* blame the 'q'. + // FIXME: Right now, the wrong field is blamed. + want( + Two { a: Two { a: (), b: Two { a: Two { a: (), b: q }, b: () } }, b: () }, + //~^ ERROR the trait bound `Q: T1` is not satisfied [E0277] + ); + + // Verifies for reference: + want(&Burrito { spicy: false, filling: q }); + //~^ ERROR the trait bound `Q: T3` is not satisfied [E0277] +} + +fn main() {} diff --git a/tests/ui/errors/traits/blame-trait-error-spans-on-exprs.stderr b/tests/ui/errors/traits/blame-trait-error-spans-on-exprs.stderr new file mode 100644 index 000000000..b6a24e12b --- /dev/null +++ b/tests/ui/errors/traits/blame-trait-error-spans-on-exprs.stderr @@ -0,0 +1,412 @@ +error[E0277]: the trait bound `Q: T3` is not satisfied + --> $DIR/blame-trait-error-spans-on-exprs.rs:81:60 + | +LL | want(Wrapper { value: Burrito { spicy: false, filling: q } }); + | ---- required by a bound introduced by this call ^ the trait `T3` is not implemented for `Q` + | +note: required for `Burrito<Q>` to implement `T2` + --> $DIR/blame-trait-error-spans-on-exprs.rs:22:13 + | +LL | impl<A: T3> T2 for Burrito<A> {} + | -- ^^ ^^^^^^^^^^ + | | + | unsatisfied trait bound introduced here +note: required for `Wrapper<Burrito<Q>>` to implement `T1` + --> $DIR/blame-trait-error-spans-on-exprs.rs:16:13 + | +LL | impl<B: T2> T1 for Wrapper<B> {} + | -- ^^ ^^^^^^^^^^ + | | + | unsatisfied trait bound introduced here +note: required by a bound in `want` + --> $DIR/blame-trait-error-spans-on-exprs.rs:53:12 + | +LL | fn want<V: T1>(_x: V) {} + | ^^ required by this bound in `want` +help: consider restricting type parameter `Q` + | +LL | fn example<Q: T3>(q: Q) { + | ++++ + +error[E0277]: the trait bound `Q: T3` is not satisfied + --> $DIR/blame-trait-error-spans-on-exprs.rs:85:84 + | +LL | want(Wrapper { value: BurritoKinds::SmallBurrito { spicy: true, small_filling: q } }); + | ---- required by a bound introduced by this call ^ the trait `T3` is not implemented for `Q` + | +note: required for `BurritoKinds<Q>` to implement `T2` + --> $DIR/blame-trait-error-spans-on-exprs.rs:32:13 + | +LL | impl<D: T3> T2 for BurritoKinds<D> {} + | -- ^^ ^^^^^^^^^^^^^^^ + | | + | unsatisfied trait bound introduced here +note: required for `Wrapper<BurritoKinds<Q>>` to implement `T1` + --> $DIR/blame-trait-error-spans-on-exprs.rs:16:13 + | +LL | impl<B: T2> T1 for Wrapper<B> {} + | -- ^^ ^^^^^^^^^^ + | | + | unsatisfied trait bound introduced here +note: required by a bound in `want` + --> $DIR/blame-trait-error-spans-on-exprs.rs:53:12 + | +LL | fn want<V: T1>(_x: V) {} + | ^^ required by this bound in `want` +help: consider restricting type parameter `Q` + | +LL | fn example<Q: T3>(q: Q) { + | ++++ + +error[E0277]: the trait bound `Q: T3` is not satisfied + --> $DIR/blame-trait-error-spans-on-exprs.rs:89:39 + | +LL | want(Wrapper { value: Taco(false, q) }); + | ---- ^ the trait `T3` is not implemented for `Q` + | | + | required by a bound introduced by this call + | +note: required for `Taco<Q>` to implement `T2` + --> $DIR/blame-trait-error-spans-on-exprs.rs:35:13 + | +LL | impl<E: T3> T2 for Taco<E> {} + | -- ^^ ^^^^^^^ + | | + | unsatisfied trait bound introduced here +note: required for `Wrapper<Taco<Q>>` to implement `T1` + --> $DIR/blame-trait-error-spans-on-exprs.rs:16:13 + | +LL | impl<B: T2> T1 for Wrapper<B> {} + | -- ^^ ^^^^^^^^^^ + | | + | unsatisfied trait bound introduced here +note: required by a bound in `want` + --> $DIR/blame-trait-error-spans-on-exprs.rs:53:12 + | +LL | fn want<V: T1>(_x: V) {} + | ^^ required by this bound in `want` +help: consider restricting type parameter `Q` + | +LL | fn example<Q: T3>(q: Q) { + | ++++ + +error[E0277]: the trait bound `Q: T3` is not satisfied + --> $DIR/blame-trait-error-spans-on-exprs.rs:93:53 + | +LL | want(Wrapper { value: TacoKinds::OneTaco(false, q) }); + | ---- ^ the trait `T3` is not implemented for `Q` + | | + | required by a bound introduced by this call + | +note: required for `TacoKinds<Q>` to implement `T2` + --> $DIR/blame-trait-error-spans-on-exprs.rs:41:13 + | +LL | impl<F: T3> T2 for TacoKinds<F> {} + | -- ^^ ^^^^^^^^^^^^ + | | + | unsatisfied trait bound introduced here +note: required for `Wrapper<TacoKinds<Q>>` to implement `T1` + --> $DIR/blame-trait-error-spans-on-exprs.rs:16:13 + | +LL | impl<B: T2> T1 for Wrapper<B> {} + | -- ^^ ^^^^^^^^^^ + | | + | unsatisfied trait bound introduced here +note: required by a bound in `want` + --> $DIR/blame-trait-error-spans-on-exprs.rs:53:12 + | +LL | fn want<V: T1>(_x: V) {} + | ^^ required by this bound in `want` +help: consider restricting type parameter `Q` + | +LL | fn example<Q: T3>(q: Q) { + | ++++ + +error[E0277]: the trait bound `Q: T3` is not satisfied + --> $DIR/blame-trait-error-spans-on-exprs.rs:97:74 + | +LL | want(Wrapper { value: GenericBurrito { spiciness: NotSpicy, filling: q } }); + | ---- required by a bound introduced by this call ^ the trait `T3` is not implemented for `Q` + | +note: required for `GenericBurrito<NotSpicy, Q>` to implement `T2` + --> $DIR/blame-trait-error-spans-on-exprs.rs:47:16 + | +LL | impl<X, Y: T3> T2 for GenericBurrito<X, Y> {} + | -- ^^ ^^^^^^^^^^^^^^^^^^^^ + | | + | unsatisfied trait bound introduced here +note: required for `Wrapper<GenericBurrito<NotSpicy, Q>>` to implement `T1` + --> $DIR/blame-trait-error-spans-on-exprs.rs:16:13 + | +LL | impl<B: T2> T1 for Wrapper<B> {} + | -- ^^ ^^^^^^^^^^ + | | + | unsatisfied trait bound introduced here +note: required by a bound in `want` + --> $DIR/blame-trait-error-spans-on-exprs.rs:53:12 + | +LL | fn want<V: T1>(_x: V) {} + | ^^ required by this bound in `want` +help: consider restricting type parameter `Q` + | +LL | fn example<Q: T3>(q: Q) { + | ++++ + +error[E0277]: the trait bound `Q: T2` is not satisfied + --> $DIR/blame-trait-error-spans-on-exprs.rs:101:14 + | +LL | want((3, q)); + | ---- ^ the trait `T2` is not implemented for `Q` + | | + | required by a bound introduced by this call + | +note: required for `(i32, Q)` to implement `T1` + --> $DIR/blame-trait-error-spans-on-exprs.rs:51:20 + | +LL | impl<A: T2, B: T2> T1 for (A, B) {} + | -- ^^ ^^^^^^ + | | + | unsatisfied trait bound introduced here +note: required by a bound in `want` + --> $DIR/blame-trait-error-spans-on-exprs.rs:53:12 + | +LL | fn want<V: T1>(_x: V) {} + | ^^ required by this bound in `want` +help: consider restricting type parameter `Q` + | +LL | fn example<Q: T2>(q: Q) { + | ++++ + +error[E0277]: the trait bound `Q: T3` is not satisfied + --> $DIR/blame-trait-error-spans-on-exprs.rs:105:31 + | +LL | want(Wrapper { value: (3, q) }); + | ---- ^ the trait `T3` is not implemented for `Q` + | | + | required by a bound introduced by this call + | +note: required for `(i32, Q)` to implement `T2` + --> $DIR/blame-trait-error-spans-on-exprs.rs:50:20 + | +LL | impl<A: T3, B: T3> T2 for (A, B) {} + | -- ^^ ^^^^^^ + | | + | unsatisfied trait bound introduced here +note: required for `Wrapper<(i32, Q)>` to implement `T1` + --> $DIR/blame-trait-error-spans-on-exprs.rs:16:13 + | +LL | impl<B: T2> T1 for Wrapper<B> {} + | -- ^^ ^^^^^^^^^^ + | | + | unsatisfied trait bound introduced here +note: required by a bound in `want` + --> $DIR/blame-trait-error-spans-on-exprs.rs:53:12 + | +LL | fn want<V: T1>(_x: V) {} + | ^^ required by this bound in `want` +help: consider restricting type parameter `Q` + | +LL | fn example<Q: T3>(q: Q) { + | ++++ + +error[E0277]: the trait bound `Q: T3` is not satisfied + --> $DIR/blame-trait-error-spans-on-exprs.rs:109:15 + | +LL | want(((3, q), 5)); + | ---- ^ the trait `T3` is not implemented for `Q` + | | + | required by a bound introduced by this call + | +note: required for `(i32, Q)` to implement `T2` + --> $DIR/blame-trait-error-spans-on-exprs.rs:50:20 + | +LL | impl<A: T3, B: T3> T2 for (A, B) {} + | -- ^^ ^^^^^^ + | | + | unsatisfied trait bound introduced here +note: required for `((i32, Q), i32)` to implement `T1` + --> $DIR/blame-trait-error-spans-on-exprs.rs:51:20 + | +LL | impl<A: T2, B: T2> T1 for (A, B) {} + | -- ^^ ^^^^^^ + | | + | unsatisfied trait bound introduced here +note: required by a bound in `want` + --> $DIR/blame-trait-error-spans-on-exprs.rs:53:12 + | +LL | fn want<V: T1>(_x: V) {} + | ^^ required by this bound in `want` +help: consider restricting type parameter `Q` + | +LL | fn example<Q: T3>(q: Q) { + | ++++ + +error[E0277]: the trait bound `Q: T1` is not satisfied + --> $DIR/blame-trait-error-spans-on-exprs.rs:112:49 + | +LL | want(DoubleWrapper { item: Wrapper { value: q } }); + | ---- ^ the trait `T1` is not implemented for `Q` + | | + | required by a bound introduced by this call + | +note: required for `DoubleWrapper<Q>` to implement `T1` + --> $DIR/blame-trait-error-spans-on-exprs.rs:72:13 + | +LL | impl<T: T1> T1 for DoubleWrapper<T> {} + | -- ^^ ^^^^^^^^^^^^^^^^ + | | + | unsatisfied trait bound introduced here +note: required by a bound in `want` + --> $DIR/blame-trait-error-spans-on-exprs.rs:53:12 + | +LL | fn want<V: T1>(_x: V) {} + | ^^ required by this bound in `want` +help: consider restricting type parameter `Q` + | +LL | fn example<Q: T1>(q: Q) { + | ++++ + +error[E0277]: the trait bound `Q: T1` is not satisfied + --> $DIR/blame-trait-error-spans-on-exprs.rs:115:88 + | +LL | want(DoubleWrapper { item: Wrapper { value: DoubleWrapper { item: Wrapper { value: q } } } }); + | ---- required by a bound introduced by this call ^ the trait `T1` is not implemented for `Q` + | +note: required for `DoubleWrapper<Q>` to implement `T1` + --> $DIR/blame-trait-error-spans-on-exprs.rs:72:13 + | +LL | impl<T: T1> T1 for DoubleWrapper<T> {} + | -- ^^ ^^^^^^^^^^^^^^^^ + | | + | unsatisfied trait bound introduced here + = note: 1 redundant requirement hidden + = note: required for `DoubleWrapper<DoubleWrapper<Q>>` to implement `T1` +note: required by a bound in `want` + --> $DIR/blame-trait-error-spans-on-exprs.rs:53:12 + | +LL | fn want<V: T1>(_x: V) {} + | ^^ required by this bound in `want` +help: consider restricting type parameter `Q` + | +LL | fn example<Q: T1>(q: Q) { + | ++++ + +error[E0277]: the trait bound `Q: T3` is not satisfied + --> $DIR/blame-trait-error-spans-on-exprs.rs:119:27 + | +LL | want(Wrapper { value: AliasBurrito { spiciness: q, filling: q } }); + | ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `T3` is not implemented for `Q` + | | + | required by a bound introduced by this call + | +note: required for `GenericBurrito<Q, Q>` to implement `T2` + --> $DIR/blame-trait-error-spans-on-exprs.rs:47:16 + | +LL | impl<X, Y: T3> T2 for GenericBurrito<X, Y> {} + | -- ^^ ^^^^^^^^^^^^^^^^^^^^ + | | + | unsatisfied trait bound introduced here +note: required for `Wrapper<GenericBurrito<Q, Q>>` to implement `T1` + --> $DIR/blame-trait-error-spans-on-exprs.rs:16:13 + | +LL | impl<B: T2> T1 for Wrapper<B> {} + | -- ^^ ^^^^^^^^^^ + | | + | unsatisfied trait bound introduced here +note: required by a bound in `want` + --> $DIR/blame-trait-error-spans-on-exprs.rs:53:12 + | +LL | fn want<V: T1>(_x: V) {} + | ^^ required by this bound in `want` +help: consider restricting type parameter `Q` + | +LL | fn example<Q: T3>(q: Q) { + | ++++ + +error[E0277]: the trait bound `Q: T1` is not satisfied + --> $DIR/blame-trait-error-spans-on-exprs.rs:122:35 + | +LL | want(Two { a: Two { a: (), b: q }, b: () }); + | ---- ^ the trait `T1` is not implemented for `Q` + | | + | required by a bound introduced by this call + | +note: required for `Two<Two<(), Q>, ()>` to implement `T1` + --> $DIR/blame-trait-error-spans-on-exprs.rs:66:19 + | +LL | impl<X, Y: T1, Z> T1 for Two<Two<X, Y>, Z> {} + | -- ^^ ^^^^^^^^^^^^^^^^^ + | | + | unsatisfied trait bound introduced here +note: required by a bound in `want` + --> $DIR/blame-trait-error-spans-on-exprs.rs:53:12 + | +LL | fn want<V: T1>(_x: V) {} + | ^^ required by this bound in `want` +help: consider restricting type parameter `Q` + | +LL | fn example<Q: T1>(q: Q) { + | ++++ + +error[E0277]: the trait bound `Q: T1` is not satisfied + --> $DIR/blame-trait-error-spans-on-exprs.rs:128:59 + | +LL | want( + | ---- required by a bound introduced by this call +LL | Two { a: Two { a: (), b: Two { a: Two { a: (), b: q }, b: () } }, b: () }, + | ^ the trait `T1` is not implemented for `Q` + | +note: required for `Two<Two<(), Q>, ()>` to implement `T1` + --> $DIR/blame-trait-error-spans-on-exprs.rs:66:19 + | +LL | impl<X, Y: T1, Z> T1 for Two<Two<X, Y>, Z> {} + | -- ^^ ^^^^^^^^^^^^^^^^^ + | | + | unsatisfied trait bound introduced here + = note: 1 redundant requirement hidden + = note: required for `Two<Two<(), Two<Two<(), Q>, ()>>, ()>` to implement `T1` +note: required by a bound in `want` + --> $DIR/blame-trait-error-spans-on-exprs.rs:53:12 + | +LL | fn want<V: T1>(_x: V) {} + | ^^ required by this bound in `want` +help: consider restricting type parameter `Q` + | +LL | fn example<Q: T1>(q: Q) { + | ++++ + +error[E0277]: the trait bound `Q: T3` is not satisfied + --> $DIR/blame-trait-error-spans-on-exprs.rs:133:44 + | +LL | want(&Burrito { spicy: false, filling: q }); + | ---- ^ the trait `T3` is not implemented for `Q` + | | + | required by a bound introduced by this call + | +note: required for `Burrito<Q>` to implement `T2` + --> $DIR/blame-trait-error-spans-on-exprs.rs:22:13 + | +LL | impl<A: T3> T2 for Burrito<A> {} + | -- ^^ ^^^^^^^^^^ + | | + | unsatisfied trait bound introduced here +note: required for `&Burrito<Q>` to implement `T1` + --> $DIR/blame-trait-error-spans-on-exprs.rs:74:17 + | +LL | impl<'a, T: T2> T1 for &'a T {} + | -- ^^ ^^^^^ + | | + | unsatisfied trait bound introduced here +note: required by a bound in `want` + --> $DIR/blame-trait-error-spans-on-exprs.rs:53:12 + | +LL | fn want<V: T1>(_x: V) {} + | ^^ required by this bound in `want` +help: consider restricting type parameter `Q` + | +LL | fn example<Q: T3>(q: Q) { + | ++++ + +error: aborting due to 14 previous errors + +For more information about this error, try `rustc --explain E0277`. |