diff options
| author | Matthew Jasper <mjjasper1@gmail.com> | 2020-06-27 21:36:35 +0100 |
|---|---|---|
| committer | Matthew Jasper <mjjasper1@gmail.com> | 2020-10-06 11:19:29 +0100 |
| commit | f958e6c24615c4b1f1e77b0ee3d4f32383fb3617 (patch) | |
| tree | d9668ba16b66d59b026e9d936803dd92fdff6fec /src | |
| parent | d297147e620431dacfd4bbe90c6f82911b7d72c5 (diff) | |
| download | rust-f958e6c24615c4b1f1e77b0ee3d4f32383fb3617.tar.gz rust-f958e6c24615c4b1f1e77b0ee3d4f32383fb3617.zip | |
Separate bounds and predicates for associated/opaque types
Diffstat (limited to 'src')
95 files changed, 698 insertions, 978 deletions
diff --git a/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.rs b/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.rs index 556d8900d1a..4c78f17a6a3 100644 --- a/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.rs +++ b/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.rs @@ -23,19 +23,17 @@ trait Case1 { Debug > > + Sync>; + //~^^^^^^ ERROR `<<Self as Case1>::C as std::iter::Iterator>::Item` is not an iterator + //~^^^^^^ ERROR `<<Self as Case1>::C as std::iter::Iterator>::Item` cannot be sent between threads safely + //~^^^ ERROR `<<Self as Case1>::C as std::iter::Iterator>::Item` cannot be shared between threads safely } pub struct S1; impl Case1 for S1 { -//~^ ERROR `<L1 as Lam<&'a u8>>::App` doesn't implement `Debug` [E0277] type C = Once<Once<L1>>; } fn assume_case1<T: Case1>() { -//~^ ERROR `<_ as Lam<&'a u8>>::App` doesn't implement `Debug` [E0277] -//~| ERROR `<<T as Case1>::C as Iterator>::Item` is not an iterator [E0277] -//~| ERROR `<<T as Case1>::C as Iterator>::Item` cannot be sent between threads safely [E0277] -//~| ERROR `<<T as Case1>::C as Iterator>::Item` cannot be shared between threads safely [E0277] fn assert_a<_0, A>() where A: Iterator<Item = _0>, _0: Debug {} assert_a::<_, T::A>(); diff --git a/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr b/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr index 49b5e7fbb89..20a087a85a6 100644 --- a/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr +++ b/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr @@ -1,79 +1,54 @@ -error[E0277]: `<L1 as Lam<&'a u8>>::App` doesn't implement `Debug` - --> $DIR/bad-bounds-on-assoc-in-trait.rs:29:6 - | -LL | trait Case1 { - | ----- required by a bound in this -... -LL | Debug - | ----- required by this bound in `Case1` -... -LL | impl Case1 for S1 { - | ^^^^^ `<L1 as Lam<&'a u8>>::App` cannot be formatted using `{:?}` because it doesn't implement `Debug` - | - = help: the trait `for<'a> Debug` is not implemented for `<L1 as Lam<&'a u8>>::App` - -error[E0277]: `<<T as Case1>::C as Iterator>::Item` is not an iterator - --> $DIR/bad-bounds-on-assoc-in-trait.rs:34:20 - | -LL | fn assume_case1<T: Case1>() { - | ^^^^^ `<<T as Case1>::C as Iterator>::Item` is not an iterator - | - = help: the trait `Iterator` is not implemented for `<<T as Case1>::C as Iterator>::Item` +error[E0277]: `<<Self as Case1>::C as std::iter::Iterator>::Item` is not an iterator + --> $DIR/bad-bounds-on-assoc-in-trait.rs:22:5 + | +LL | / type C: Clone + Iterator<Item: +LL | | Send + Iterator<Item: +LL | | for<'a> Lam<&'a u8, App: +LL | | Debug +LL | | > +LL | | > + Sync>; + | |__________________^ `<<Self as Case1>::C as std::iter::Iterator>::Item` is not an iterator + | + = help: the trait `std::iter::Iterator` is not implemented for `<<Self as Case1>::C as std::iter::Iterator>::Item` help: consider further restricting the associated type | -LL | fn assume_case1<T: Case1>() where <<T as Case1>::C as Iterator>::Item: Iterator { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | trait Case1 where <<Self as Case1>::C as std::iter::Iterator>::Item: std::iter::Iterator { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0277]: `<<T as Case1>::C as Iterator>::Item` cannot be sent between threads safely - --> $DIR/bad-bounds-on-assoc-in-trait.rs:34:20 +error[E0277]: `<<Self as Case1>::C as std::iter::Iterator>::Item` cannot be sent between threads safely + --> $DIR/bad-bounds-on-assoc-in-trait.rs:23:9 | -LL | trait Case1 { - | ----- required by a bound in this -LL | type C: Clone + Iterator<Item: LL | Send + Iterator<Item: - | ---- required by this bound in `Case1` -... -LL | fn assume_case1<T: Case1>() { - | ^^^^^ `<<T as Case1>::C as Iterator>::Item` cannot be sent between threads safely + | ^^^^ `<<Self as Case1>::C as std::iter::Iterator>::Item` cannot be sent between threads safely | - = help: the trait `Send` is not implemented for `<<T as Case1>::C as Iterator>::Item` + ::: $SRC_DIR/libcore/marker.rs:LL:COL + | +LL | pub unsafe auto trait Send { + | -------------------------- required by this bound in `std::marker::Send` + | + = help: the trait `std::marker::Send` is not implemented for `<<Self as Case1>::C as std::iter::Iterator>::Item` help: consider further restricting the associated type | -LL | fn assume_case1<T: Case1>() where <<T as Case1>::C as Iterator>::Item: Send { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | trait Case1 where <<Self as Case1>::C as std::iter::Iterator>::Item: std::marker::Send { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0277]: `<<T as Case1>::C as Iterator>::Item` cannot be shared between threads safely - --> $DIR/bad-bounds-on-assoc-in-trait.rs:34:20 +error[E0277]: `<<Self as Case1>::C as std::iter::Iterator>::Item` cannot be shared between threads safely + --> $DIR/bad-bounds-on-assoc-in-trait.rs:27:13 | -LL | trait Case1 { - | ----- required by a bound in this -... LL | > + Sync>; - | ---- required by this bound in `Case1` -... -LL | fn assume_case1<T: Case1>() { - | ^^^^^ `<<T as Case1>::C as Iterator>::Item` cannot be shared between threads safely + | ^^^^ `<<Self as Case1>::C as std::iter::Iterator>::Item` cannot be shared between threads safely | - = help: the trait `Sync` is not implemented for `<<T as Case1>::C as Iterator>::Item` -help: consider further restricting the associated type + ::: $SRC_DIR/libcore/marker.rs:LL:COL | -LL | fn assume_case1<T: Case1>() where <<T as Case1>::C as Iterator>::Item: Sync { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0277]: `<_ as Lam<&'a u8>>::App` doesn't implement `Debug` - --> $DIR/bad-bounds-on-assoc-in-trait.rs:34:20 +LL | pub unsafe auto trait Sync { + | -------------------------- required by this bound in `std::marker::Sync` | -LL | trait Case1 { - | ----- required by a bound in this -... -LL | Debug - | ----- required by this bound in `Case1` -... -LL | fn assume_case1<T: Case1>() { - | ^^^^^ `<_ as Lam<&'a u8>>::App` cannot be formatted using `{:?}` because it doesn't implement `Debug` + = help: the trait `std::marker::Sync` is not implemented for `<<Self as Case1>::C as std::iter::Iterator>::Item` +help: consider further restricting the associated type | - = help: the trait `for<'a> Debug` is not implemented for `<_ as Lam<&'a u8>>::App` +LL | trait Case1 where <<Self as Case1>::C as std::iter::Iterator>::Item: std::marker::Sync { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 5 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.rs b/src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.rs index ceca54b7cd7..4025e0fc5e1 100644 --- a/src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.rs +++ b/src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.rs @@ -1,4 +1,4 @@ -// check-pass +// ignore-tidy-linelength #![feature(associated_type_bounds)] @@ -18,6 +18,7 @@ impl<'a, 'b> Lam<&'a &'b u8> for L2 { type App = u8; } trait Case1 { type A: Iterator<Item: Debug>; + //~^ ERROR `<<Self as Case1>::A as std::iter::Iterator>::Item` doesn't implement `std::fmt::Debug` type B: Iterator<Item: 'static>; } @@ -30,7 +31,11 @@ impl Case1 for S1 { // Ensure we don't have opaque `impl Trait` desugaring: +// What is this supposed to mean? Rustc currently lowers `: Default` in the +// bounds of `Out`, but trait selection can't find the bound since it applies +// to a type other than `Self::Out`. pub trait Foo { type Out: Baz<Assoc: Default>; } +//~^ ERROR trait bound `<<Self as Foo>::Out as Baz>::Assoc: std::default::Default` is not satisfied pub trait Baz { type Assoc; } #[derive(Default)] diff --git a/src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.stderr b/src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.stderr new file mode 100644 index 00000000000..2be37285e29 --- /dev/null +++ b/src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.stderr @@ -0,0 +1,36 @@ +error[E0277]: `<<Self as Case1>::A as std::iter::Iterator>::Item` doesn't implement `std::fmt::Debug` + --> $DIR/bounds-on-assoc-in-trait.rs:20:28 + | +LL | type A: Iterator<Item: Debug>; + | ^^^^^ `<<Self as Case1>::A as std::iter::Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` + | + ::: $SRC_DIR/libcore/fmt/mod.rs:LL:COL + | +LL | pub trait Debug { + | --------------- required by this bound in `std::fmt::Debug` + | + = help: the trait `std::fmt::Debug` is not implemented for `<<Self as Case1>::A as std::iter::Iterator>::Item` +help: consider further restricting the associated type + | +LL | trait Case1 where <<Self as Case1>::A as std::iter::Iterator>::Item: std::fmt::Debug { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `<<Self as Foo>::Out as Baz>::Assoc: std::default::Default` is not satisfied + --> $DIR/bounds-on-assoc-in-trait.rs:37:38 + | +LL | pub trait Foo { type Out: Baz<Assoc: Default>; } + | ^^^^^^^ the trait `std::default::Default` is not implemented for `<<Self as Foo>::Out as Baz>::Assoc` + | + ::: $SRC_DIR/libcore/default.rs:LL:COL + | +LL | pub trait Default: Sized { + | ------------------------ required by this bound in `std::default::Default` + | +help: consider further restricting the associated type + | +LL | pub trait Foo where <<Self as Foo>::Out as Baz>::Assoc: std::default::Default { type Out: Baz<Assoc: Default>; } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/associated-type-bounds/duplicate.stderr b/src/test/ui/associated-type-bounds/duplicate.stderr index 77cd88e524f..b5941fb80c7 100644 --- a/src/test/ui/associated-type-bounds/duplicate.stderr +++ b/src/test/ui/associated-type-bounds/duplicate.stderr @@ -512,31 +512,7 @@ LL | trait TRSW3 where Self: Iterator<Item: 'static, Item: 'static> {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:145:43 - | -LL | trait TRA1 { type A: Iterator<Item: Copy, Item: Send>; } - | ---------- ^^^^^^^^^^ re-bound here - | | - | `Item` bound here first - -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:147:43 - | -LL | trait TRA2 { type A: Iterator<Item: Copy, Item: Copy>; } - | ---------- ^^^^^^^^^^ re-bound here - | | - | `Item` bound here first - -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:149:46 - | -LL | trait TRA3 { type A: Iterator<Item: 'static, Item: 'static>; } - | ------------- ^^^^^^^^^^^^^ re-bound here - | | - | `Item` bound here first - -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:152:40 + --> $DIR/duplicate.rs:167:40 | LL | type TADyn1 = dyn Iterator<Item: Copy, Item: Send>; | ---------- ^^^^^^^^^^ re-bound here diff --git a/src/test/ui/associated-types/associated-types-unconstrained.stderr b/src/test/ui/associated-types/associated-types-unconstrained.stderr index 2914a7f868b..9d084203e3a 100644 --- a/src/test/ui/associated-types/associated-types-unconstrained.stderr +++ b/src/test/ui/associated-types/associated-types-unconstrained.stderr @@ -1,11 +1,14 @@ -error[E0284]: type annotations needed +error[E0283]: type annotations needed --> $DIR/associated-types-unconstrained.rs:14:20 | +LL | fn bar() -> isize; + | ------------------ required by `Foo::bar` +... LL | let x: isize = Foo::bar(); | ^^^^^^^^ cannot infer type | - = note: cannot satisfy `<_ as Foo>::A == _` + = note: cannot satisfy `_: Foo` error: aborting due to previous error -For more information about this error, try `rustc --explain E0284`. +For more information about this error, try `rustc --explain E0283`. diff --git a/src/test/ui/associated-types/defaults-cyclic-fail-1.rs b/src/test/ui/associated-types/defaults-cyclic-fail-1.rs index fa75f6bc152..afb2b3df716 100644 --- a/src/test/ui/associated-types/defaults-cyclic-fail-1.rs +++ b/src/test/ui/associated-types/defaults-cyclic-fail-1.rs @@ -6,11 +6,8 @@ trait Tr { type B = Self::A; } -// ...but is an error in any impl that doesn't override at least one of the defaults impl Tr for () {} -//~^ ERROR overflow evaluating the requirement -// As soon as at least one is redefined, it works: impl Tr for u8 { type A = u8; } @@ -24,16 +21,14 @@ impl Tr for u32 { type B = u8; } -// ...but only if this actually breaks the cycle +// ...but not in an impl that redefines one of the types. impl Tr for bool { - //~^ ERROR type mismatch resolving `<bool as Tr>::B == _` type A = Box<Self::B>; //~^ ERROR type mismatch resolving `<bool as Tr>::B == _` } // (the error is shown twice for some reason) impl Tr for usize { - //~^ ERROR type mismatch resolving `<usize as Tr>::B == _` type B = &'static Self::A; //~^ ERROR type mismatch resolving `<usize as Tr>::A == _` } diff --git a/src/test/ui/associated-types/defaults-cyclic-fail-1.stderr b/src/test/ui/associated-types/defaults-cyclic-fail-1.stderr index 0aea30b1112..28decb0934c 100644 --- a/src/test/ui/associated-types/defaults-cyclic-fail-1.stderr +++ b/src/test/ui/associated-types/defaults-cyclic-fail-1.stderr @@ -1,34 +1,16 @@ -error[E0275]: overflow evaluating the requirement `<() as Tr>::B == _` - --> $DIR/defaults-cyclic-fail-1.rs:10:6 - | -LL | impl Tr for () {} - | ^^ - -error[E0271]: type mismatch resolving `<bool as Tr>::B == _` - --> $DIR/defaults-cyclic-fail-1.rs:28:6 - | -LL | impl Tr for bool { - | ^^ cyclic type of infinite size - -error[E0271]: type mismatch resolving `<usize as Tr>::B == _` - --> $DIR/defaults-cyclic-fail-1.rs:35:6 - | -LL | impl Tr for usize { - | ^^ cyclic type of infinite size - -error[E0271]: type mismatch resolving `<bool as Tr>::B == _` - --> $DIR/defaults-cyclic-fail-1.rs:30:5 +error[E0275]: overflow evaluating the requirement `<bool as Tr>::B` + --> $DIR/defaults-cyclic-fail-1.rs:26:5 | LL | type A = Box<Self::B>; | ^^^^^^^^^^^^^^^^^^^^^^ cyclic type of infinite size -error[E0271]: type mismatch resolving `<usize as Tr>::A == _` - --> $DIR/defaults-cyclic-fail-1.rs:37:5 +error[E0275]: overflow evaluating the requirement `<usize as Tr>::A` + --> $DIR/defaults-cyclic-fail-1.rs:32:5 | LL | type B = &'static Self::A; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ cyclic type of infinite size -error: aborting due to 5 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0271, E0275. For more information about an error, try `rustc --explain E0271`. diff --git a/src/test/ui/associated-types/defaults-cyclic-fail-2.rs b/src/test/ui/associated-types/defaults-cyclic-fail-2.rs index edcd310908a..ba4bb0d5a29 100644 --- a/src/test/ui/associated-types/defaults-cyclic-fail-2.rs +++ b/src/test/ui/associated-types/defaults-cyclic-fail-2.rs @@ -8,11 +8,8 @@ trait Tr { type B = Box<Self::A>; } -// ...but is an error in any impl that doesn't override at least one of the defaults impl Tr for () {} -//~^ ERROR type mismatch resolving `<() as Tr>::B == _` -// As soon as at least one is redefined, it works: impl Tr for u8 { type A = u8; } @@ -26,16 +23,13 @@ impl Tr for u32 { type B = u8; } -// ...but only if this actually breaks the cycle impl Tr for bool { - //~^ ERROR type mismatch resolving `<bool as Tr>::B == _` type A = Box<Self::B>; //~^ ERROR type mismatch resolving `<bool as Tr>::B == _` } // (the error is shown twice for some reason) impl Tr for usize { - //~^ ERROR type mismatch resolving `<usize as Tr>::B == _` type B = &'static Self::A; //~^ ERROR type mismatch resolving `<usize as Tr>::A == _` } diff --git a/src/test/ui/associated-types/defaults-cyclic-fail-2.stderr b/src/test/ui/associated-types/defaults-cyclic-fail-2.stderr index f39021c30ed..6b6d5348c15 100644 --- a/src/test/ui/associated-types/defaults-cyclic-fail-2.stderr +++ b/src/test/ui/associated-types/defaults-cyclic-fail-2.stderr @@ -1,33 +1,15 @@ -error[E0271]: type mismatch resolving `<() as Tr>::B == _` - --> $DIR/defaults-cyclic-fail-2.rs:12:6 - | -LL | impl Tr for () {} - | ^^ cyclic type of infinite size - -error[E0271]: type mismatch resolving `<bool as Tr>::B == _` - --> $DIR/defaults-cyclic-fail-2.rs:30:6 - | -LL | impl Tr for bool { - | ^^ cyclic type of infinite size - -error[E0271]: type mismatch resolving `<usize as Tr>::B == _` - --> $DIR/defaults-cyclic-fail-2.rs:37:6 - | -LL | impl Tr for usize { - | ^^ cyclic type of infinite size - -error[E0271]: type mismatch resolving `<bool as Tr>::B == _` - --> $DIR/defaults-cyclic-fail-2.rs:32:5 +error[E0275]: overflow evaluating the requirement `<bool as Tr>::B` + --> $DIR/defaults-cyclic-fail-2.rs:27:5 | LL | type A = Box<Self::B>; | ^^^^^^^^^^^^^^^^^^^^^^ cyclic type of infinite size -error[E0271]: type mismatch resolving `<usize as Tr>::A == _` - --> $DIR/defaults-cyclic-fail-2.rs:39:5 +error[E0275]: overflow evaluating the requirement `<usize as Tr>::A` + --> $DIR/defaults-cyclic-fail-2.rs:33:5 | LL | type B = &'static Self::A; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ cyclic type of infinite size -error: aborting due to 5 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0271`. diff --git a/src/test/ui/associated-types/defaults-suitability.rs b/src/test/ui/associated-types/defaults-suitability.rs index 30c2555df8b..69be300b16f 100644 --- a/src/test/ui/associated-types/defaults-suitability.rs +++ b/src/test/ui/associated-types/defaults-suitability.rs @@ -1,10 +1,8 @@ //! Checks that associated type defaults are properly validated. //! //! This means: -//! * Default types are wfchecked //! * Default types are checked against where clauses on the assoc. type -//! (eg. `type Assoc: Clone = NotClone`), and also against where clauses on -//! the trait itself when possible +//! (eg. `type Assoc: Clone = NotClone`) #![feature(associated_type_defaults)] @@ -17,15 +15,12 @@ trait Tr { } // Where-clauses defined on the trait must also be considered -trait Tr2 where Self::Ty: Clone { - //~^ ERROR the trait bound `NotClone: Clone` is not satisfied +trait Tr2 +where + Self::Ty: Clone, +{ type Ty = NotClone; -} - -// Independent of where-clauses (there are none here), default types must always be wf -trait Tr3 { - type Ty = Vec<[u8]>; - //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time + //~^ ERROR the trait bound `NotClone: std::clone::Clone` is not satisfied } // Involved type parameters must fulfill all bounds required by defaults that mention them @@ -43,25 +38,24 @@ trait Bar: Sized { trait IsU8<T> {} impl<T> IsU8<u8> for T {} -// Test that mentioning the assoc. type inside where clauses works +// Test that mentioning the assoc. type inside where clauses is not allowed trait C where Vec<Self::Assoc>: Clone, Self::Assoc: IsU8<Self::Assoc>, bool: IsU8<Self::Assoc>, { type Assoc = u8; + //~^ ERROR the trait bound `u8: IsU8<<Self as C>::Assoc>` is not satisfied } // Test that we get all expected errors if that default is unsuitable trait D where Vec<Self::Assoc>: Clone, - //~^ ERROR the trait bound `NotClone: Clone` is not satisfied Self::Assoc: IsU8<Self::Assoc>, - //~^ ERROR the trait bound `NotClone: IsU8<NotClone>` is not satisfied bool: IsU8<Self::Assoc>, - //~^ ERROR the trait bound `bool: IsU8<NotClone>` is not satisfied { type Assoc = NotClone; + //~^ ERROR the trait bound `NotClone: IsU8<<Self as D>::Assoc>` is not satisfied } // Test behavior of the check when defaults refer to other defaults: @@ -85,18 +79,20 @@ trait Foo25<T: Clone> { // Adding the `Baz: Clone` bound isn't enough since the default is type // parameter `T`, which also might not be `Clone`. -trait Foo3<T> where +trait Foo3<T> +where Self::Bar: Clone, Self::Baz: Clone, - //~^ ERROR the trait bound `T: Clone` is not satisfied { type Bar = Vec<Self::Baz>; type Baz = T; + //~^ ERROR the trait bound `T: std::clone::Clone` is not satisfied } // This one finally works, with `Clone` bounds on all assoc. types and the type // parameter. -trait Foo4<T> where +trait Foo4<T> +where T: Clone, { type Bar: Clone = Vec<Self::Baz>; diff --git a/src/test/ui/associated-types/defaults-suitability.stderr b/src/test/ui/associated-types/defaults-suitability.stderr index c2ad4c5824e..4d8e6f1584d 100644 --- a/src/test/ui/associated-types/defaults-suitability.stderr +++ b/src/test/ui/associated-types/defaults-suitability.stderr @@ -1,27 +1,31 @@ -error[E0277]: the trait bound `NotClone: Clone` is not satisfied - --> $DIR/defaults-suitability.rs:15:14 +error[E0277]: the trait bound `NotClone: std::clone::Clone` is not satisfied + --> $DIR/defaults-suitability.rs:13:5 | -LL | trait Tr { - | -------- required by `Tr` LL | type Ty: Clone = NotClone; - | ^^^^^ the trait `Clone` is not implemented for `NotClone` + | ^^^^^^^^^-----^^^^^^^^^^^^ + | | | + | | required by this bound in `Tr::Ty` + | the trait `std::clone::Clone` is not implemented for `NotClone` -error[E0277]: the trait bound `NotClone: Clone` is not satisfied - --> $DIR/defaults-suitability.rs:20:27 +error[E0277]: the trait bound `NotClone: std::clone::Clone` is not satisfied + --> $DIR/defaults-suitability.rs:19:5 | LL | trait Tr2 where Self::Ty: Clone { - | --------------------------^^^^^ - | | | - | | the trait `Clone` is not implemented for `NotClone` - | required by `Tr2` + | ----- required by this bound in `Tr2::Ty` +LL | type Ty = NotClone; + | ^^^^^--^^^^^^^^^^^^ + | | | + | | required by a bound in this + | the trait `std::clone::Clone` is not implemented for `NotClone` -error[E0277]: the trait bound `T: Clone` is not satisfied - --> $DIR/defaults-suitability.rs:33:15 +error[E0277]: the trait bound `T: std::clone::Clone` is not satisfied + --> $DIR/defaults-suitability.rs:25:5 | -LL | trait Foo<T> { - | ------------ required by `Foo` LL | type Bar: Clone = Vec<T>; - | ^^^^^ the trait `Clone` is not implemented for `T` + | ^^^^^^^^^^-----^^^^^^^^^^ + | | | + | | required by this bound in `Foo::Bar` + | the trait `std::clone::Clone` is not implemented for `T` | = note: required because of the requirements on the impl of `Clone` for `Vec<T>` help: consider restricting type parameter `T` @@ -30,64 +34,46 @@ LL | trait Foo<T: Clone> { | ^^^^^^^ error[E0277]: the trait bound `(): Foo<Self>` is not satisfied - --> $DIR/defaults-suitability.rs:39:17 + --> $DIR/defaults-suitability.rs:31:5 | -LL | trait Bar: Sized { - | ---------------- required by `Bar` -LL | // `(): Foo<Self>` might hold for some possible impls but not all. LL | type Assoc: Foo<Self> = (); - | ^^^^^^^^^ the trait `Foo<Self>` is not implemented for `()` + | ^^^^^^^^^^^^---------^^^^^^ + | | | + | | required by this bound in `Bar::Assoc` + | the trait `Foo<Self>` is not implemented for `()` -error[E0277]: the trait bound `NotClone: IsU8<NotClone>` is not satisfied - --> $DIR/defaults-suitability.rs:59:18 - | -LL | / trait D where -LL | | Vec<Self::Assoc>: Clone, -LL | | -LL | | Self::Assoc: IsU8<Self::Assoc>, - | | ^^^^^^^^^^^^^^^^^ the trait `IsU8<NotClone>` is not implemented for `NotClone` -... | -LL | | type Assoc = NotClone; -LL | | } - | |_- required by `D` +error[E0277]: the trait bound `u8: IsU8<<Self as C>::Assoc>` is not satisfied + --> $DIR/defaults-suitability.rs:44:5 + | +LL | Self::Assoc: IsU8<Self::Assoc>, + | ----------------- required by this bound in `C::Assoc` +... +LL | type Assoc = u8; + | ^^^^^-----^^^^^^ + | | | + | | required by a bound in this + | the trait `IsU8<<Self as C>::Assoc>` is not implemented for `u8` -error[E0277]: the trait bound `bool: IsU8<NotClone>` is not satisfied - --> $DIR/defaults-suitability.rs:61:11 - | -LL | / trait D where -LL | | Vec<Self::Assoc>: Clone, -LL | | -LL | | Self::Assoc: IsU8<Self::Assoc>, -LL | | -LL | | bool: IsU8<Self::Assoc>, - | | ^^^^^^^^^^^^^^^^^ the trait `IsU8<NotClone>` is not implemented for `bool` -... | -LL | | type Assoc = NotClone; -LL | | } - | |_- required by `D` +error[E0277]: the trait bound `NotClone: IsU8<<Self as D>::Assoc>` is not satisfied + --> $DIR/defaults-suitability.rs:54:5 + | +LL | Self::Assoc: IsU8<Self::Assoc>, + | ----------------- required by this bound in `D::Assoc` +... +LL | type Assoc = NotClone; + | ^^^^^-----^^^^^^^^^^^^ + | | | + | | required by a bound in this + | the trait `IsU8<<Self as D>::Assoc>` is not implemented for `NotClone` -error[E0277]: the trait bound `NotClone: Clone` is not satisfied - --> $DIR/defaults-suitability.rs:57:23 - | -LL | / trait D where -LL | | Vec<Self::Assoc>: Clone, - | | ^^^^^ the trait `Clone` is not implemented for `NotClone` -LL | | -LL | | Self::Assoc: IsU8<Self::Assoc>, -... | -LL | | type Assoc = NotClone; -LL | | } - | |_- required by `D` - | - = note: required because of the requirements on the impl of `Clone` for `Vec<NotClone>` - -error[E0277]: the trait bound `<Self as Foo2<T>>::Baz: Clone` is not satisfied - --> $DIR/defaults-suitability.rs:72:15 +error[E0277]: the trait bound `<Self as Foo2<T>>::Baz: std::clone::Clone` is not satisfied + --> $DIR/defaults-suitability.rs:63:5 | -LL | trait Foo2<T> { - | ------------- required by `Foo2` LL | type Bar: Clone = Vec<Self::Baz>; - | ^^^^^ the trait `Clone` is not implemented for `<Self as Foo2<T>>::Baz` + | ^^^^^^^^^^-----^^^^^^^^^^^^^^^^^^ + | | | + | | required by this bound in `Foo2::Bar` + | the trait `std::clone::Clone` is not implemented for `<Self as Foo2<T>>::Baz` | = note: required because of the requirements on the impl of `Clone` for `Vec<<Self as Foo2<T>>::Baz>` help: consider further restricting the associated type @@ -95,13 +81,14 @@ help: consider further restricting the associated type LL | trait Foo2<T> where <Self as Foo2<T>>::Baz: Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0277]: the trait bound `<Self as Foo25<T>>::Baz: Clone` is not satisfied - --> $DIR/defaults-suitability.rs:81:15 +error[E0277]: the trait bound `<Self as Foo25<T>>::Baz: std::clone::Clone` is not satisfied + --> $DIR/defaults-suitability.rs:72:5 | -LL | trait Foo25<T: Clone> { - | --------------------- required by `Foo25` LL | type Bar: Clone = Vec<Self::Baz>; - | ^^^^^ the trait `Clone` is not implemented for `<Self as Foo25<T>>::Baz` + | ^^^^^^^^^^-----^^^^^^^^^^^^^^^^^^ + | | | + | | required by this bound in `Foo25::Bar` + | the trait `std::clone::Clone` is not implemented for `<Self as Foo25<T>>::Baz` | = note: required because of the requirements on the impl of `Clone` for `Vec<<Self as Foo25<T>>::Baz>` help: consider further restricting the associated type @@ -109,37 +96,23 @@ help: consider further restricting the associated type LL | trait Foo25<T: Clone> where <Self as Foo25<T>>::Baz: Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0277]: the trait bound `T: Clone` is not satisfied - --> $DIR/defaults-suitability.rs:90:16 - | -LL | / trait Foo3<T> where -LL | | Self::Bar: Clone, -LL | | Self::Baz: Clone, - | | ^^^^^ the trait `Clone` is not implemented for `T` -LL | | -... | -LL | | type Baz = T; -LL | | } - | |_- required by `Foo3` +error[E0277]: the trait bound `T: std::clone::Clone` is not satisfied + --> $DIR/defaults-suitability.rs:84:5 + | +LL | Self::Baz: Clone, + | ----- required by this bound in `Foo3::Baz` +... +LL | type Baz = T; + | ^^^^^---^^^^^ + | | | + | | required by a bound in this + | the trait `std::clone::Clone` is not implemented for `T` | help: consider further restricting type parameter `T` | LL | Self::Baz: Clone, T: Clone | ^^^^^^^^^^ -error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/defaults-suitability.rs:27:5 - | -LL | type Ty = Vec<[u8]>; - | ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - ::: $SRC_DIR/alloc/src/vec.rs:LL:COL - | -LL | pub struct Vec<T> { - | - required by this bound in `Vec` - | - = help: the trait `Sized` is not implemented for `[u8]` - -error: aborting due to 11 previous errors +error: aborting due to 9 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/associated-types/defaults-unsound-62211-1.rs b/src/test/ui/associated-types/defaults-unsound-62211-1.rs index f283d22b3c7..093e32f66be 100644 --- a/src/test/ui/associated-types/defaults-unsound-62211-1.rs +++ b/src/test/ui/associated-types/defaults-unsound-62211-1.rs @@ -11,22 +11,13 @@ use std::{ fmt::Display, - ops::{AddAssign, Deref} + ops::{AddAssign, Deref}, }; - trait UncheckedCopy: Sized { // This Output is said to be Copy. Yet we default to Self // and it's accepted, not knowing if Self ineed is Copy - type Output: Copy - //~^ ERROR the trait bound `Self: Copy` is not satisfied - + Deref<Target = str> - //~^ ERROR the trait bound `Self: Deref` is not satisfied - + AddAssign<&'static str> - //~^ ERROR cannot add-assign `&'static str` to `Self` - + From<Self> - + Display = Self; - //~^ ERROR `Self` doesn't implement `std::fmt::Display` + type Output: Copy + Deref<Target = str> + AddAssign<&'static str> + From<Self> + Display = Self; // We said the Output type was Copy, so we can Copy it freely! fn unchecked_copy(other: &Self::Output) -> Self::Output { @@ -39,10 +30,6 @@ trait UncheckedCopy: Sized { } impl<T> UncheckedCopy for T {} -//~^ ERROR `T` doesn't implement `std::fmt::Display` -//~| ERROR the trait bound `T: Deref` is not satisfied -//~| ERROR cannot add-assign `&'static str` to `T` -//~| ERROR the trait bound `T: Copy` is not satisfied fn bug<T: UncheckedCopy>(origin: T) { let origin = T::make_origin(origin); diff --git a/src/test/ui/associated-types/defaults-unsound-62211-1.stderr b/src/test/ui/associated-types/defaults-unsound-62211-1.stderr index 29a7c2eab41..a8584d6dc5c 100644 --- a/src/test/ui/associated-types/defaults-unsound-62211-1.stderr +++ b/src/test/ui/associated-types/defaults-unsound-62211-1.stderr @@ -1,53 +1,19 @@ -error[E0277]: the trait bound `Self: Copy` is not satisfied - --> $DIR/defaults-unsound-62211-1.rs:21:18 - | -LL | trait UncheckedCopy: Sized { - | -------------------------- required by `UncheckedCopy` -... -LL | type Output: Copy - | ^^^^ the trait `Copy` is not implemented for `Self` - | -help: consider further restricting `Self` - | -LL | trait UncheckedCopy: Sized + Copy { - | ^^^^^^ - -error[E0277]: cannot add-assign `&'static str` to `Self` - --> $DIR/defaults-unsound-62211-1.rs:25:7 - | -LL | trait UncheckedCopy: Sized { - | -------------------------- required by `UncheckedCopy` -... -LL | + AddAssign<&'static str> - | ^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `Self += &'static str` - | -help: consider further restricting `Self` - | -LL | trait UncheckedCopy: Sized + AddAssign<&'static str> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0277]: the trait bound `Self: Deref` is not satisfied - --> $DIR/defaults-unsound-62211-1.rs:23:7 - | -LL | trait UncheckedCopy: Sized { - | -------------------------- required by `UncheckedCopy` -... -LL | + Deref<Target = str> - | ^^^^^^^^^^^^^^^^^^^ the trait `Deref` is not implemented for `Self` - | -help: consider further restricting `Self` - | -LL | trait UncheckedCopy: Sized + Deref { - | ^^^^^^^ - error[E0277]: `Self` doesn't implement `std::fmt::Display` - --> $DIR/defaults-unsound-62211-1.rs:28:7 - | -LL | trait UncheckedCopy: Sized { - | -------------------------- required by `UncheckedCopy` -... -LL | + Display = Self; - | ^^^^^^^ `Self` cannot be formatted with the default formatter + --> $DIR/defaults-unsound-62211-1.rs:21:5 + | +LL | type Output: Copy + | ^ ------ required by a bound in this + | _____| + | | +LL | | +LL | | +LL | | +... | +LL | | + From<Self> +LL | | + Display = Self; + | |___________-------_______^ `Self` cannot be formatted with the default formatter + | | + | required by this bound in `UncheckedCopy::Output` | = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead help: consider further restricting `Self` @@ -55,75 +21,71 @@ help: consider further restricting `Self` LL | trait UncheckedCopy: Sized + std::fmt::Display { | ^^^^^^^^^^^^^^^^^^^ -error[E0277]: `T` doesn't implement `std::fmt::Display` - --> $DIR/defaults-unsound-62211-1.rs:41:9 - | -LL | trait UncheckedCopy: Sized { - | ------------- required by a bound in this -... -LL | + Display = Self; - | ------- required by this bound in `UncheckedCopy` -... -LL | impl<T> UncheckedCopy for T {} - | ^^^^^^^^^^^^^ `T` cannot be formatted with the default formatter - | - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead -help: consider restricting type parameter `T` +error[E0277]: the trait bound `Self: std::ops::Deref` is not satisfied + --> $DIR/defaults-unsound-62211-1.rs:21:5 + | +LL | type Output: Copy + | ^ ------ required by a bound in this + | _____| + | | +LL | | +LL | | +LL | | +LL | | +LL | | + Deref<Target = str> + | | ------------------- required by this bound in `UncheckedCopy::Output` +LL | | + AddAssign<&'static str> +LL | | + From<Self> +LL | | + Display = Self; + | |_________________________^ the trait `std::ops::Deref` is not implemented for `Self` | -LL | impl<T: std::fmt::Display> UncheckedCopy for T {} - | ^^^^^^^^^^^^^^^^^^^ - -error[E0277]: the trait bound `T: Deref` is not satisfied - --> $DIR/defaults-unsound-62211-1.rs:41:9 - | -LL | trait UncheckedCopy: Sized { - | ------------- required by a bound in this -... -LL | + Deref<Target = str> - | ------------------- required by this bound in `UncheckedCopy` -... -LL | impl<T> UncheckedCopy for T {} - | ^^^^^^^^^^^^^ the trait `Deref` is not implemented for `T` - | -help: consider restricting type parameter `T` +help: consider further restricting `Self` | -LL | impl<T: Deref> UncheckedCopy for T {} - | ^^^^^^^ +LL | trait UncheckedCopy: Sized + Deref { + | ^^^^^^^ -error[E0277]: cannot add-assign `&'static str` to `T` - --> $DIR/defaults-unsound-62211-1.rs:41:9 - | -LL | trait UncheckedCopy: Sized { - | ------------- required by a bound in this -... -LL | + AddAssign<&'static str> - | ----------------------- required by this bound in `UncheckedCopy` -... -LL | impl<T> UncheckedCopy for T {} - | ^^^^^^^^^^^^^ no implementation for `T += &'static str` +error[E0277]: cannot add-assign `&'static str` to `Self` + --> $DIR/defaults-unsound-62211-1.rs:21:5 + | +LL | type Output: Copy + | ^ ------ required by a bound in this + | _____| + | | +LL | | +LL | | +LL | | +... | +LL | | + AddAssign<&'static str> + | | ----------------------- required by this bound in `UncheckedCopy::Output` +LL | | + From<Self> +LL | | + Display = Self; + | |_________________________^ no implementation for `Self += &'static str` | -help: consider restricting type parameter `T` +help: consider further restricting `Self` | -LL | impl<T: AddAssign<&'static str>> UncheckedCopy for T {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | trait UncheckedCopy: Sized + std::ops::AddAssign<&'static str> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/defaults-unsound-62211-1.rs:41:9 - | -LL | trait UncheckedCopy: Sized { - | ------------- required by a bound in this -... -LL | type Output: Copy - | ---- required by this bound in `UncheckedCopy` -... -LL | impl<T> UncheckedCopy for T {} - | ^^^^^^^^^^^^^ the trait `Copy` is not implemented for `T` +error[E0277]: the trait bound `Self: std::marker::Copy` is not satisfied + --> $DIR/defaults-unsound-62211-1.rs:21:5 + | +LL | type Output: Copy + | ^ ---- required by this bound in `UncheckedCopy::Output` + | _____| + | | +LL | | +LL | | +LL | | +... | +LL | | + From<Self> +LL | | + Display = Self; + | |_________________________^ the trait `std::marker::Copy` is not implemented for `Self` | -help: consider restricting type parameter `T` +help: consider further restricting `Self` | -LL | impl<T: Copy> UncheckedCopy for T {} - | ^^^^^^ +LL | trait UncheckedCopy: Sized + std::marker::Copy { + | ^^^^^^^^^^^^^^^^^^^ -error: aborting due to 8 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/associated-types/defaults-unsound-62211-2.rs b/src/test/ui/associated-types/defaults-unsound-62211-2.rs index 5518cda3708..44bbdc9f52b 100644 --- a/src/test/ui/associated-types/defaults-unsound-62211-2.rs +++ b/src/test/ui/associated-types/defaults-unsound-62211-2.rs @@ -11,22 +11,13 @@ use std::{ fmt::Display, - ops::{AddAssign, Deref} + ops::{AddAssign, Deref}, }; - trait UncheckedCopy: Sized { // This Output is said to be Copy. Yet we default to Self // and it's accepted, not knowing if Self ineed is Copy - type Output: Copy - //~^ ERROR the trait bound `Self: Copy` is not satisfied - + Deref<Target = str> - //~^ ERROR the trait bound `Self: Deref` is not satisfied - + AddAssign<&'static str> - //~^ ERROR cannot add-assign `&'static str` to `Self` - + From<Self> - + Display = Self; - //~^ ERROR `Self` doesn't implement `std::fmt::Display` + type Output: Copy + Deref<Target = str> + AddAssign<&'static str> + From<Self> + Display = Self; // We said the Output type was Copy, so we can Copy it freely! fn unchecked_copy(other: &Self::Output) -> Self::Output { @@ -39,10 +30,6 @@ trait UncheckedCopy: Sized { } impl<T> UncheckedCopy for T {} -//~^ ERROR `T` doesn't implement `std::fmt::Display` -//~| ERROR the trait bound `T: Deref` is not satisfied -//~| ERROR cannot add-assign `&'static str` to `T` -//~| ERROR the trait bound `T: Copy` is not satisfied fn bug<T: UncheckedCopy>(origin: T) { let origin = T::make_origin(origin); diff --git a/src/test/ui/associated-types/defaults-unsound-62211-2.stderr b/src/test/ui/associated-types/defaults-unsound-62211-2.stderr index 49c66093bf0..6a8e3ff7b62 100644 --- a/src/test/ui/associated-types/defaults-unsound-62211-2.stderr +++ b/src/test/ui/associated-types/defaults-unsound-62211-2.stderr @@ -1,53 +1,19 @@ -error[E0277]: the trait bound `Self: Copy` is not satisfied - --> $DIR/defaults-unsound-62211-2.rs:21:18 - | -LL | trait UncheckedCopy: Sized { - | -------------------------- required by `UncheckedCopy` -... -LL | type Output: Copy - | ^^^^ the trait `Copy` is not implemented for `Self` - | -help: consider further restricting `Self` - | -LL | trait UncheckedCopy: Sized + Copy { - | ^^^^^^ - -error[E0277]: cannot add-assign `&'static str` to `Self` - --> $DIR/defaults-unsound-62211-2.rs:25:7 - | -LL | trait UncheckedCopy: Sized { - | -------------------------- required by `UncheckedCopy` -... -LL | + AddAssign<&'static str> - | ^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `Self += &'static str` - | -help: consider further restricting `Self` - | -LL | trait UncheckedCopy: Sized + AddAssign<&'static str> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0277]: the trait bound `Self: Deref` is not satisfied - --> $DIR/defaults-unsound-62211-2.rs:23:7 - | -LL | trait UncheckedCopy: Sized { - | -------------------------- required by `UncheckedCopy` -... -LL | + Deref<Target = str> - | ^^^^^^^^^^^^^^^^^^^ the trait `Deref` is not implemented for `Self` - | -help: consider further restricting `Self` - | -LL | trait UncheckedCopy: Sized + Deref { - | ^^^^^^^ - error[E0277]: `Self` doesn't implement `std::fmt::Display` - --> $DIR/defaults-unsound-62211-2.rs:28:7 - | -LL | trait UncheckedCopy: Sized { - | -------------------------- required by `UncheckedCopy` -... -LL | + Display = Self; - | ^^^^^^^ `Self` cannot be formatted with the default formatter + --> $DIR/defaults-unsound-62211-2.rs:21:5 + | +LL | type Output: Copy + | ^ ------ required by a bound in this + | _____| + | | +LL | | +LL | | +LL | | +... | +LL | | + From<Self> +LL | | + Display = Self; + | |___________-------_______^ `Self` cannot be formatted with the default formatter + | | + | required by this bound in `UncheckedCopy::Output` | = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead help: consider further restricting `Self` @@ -55,75 +21,71 @@ help: consider further restricting `Self` LL | trait UncheckedCopy: Sized + std::fmt::Display { | ^^^^^^^^^^^^^^^^^^^ -error[E0277]: `T` doesn't implement `std::fmt::Display` - --> $DIR/defaults-unsound-62211-2.rs:41:9 - | -LL | trait UncheckedCopy: Sized { - | ------------- required by a bound in this -... -LL | + Display = Self; - | ------- required by this bound in `UncheckedCopy` -... -LL | impl<T> UncheckedCopy for T {} - | ^^^^^^^^^^^^^ `T` cannot be formatted with the default formatter - | - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead -help: consider restricting type parameter `T` +error[E0277]: the trait bound `Self: std::ops::Deref` is not satisfied + --> $DIR/defaults-unsound-62211-2.rs:21:5 + | +LL | type Output: Copy + | ^ ------ required by a bound in this + | _____| + | | +LL | | +LL | | +LL | | +LL | | +LL | | + Deref<Target = str> + | | ------------------- required by this bound in `UncheckedCopy::Output` +LL | | + AddAssign<&'static str> +LL | | + From<Self> +LL | | + Display = Self; + | |_________________________^ the trait `std::ops::Deref` is not implemented for `Self` | -LL | impl<T: std::fmt::Display> UncheckedCopy for T {} - | ^^^^^^^^^^^^^^^^^^^ - -error[E0277]: the trait bound `T: Deref` is not satisfied - --> $DIR/defaults-unsound-62211-2.rs:41:9 - | -LL | trait UncheckedCopy: Sized { - | ------------- required by a bound in this -... -LL | + Deref<Target = str> - | ------------------- required by this bound in `UncheckedCopy` -... -LL | impl<T> UncheckedCopy for T {} - | ^^^^^^^^^^^^^ the trait `Deref` is not implemented for `T` - | -help: consider restricting type parameter `T` +help: consider further restricting `Self` | -LL | impl<T: Deref> UncheckedCopy for T {} - | ^^^^^^^ +LL | trait UncheckedCopy: Sized + Deref { + | ^^^^^^^ -error[E0277]: cannot add-assign `&'static str` to `T` - --> $DIR/defaults-unsound-62211-2.rs:41:9 - | -LL | trait UncheckedCopy: Sized { - | ------------- required by a bound in this -... -LL | + AddAssign<&'static str> - | ----------------------- required by this bound in `UncheckedCopy` -... -LL | impl<T> UncheckedCopy for T {} - | ^^^^^^^^^^^^^ no implementation for `T += &'static str` +error[E0277]: cannot add-assign `&'static str` to `Self` + --> $DIR/defaults-unsound-62211-2.rs:21:5 + | +LL | type Output: Copy + | ^ ------ required by a bound in this + | _____| + | | +LL | | +LL | | +LL | | +... | +LL | | + AddAssign<&'static str> + | | ----------------------- required by this bound in `UncheckedCopy::Output` +LL | | + From<Self> +LL | | + Display = Self; + | |_________________________^ no implementation for `Self += &'static str` | -help: consider restricting type parameter `T` +help: consider further restricting `Self` | -LL | impl<T: AddAssign<&'static str>> UncheckedCopy for T {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | trait UncheckedCopy: Sized + std::ops::AddAssign<&'static str> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/defaults-unsound-62211-2.rs:41:9 - | -LL | trait UncheckedCopy: Sized { - | ------------- required by a bound in this -... -LL | type Output: Copy - | ---- required by this bound in `UncheckedCopy` -... -LL | impl<T> UncheckedCopy for T {} - | ^^^^^^^^^^^^^ the trait `Copy` is not implemented for `T` +error[E0277]: the trait bound `Self: std::marker::Copy` is not satisfied + --> $DIR/defaults-unsound-62211-2.rs:21:5 + | +LL | type Output: Copy + | ^ ---- required by this bound in `UncheckedCopy::Output` + | _____| + | | +LL | | +LL | | +LL | | +... | +LL | | + From<Self> +LL | | + Display = Self; + | |_________________________^ the trait `std::marker::Copy` is not implemented for `Self` | -help: consider restricting type parameter `T` +help: consider further restricting `Self` | -LL | impl<T: Copy> UncheckedCopy for T {} - | ^^^^^^ +LL | trait UncheckedCopy: Sized + std::marker::Copy { + | ^^^^^^^^^^^^^^^^^^^ -error: aborting due to 8 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/associated-types/defaults-wf.rs b/src/test/ui/associated-types/defaults-wf.rs new file mode 100644 index 00000000000..99b51250334 --- /dev/null +++ b/src/test/ui/associated-types/defaults-wf.rs @@ -0,0 +1,11 @@ +// Check that associated type defaults are wf checked. + +#![feature(associated_type_defaults)] + +// Default types must always be wf +trait Tr3 { + type Ty = Vec<[u8]>; + //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time +} + +fn main() {} diff --git a/src/test/ui/associated-types/defaults-wf.stderr b/src/test/ui/associated-types/defaults-wf.stderr new file mode 100644 index 00000000000..aeb7b6cae19 --- /dev/null +++ b/src/test/ui/associated-types/defaults-wf.stderr @@ -0,0 +1,16 @@ +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/defaults-wf.rs:7:5 + | +LL | type Ty = Vec<[u8]>; + | ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + ::: $SRC_DIR/liballoc/vec.rs:LL:COL + | +LL | pub struct Vec<T> { + | - required by this bound in `std::vec::Vec` + | + = help: the trait `std::marker::Sized` is not implemented for `[u8]` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/associated-types/issue-43924.rs b/src/test/ui/associated-types/issue-43924.rs index 26f1183c6bd..6a63b3e0936 100644 --- a/src/test/ui/associated-types/issue-43924.rs +++ b/src/test/ui/associated-types/issue-43924.rs @@ -4,12 +4,13 @@ // type-checked. trait Foo<T: Default + ToString> { - type Out: Default + ToString + ?Sized = dyn ToString; //~ error: not satisfied + type Out: Default + ToString + ?Sized = dyn ToString; //~ ERROR not satisfied } -impl Foo<u32> for () {} //~ error: not satisfied -impl Foo<u64> for () {} //~ error: not satisfied +impl Foo<u32> for () {} +impl Foo<u64> for () {} fn main() { assert_eq!(<() as Foo<u32>>::Out::default().to_string(), "false"); + //~^ ERROR no function or associated item named `default` found for trait object } diff --git a/src/test/ui/associated-types/issue-43924.stderr b/src/test/ui/associated-types/issue-43924.stderr index 661730bcd75..9bcedb05ed4 100644 --- a/src/test/ui/associated-types/issue-43924.stderr +++ b/src/test/ui/associated-types/issue-43924.stderr @@ -1,33 +1,19 @@ -error[E0277]: the trait bound `(dyn ToString + 'static): Default` is not satisfied - --> $DIR/issue-43924.rs:7:15 +error[E0277]: the trait bound `(dyn std::string::ToString + 'static): std::default::Default` is not satisfied + --> $DIR/issue-43924.rs:7:5 | -LL | trait Foo<T: Default + ToString> { - | -------------------------------- required by `Foo` LL | type Out: Default + ToString + ?Sized = dyn ToString; - | ^^^^^^^ the trait `Default` is not implemented for `(dyn ToString + 'static)` + | ^^^^^^^^^^-------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | | + | | required by this bound in `Foo::Out` + | the trait `std::default::Default` is not implemented for `(dyn std::string::ToString + 'static)` -error[E0277]: the trait bound `(dyn ToString + 'static): Default` is not satisfied - --> $DIR/issue-43924.rs:10:6 +error[E0599]: no function or associated item named `default` found for trait object `(dyn std::string::ToString + 'static)` in the current scope + --> $DIR/issue-43924.rs:14:39 | -LL | trait Foo<T: Default + ToString> { - | --- required by a bound in this -LL | type Out: Default + ToString + ?Sized = dyn ToString; - | ------- required by this bound in `Foo` -... -LL | impl Foo<u32> for () {} - | ^^^^^^^^ the trait `Default` is not implemented for `(dyn ToString + 'static)` - -error[E0277]: the trait bound `(dyn ToString + 'static): Default` is not satisfied - --> $DIR/issue-43924.rs:11:6 - | -LL | trait Foo<T: Default + ToString> { - | --- required by a bound in this -LL | type Out: Default + ToString + ?Sized = dyn ToString; - | ------- required by this bound in `Foo` -... -LL | impl Foo<u64> for () {} - | ^^^^^^^^ the trait `Default` is not implemented for `(dyn ToString + 'static)` +LL | assert_eq!(<() as Foo<u32>>::Out::default().to_string(), "false"); + | ^^^^^^^ function or associated item not found in `(dyn std::string::ToString + 'static)` -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0277, E0599. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/associated-types/issue-63593.stderr b/src/test/ui/associated-types/issue-63593.stderr index ddc0bf436f6..16ae07687e2 100644 --- a/src/test/ui/associated-types/issue-63593.stderr +++ b/src/test/ui/associated-types/issue-63593.stderr @@ -1,10 +1,11 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation time --> $DIR/issue-63593.rs:9:5 | -LL | trait MyTrait { - | ------------- required by `MyTrait` LL | type This = Self; - | ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | ^^^^^^^^^^^^^^^^^ + | | + | doesn't have a size known at compile-time + | required by this bound in `MyTrait::This` | help: consider further restricting `Self` | diff --git a/src/test/ui/associated-types/issue-65774-1.rs b/src/test/ui/associated-types/issue-65774-1.rs index 0ffd6cc2cf2..9345140558b 100644 --- a/src/test/ui/associated-types/issue-65774-1.rs +++ b/src/test/ui/associated-types/issue-65774-1.rs @@ -14,7 +14,6 @@ trait MPU { struct S; impl MPU for S { } -//~^ ERROR the trait bound `T: MyDisplay` is not satisfied trait MyWrite { fn my_write(&self, _: &dyn MyDisplay) { } @@ -43,6 +42,7 @@ impl ProcessType for Process { // FulfillmentError(Obligation(predicate=Binder(TraitPredicate(<T as MyDisplay>)), // depth=1),Unimplemented) let closure = |config: &mut <S as MPU>::MpuConfig| writer.my_write(&config); + //~^ ERROR the trait bound `T: MyDisplay` is not satisfied closure(valref); } } diff --git a/src/test/ui/associated-types/issue-65774-1.stderr b/src/test/ui/associated-types/issue-65774-1.stderr index 72f47df5d80..f644eb5a1f4 100644 --- a/src/test/ui/associated-types/issue-65774-1.stderr +++ b/src/test/ui/associated-types/issue-65774-1.stderr @@ -1,21 +1,20 @@ error[E0277]: the trait bound `T: MyDisplay` is not satisfied - --> $DIR/issue-65774-1.rs:10:21 + --> $DIR/issue-65774-1.rs:10:5 | -LL | trait MPU { - | --------- required by `MPU` LL | type MpuConfig: MyDisplay = T; - | ^^^^^^^^^ the trait `MyDisplay` is not implemented for `T` + | ^^^^^^^^^^^^^^^^---------^^^^^ + | | | + | | required by this bound in `MPU::MpuConfig` + | the trait `MyDisplay` is not implemented for `T` error[E0277]: the trait bound `T: MyDisplay` is not satisfied - --> $DIR/issue-65774-1.rs:16:6 + --> $DIR/issue-65774-1.rs:44:76 | -LL | trait MPU { - | --- required by a bound in this -LL | type MpuConfig: MyDisplay = T; - | --------- required by this bound in `MPU` -... -LL | impl MPU for S { } - | ^^^ the trait `MyDisplay` is not implemented for `T` +LL | let closure = |config: &mut <S as MPU>::MpuConfig| writer.my_write(&config); + | ^^^^^^^ the trait `MyDisplay` is not implemented for `T` + | + = note: required because of the requirements on the impl of `MyDisplay` for `&mut T` + = note: required for the cast to the object type `dyn MyDisplay` error: aborting due to 2 previous errors diff --git a/src/test/ui/associated-types/issue-65774-2.rs b/src/test/ui/associated-types/issue-65774-2.rs index 31e203a81d3..171e0893b47 100644 --- a/src/test/ui/associated-types/issue-65774-2.rs +++ b/src/test/ui/associated-types/issue-65774-2.rs @@ -14,7 +14,6 @@ trait MPU { struct S; impl MPU for S { } -//~^ ERROR the trait bound `T: MyDisplay` is not satisfied trait MyWrite { fn my_write(&self, _: &dyn MyDisplay) { } @@ -38,6 +37,7 @@ impl ProcessType for Process { // // `Unimplemented` selecting `Binder(<T as MyDisplay>)` during codegen // writer.my_write(valref) + //~^ ERROR the trait bound `T: MyDisplay` is not satisfied // This one causes the ICE: // FulfillmentError(Obligation(predicate=Binder(TraitPredicate(<T as MyDisplay>)), diff --git a/src/test/ui/associated-types/issue-65774-2.stderr b/src/test/ui/associated-types/issue-65774-2.stderr index aef70885af3..572a9cf1909 100644 --- a/src/test/ui/associated-types/issue-65774-2.stderr +++ b/src/test/ui/associated-types/issue-65774-2.stderr @@ -1,21 +1,19 @@ error[E0277]: the trait bound `T: MyDisplay` is not satisfied - --> $DIR/issue-65774-2.rs:10:21 + --> $DIR/issue-65774-2.rs:10:5 | -LL | trait MPU { - | --------- required by `MPU` LL | type MpuConfig: MyDisplay = T; - | ^^^^^^^^^ the trait `MyDisplay` is not implemented for `T` + | ^^^^^^^^^^^^^^^^---------^^^^^ + | | | + | | required by this bound in `MPU::MpuConfig` + | the trait `MyDisplay` is not implemented for `T` error[E0277]: the trait bound `T: MyDisplay` is not satisfied - --> $DIR/issue-65774-2.rs:16:6 + --> $DIR/issue-65774-2.rs:39:25 | -LL | trait MPU { - | --- required by a bound in this -LL | type MpuConfig: MyDisplay = T; - | --------- required by this bound in `MPU` -... -LL | impl MPU for S { } - | ^^^ the trait `MyDisplay` is not implemented for `T` +LL | writer.my_write(valref) + | ^^^^^^ the trait `MyDisplay` is not implemented for `T` + | + = note: required for the cast to the object type `dyn MyDisplay` error: aborting due to 2 previous errors diff --git a/src/test/ui/associated-types/issue-72806.rs b/src/test/ui/associated-types/issue-72806.rs index ae63781d568..94758250346 100644 --- a/src/test/ui/associated-types/issue-72806.rs +++ b/src/test/ui/associated-types/issue-72806.rs @@ -9,9 +9,10 @@ trait Bar2 { struct Foo; struct Foo2; -impl Bar for Foo { //~ ERROR type mismatch resolving `<Foo2 as Bar2>::Ok == char` +impl Bar for Foo { type Ok = (); type Sibling = Foo2; + //~^ ERROR type mismatch resolving `<Foo2 as Bar2>::Ok == char` } impl Bar2 for Foo2 { type Ok = u32; diff --git a/src/test/ui/associated-types/issue-72806.stderr b/src/test/ui/associated-types/issue-72806.stderr index 03a6565848d..23fabbee1c5 100644 --- a/src/test/ui/associated-types/issue-72806.stderr +++ b/src/test/ui/associated-types/issue-72806.stderr @@ -1,8 +1,11 @@ error[E0271]: type mismatch resolving `<Foo2 as Bar2>::Ok == char` - --> $DIR/issue-72806.rs:12:6 + --> $DIR/issue-72806.rs:14:5 | -LL | impl Bar for Foo { - | ^^^ expected `u32`, found `char` +LL | type Sibling: Bar2<Ok=char>; + | ------- required by this bound in `Bar::Sibling` +... +LL | type Sibling = Foo2; + | ^^^^^^^^^^^^^^^^^^^^ expected `char`, found `u32` error: aborting due to previous error diff --git a/src/test/ui/associated-types/point-at-type-on-obligation-failure-2.rs b/src/test/ui/associated-types/point-at-type-on-obligation-failure-2.rs index 67b7c78071c..4bd3ccab834 100644 --- a/src/test/ui/associated-types/point-at-type-on-obligation-failure-2.rs +++ b/src/test/ui/associated-types/point-at-type-on-obligation-failure-2.rs @@ -5,7 +5,9 @@ trait Foo { } impl Foo for () { - type Assoc = bool; //~ ERROR the trait bound `bool: Bar` is not satisfied + // Doesn't error because we abort compilation after the errors below. + // See point-at-type-on-obligation-failure-3.rs + type Assoc = bool; } trait Baz where Self::Assoc: Bar { diff --git a/src/test/ui/associated-types/point-at-type-on-obligation-failure-2.stderr b/src/test/ui/associated-types/point-at-type-on-obligation-failure-2.stderr index 3118a9c5352..f4971105499 100644 --- a/src/test/ui/associated-types/point-at-type-on-obligation-failure-2.stderr +++ b/src/test/ui/associated-types/point-at-type-on-obligation-failure-2.stderr @@ -1,16 +1,5 @@ error[E0277]: the trait bound `bool: Bar` is not satisfied - --> $DIR/point-at-type-on-obligation-failure-2.rs:8:18 - | -LL | trait Foo { - | --- required by a bound in this -LL | type Assoc: Bar; - | --- required by this bound in `Foo` -... -LL | type Assoc = bool; - | ^^^^ the trait `Bar` is not implemented for `bool` - -error[E0277]: the trait bound `bool: Bar` is not satisfied - --> $DIR/point-at-type-on-obligation-failure-2.rs:16:18 + --> $DIR/point-at-type-on-obligation-failure-2.rs:18:18 | LL | trait Baz where Self::Assoc: Bar { | --- required by this bound in `Baz` @@ -19,7 +8,7 @@ LL | type Assoc = bool; | ^^^^ the trait `Bar` is not implemented for `bool` error[E0277]: the trait bound `bool: Bar` is not satisfied - --> $DIR/point-at-type-on-obligation-failure-2.rs:24:18 + --> $DIR/point-at-type-on-obligation-failure-2.rs:26:18 | LL | trait Bat where <Self as Bat>::Assoc: Bar { | --- required by this bound in `Bat` @@ -27,6 +16,6 @@ LL | trait Bat where <Self as Bat>::Assoc: Bar { LL | type Assoc = bool; | ^^^^ the trait `Bar` is not implemented for `bool` -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/associated-types/point-at-type-on-obligation-failure-3.rs b/src/test/ui/associated-types/point-at-type-on-obligation-failure-3.rs new file mode 100644 index 00000000000..9360d96f05e --- /dev/null +++ b/src/test/ui/associated-types/point-at-type-on-obligation-failure-3.rs @@ -0,0 +1,11 @@ +trait Bar {} + +trait Foo { + type Assoc: Bar; +} + +impl Foo for () { + type Assoc = bool; //~ ERROR the trait bound `bool: Bar` is not satisfied +} + +fn main() {} diff --git a/src/test/ui/associated-types/point-at-type-on-obligation-failure-3.stderr b/src/test/ui/associated-types/point-at-type-on-obligation-failure-3.stderr new file mode 100644 index 00000000000..6ab3d94e102 --- /dev/null +++ b/src/test/ui/associated-types/point-at-type-on-obligation-failure-3.stderr @@ -0,0 +1,12 @@ +error[E0277]: the trait bound `bool: Bar` is not satisfied + --> $DIR/point-at-type-on-obligation-failure-3.rs:8:5 + | +LL | type Assoc: Bar; + | --- required by this bound in `Foo::Assoc` +... +LL | type Assoc = bool; + | ^^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `bool` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/associated-types/point-at-type-on-obligation-failure.rs b/src/test/ui/associated-types/point-at-type-on-obligation-failure.rs index dc43dbaf54b..66666006887 100644 --- a/src/test/ui/associated-types/point-at-type-on-obligation-failure.rs +++ b/src/test/ui/associated-types/point-at-type-on-obligation-failure.rs @@ -10,8 +10,9 @@ struct Foo; struct Foo2; impl Bar for Foo { - type Ok = (); //~ ERROR type mismatch resolving `<Foo2 as Bar2>::Ok == ()` + type Ok = (); type Sibling = Foo2; + //~^ ERROR type mismatch resolving `<Foo2 as Bar2>::Ok == ()` } impl Bar2 for Foo2 { type Ok = u32; diff --git a/src/test/ui/associated-types/point-at-type-on-obligation-failure.stderr b/src/test/ui/associated-types/point-at-type-on-obligation-failure.stderr index 818702b7afe..7417a5aa3d4 100644 --- a/src/test/ui/associated-types/point-at-type-on-obligation-failure.stderr +++ b/src/test/ui/associated-types/point-at-type-on-obligation-failure.stderr @@ -1,8 +1,11 @@ error[E0271]: type mismatch resolving `<Foo2 as Bar2>::Ok == ()` - --> $DIR/point-at-type-on-obligation-failure.rs:13:15 + --> $DIR/point-at-type-on-obligation-failure.rs:14:5 | -LL | type Ok = (); - | ^^ expected `u32`, found `()` +LL | type Sibling: Bar2<Ok=Self::Ok>; + | ----------- required by this bound in `Bar::Sibling` +... +LL | type Sibling = Foo2; + | ^^^^^^^^^^^^^^^^^^^^ expected `()`, found `u32` error: aborting due to previous error diff --git a/src/test/ui/chalkify/impl_wf.rs b/src/test/ui/chalkify/impl_wf.rs index 465eb10241e..66f57c2d110 100644 --- a/src/test/ui/chalkify/impl_wf.rs +++ b/src/test/ui/chalkify/impl_wf.rs @@ -15,19 +15,6 @@ impl Foo for str { } // Implicit `T: Sized` bound. impl<T> Foo for Option<T> { } -impl Bar for () { - type Item = i32; -} - -impl<T> Bar for Option<T> { - type Item = Option<T>; -} - -impl Bar for f32 { - type Item = f32; - //~^ ERROR the trait bound `f32: Foo` is not satisfied -} - trait Baz<U: ?Sized> where U: Foo { } impl Baz<i32> for i32 { } diff --git a/src/test/ui/chalkify/impl_wf.stderr b/src/test/ui/chalkify/impl_wf.stderr index 4ca5ae472f2..24c7f0d82bd 100644 --- a/src/test/ui/chalkify/impl_wf.stderr +++ b/src/test/ui/chalkify/impl_wf.stderr @@ -10,18 +10,7 @@ LL | impl Foo for str { } = help: the trait `Sized` is not implemented for `str` error[E0277]: the trait bound `f32: Foo` is not satisfied - --> $DIR/impl_wf.rs:27:17 - | -LL | trait Bar { - | --- required by a bound in this -LL | type Item: Foo; - | --- required by this bound in `Bar` -... -LL | type Item = f32; - | ^^^ the trait `Foo` is not implemented for `f32` - -error[E0277]: the trait bound `f32: Foo` is not satisfied - --> $DIR/impl_wf.rs:35:6 + --> $DIR/impl_wf.rs:22:6 | LL | trait Baz<U: ?Sized> where U: Foo { } | --- required by this bound in `Baz` @@ -29,6 +18,6 @@ LL | trait Baz<U: ?Sized> where U: Foo { } LL | impl Baz<f32> for f32 { } | ^^^^^^^^ the trait `Foo` is not implemented for `f32` -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/chalkify/impl_wf_2.rs b/src/test/ui/chalkify/impl_wf_2.rs new file mode 100644 index 00000000000..758a7185e39 --- /dev/null +++ b/src/test/ui/chalkify/impl_wf_2.rs @@ -0,0 +1,33 @@ +// Split out of impl_wf.rs to work around rust aborting compilation early + +// compile-flags: -Z chalk + +trait Foo: Sized { } + +trait Bar { + type Item: Foo; +} + +impl Foo for i32 { } + +// Implicit `T: Sized` bound. +impl<T> Foo for Option<T> { } + +impl Bar for () { + type Item = i32; +} + +impl<T> Bar for Option<T> { + type Item = Option<T>; +} + +impl Bar for f32 { + type Item = f32; + //~^ ERROR the trait bound `f32: Foo` is not satisfied +} + +trait Baz<U: ?Sized> where U: Foo { } + +impl Baz<i32> for i32 { } + +fn main() {} diff --git a/src/test/ui/chalkify/impl_wf_2.stderr b/src/test/ui/chalkify/impl_wf_2.stderr new file mode 100644 index 00000000000..1da2144c0a5 --- /dev/null +++ b/src/test/ui/chalkify/impl_wf_2.stderr @@ -0,0 +1,12 @@ +error[E0277]: the trait bound `f32: Foo` is not satisfied + --> $DIR/impl_wf_2.rs:25:5 + | +LL | type Item: Foo; + | --- required by this bound in `Bar::Item` +... +LL | type Item = f32; + | ^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `f32` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/feature-gates/feature-gate-associated_type_bounds.rs b/src/test/ui/feature-gates/feature-gate-associated_type_bounds.rs index 9bce274027e..c5c8c5c1eca 100644 --- a/src/test/ui/feature-gates/feature-gate-associated_type_bounds.rs +++ b/src/test/ui/feature-gates/feature-gate-associated_type_bounds.rs @@ -14,6 +14,7 @@ impl Tr1 for S1 { type As1 = S2; } trait _Tr3 { type A: Iterator<Item: Copy>; //~^ ERROR associated type bounds are unstable + //~| ERROR the trait bound `<<Self as _Tr3>::A as std::iter::Iterator>::Item: std::marker::Copy` is not satisfied type B: Iterator<Item: 'static>; //~^ ERROR associated type bounds are unstable diff --git a/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr b/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr index 7f2704e1bc3..db78e287d65 100644 --- a/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr +++ b/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr @@ -8,7 +8,7 @@ LL | type A: Iterator<Item: Copy>; = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:18:22 + --> $DIR/feature-gate-associated_type_bounds.rs:19:22 | LL | type B: Iterator<Item: 'static>; | ^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | type B: Iterator<Item: 'static>; = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:22:20 + --> $DIR/feature-gate-associated_type_bounds.rs:23:20 | LL | struct _St1<T: Tr1<As1: Tr2>> { | ^^^^^^^^ @@ -26,7 +26,7 @@ LL | struct _St1<T: Tr1<As1: Tr2>> { = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:29:18 + --> $DIR/feature-gate-associated_type_bounds.rs:30:18 | LL | enum _En1<T: Tr1<As1: Tr2>> { | ^^^^^^^^ @@ -35,7 +35,7 @@ LL | enum _En1<T: Tr1<As1: Tr2>> { = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:36:19 + --> $DIR/feature-gate-associated_type_bounds.rs:37:19 | LL | union _Un1<T: Tr1<As1: Tr2>> { | ^^^^^^^^ @@ -44,7 +44,7 @@ LL | union _Un1<T: Tr1<As1: Tr2>> { = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:43:37 + --> $DIR/feature-gate-associated_type_bounds.rs:44:37 | LL | type _TaWhere1<T> where T: Iterator<Item: Copy> = T; | ^^^^^^^^^^ @@ -53,7 +53,7 @@ LL | type _TaWhere1<T> where T: Iterator<Item: Copy> = T; = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:46:22 + --> $DIR/feature-gate-associated_type_bounds.rs:47:22 | LL | fn _apit(_: impl Tr1<As1: Copy>) {} | ^^^^^^^^^ @@ -62,7 +62,7 @@ LL | fn _apit(_: impl Tr1<As1: Copy>) {} = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:48:26 + --> $DIR/feature-gate-associated_type_bounds.rs:49:26 | LL | fn _apit_dyn(_: &dyn Tr1<As1: Copy>) {} | ^^^^^^^^^ @@ -71,7 +71,7 @@ LL | fn _apit_dyn(_: &dyn Tr1<As1: Copy>) {} = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:51:24 + --> $DIR/feature-gate-associated_type_bounds.rs:52:24 | LL | fn _rpit() -> impl Tr1<As1: Copy> { S1 } | ^^^^^^^^^ @@ -80,7 +80,7 @@ LL | fn _rpit() -> impl Tr1<As1: Copy> { S1 } = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:54:31 + --> $DIR/feature-gate-associated_type_bounds.rs:55:31 | LL | fn _rpit_dyn() -> Box<dyn Tr1<As1: Copy>> { Box::new(S1) } | ^^^^^^^^^ @@ -89,7 +89,7 @@ LL | fn _rpit_dyn() -> Box<dyn Tr1<As1: Copy>> { Box::new(S1) } = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:57:23 + --> $DIR/feature-gate-associated_type_bounds.rs:58:23 | LL | const _cdef: impl Tr1<As1: Copy> = S1; | ^^^^^^^^^ @@ -98,7 +98,7 @@ LL | const _cdef: impl Tr1<As1: Copy> = S1; = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:63:24 + --> $DIR/feature-gate-associated_type_bounds.rs:64:24 | LL | static _sdef: impl Tr1<As1: Copy> = S1; | ^^^^^^^^^ @@ -107,7 +107,7 @@ LL | static _sdef: impl Tr1<As1: Copy> = S1; = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:70:21 + --> $DIR/feature-gate-associated_type_bounds.rs:71:21 | LL | let _: impl Tr1<As1: Copy> = S1; | ^^^^^^^^^ @@ -116,7 +116,7 @@ LL | let _: impl Tr1<As1: Copy> = S1; = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/feature-gate-associated_type_bounds.rs:57:14 + --> $DIR/feature-gate-associated_type_bounds.rs:58:14 | LL | const _cdef: impl Tr1<As1: Copy> = S1; | ^^^^^^^^^^^^^^^^^^^ @@ -124,7 +124,7 @@ LL | const _cdef: impl Tr1<As1: Copy> = S1; = help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/feature-gate-associated_type_bounds.rs:63:15 + --> $DIR/feature-gate-associated_type_bounds.rs:64:15 | LL | static _sdef: impl Tr1<As1: Copy> = S1; | ^^^^^^^^^^^^^^^^^^^ @@ -132,14 +132,30 @@ LL | static _sdef: impl Tr1<As1: Copy> = S1; = help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/feature-gate-associated_type_bounds.rs:70:12 + --> $DIR/feature-gate-associated_type_bounds.rs:71:12 | LL | let _: impl Tr1<As1: Copy> = S1; | ^^^^^^^^^^^^^^^^^^^ | = help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable -error: aborting due to 16 previous errors +error[E0277]: the trait bound `<<Self as _Tr3>::A as std::iter::Iterator>::Item: std::marker::Copy` is not satisfied + --> $DIR/feature-gate-associated_type_bounds.rs:15:28 + | +LL | type A: Iterator<Item: Copy>; + | ^^^^ the trait `std::marker::Copy` is not implemented for `<<Self as _Tr3>::A as std::iter::Iterator>::Item` + | + ::: $SRC_DIR/libcore/marker.rs:LL:COL + | +LL | pub trait Copy: Clone { + | --------------------- required by this bound in `std::marker::Copy` + | +help: consider further restricting the associated type + | +LL | trait _Tr3 where <<Self as _Tr3>::A as std::iter::Iterator>::Item: std::marker::Copy { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 17 previous errors -Some errors have detailed explanations: E0562, E0658. -For more information about an error, try `rustc --explain E0562`. +Some errors have detailed explanations: E0277, E0562, E0658. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/generator/sized-yield.stderr b/src/test/ui/generator/sized-yield.stderr index 2bcf66dbeae..e49dc91ec66 100644 --- a/src/test/ui/generator/sized-yield.stderr +++ b/src/test/ui/generator/sized-yield.stderr @@ -16,6 +16,11 @@ error[E0277]: the size for values of type `str` cannot be known at compilation t | LL | Pin::new(&mut gen).resume(()); | ^^^^^^ doesn't have a size known at compile-time + | + ::: $SRC_DIR/libcore/ops/generator.rs:LL:COL + | +LL | pub enum GeneratorState<Y, R> { + | - required by this bound in `std::ops::GeneratorState` | = help: the trait `Sized` is not implemented for `str` diff --git a/src/test/ui/generic-associated-types/issue-68641-check-gat-bounds.stderr b/src/test/ui/generic-associated-types/issue-68641-check-gat-bounds.stderr index 6ba79dd5437..b380f0da2ea 100644 --- a/src/test/ui/generic-associated-types/issue-68641-check-gat-bounds.stderr +++ b/src/test/ui/generic-associated-types/issue-68641-check-gat-bounds.stderr @@ -11,7 +11,7 @@ error[E0277]: the trait bound `T: Copy` is not satisfied --> $DIR/issue-68641-check-gat-bounds.rs:15:5 | LL | type Item<'a>: Copy; - | -------------------- required by `UnsafeCopy::Item` + | ---- required by this bound in `UnsafeCopy::Item` ... LL | type Item<'a> = T; | ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `T` diff --git a/src/test/ui/generic-associated-types/issue-68642-broken-llvm-ir.stderr b/src/test/ui/generic-associated-types/issue-68642-broken-llvm-ir.stderr index 15a66e25b19..61950478c32 100644 --- a/src/test/ui/generic-associated-types/issue-68642-broken-llvm-ir.stderr +++ b/src/test/ui/generic-associated-types/issue-68642-broken-llvm-ir.stderr @@ -11,7 +11,7 @@ error[E0277]: expected a `Fn<()>` closure, found `T` --> $DIR/issue-68642-broken-llvm-ir.rs:15:5 | LL | type F<'a>: Fn() -> u32; - | ------------------------ required by `Fun::F` + | ----------- required by this bound in `Fun::F` ... LL | type F<'a> = Self; | ^^^^^^^^^^^^^^^^^^ expected an `Fn<()>` closure, found `T` diff --git a/src/test/ui/generic-associated-types/issue-68643-broken-mir.stderr b/src/test/ui/generic-associated-types/issue-68643-broken-mir.stderr index 9b2ddb23267..13980618987 100644 --- a/src/test/ui/generic-associated-types/issue-68643-broken-mir.stderr +++ b/src/test/ui/generic-associated-types/issue-68643-broken-mir.stderr @@ -11,7 +11,7 @@ error[E0277]: expected a `Fn<()>` closure, found `T` --> $DIR/issue-68643-broken-mir.rs:15:5 | LL | type F<'a>: Fn() -> u32; - | ------------------------ required by `Fun::F` + | ----------- required by this bound in `Fun::F` ... LL | type F<'a> = Self; | ^^^^^^^^^^^^^^^^^^ expected an `Fn<()>` closure, found `T` diff --git a/src/test/ui/generic-associated-types/issue-68644-codegen-selection.stderr b/src/test/ui/generic-associated-types/issue-68644-codegen-selection.stderr index f7bfab35052..81124251469 100644 --- a/src/test/ui/generic-associated-types/issue-68644-codegen-selection.stderr +++ b/src/test/ui/generic-associated-types/issue-68644-codegen-selection.stderr @@ -11,7 +11,7 @@ error[E0277]: expected a `Fn<()>` closure, found `T` --> $DIR/issue-68644-codegen-selection.rs:15:5 | LL | type F<'a>: Fn() -> u32; - | ------------------------ required by `Fun::F` + | ----------- required by this bound in `Fun::F` ... LL | type F<'a> = Self; | ^^^^^^^^^^^^^^^^^^ expected an `Fn<()>` closure, found `T` diff --git a/src/test/ui/generic-associated-types/issue-68645-codegen-fulfillment.stderr b/src/test/ui/generic-associated-types/issue-68645-codegen-fulfillment.stderr index 6c2d330a19a..22f50b39498 100644 --- a/src/test/ui/generic-associated-types/issue-68645-codegen-fulfillment.stderr +++ b/src/test/ui/generic-associated-types/issue-68645-codegen-fulfillment.stderr @@ -11,7 +11,7 @@ error[E0277]: expected a `Fn<()>` closure, found `T` --> $DIR/issue-68645-codegen-fulfillment.rs:15:5 | LL | type F<'a>: Fn() -> u32; - | ------------------------ required by `Fun::F` + | ----------- required by this bound in `Fun::F` ... LL | type F<'a> = Self; | ^^^^^^^^^^^^^^^^^^ expected an `Fn<()>` closure, found `T` diff --git a/src/test/ui/generic-associated-types/issue-68656-unsized-values.stderr b/src/test/ui/generic-associated-types/issue-68656-unsized-values.stderr index a9336151b6a..c4ee2c4e618 100644 --- a/src/test/ui/generic-associated-types/issue-68656-unsized-values.stderr +++ b/src/test/ui/generic-associated-types/issue-68656-unsized-values.stderr @@ -11,7 +11,7 @@ error[E0271]: type mismatch resolving `<T as Deref>::Target == T` --> $DIR/issue-68656-unsized-values.rs:16:5 | LL | type Item<'a>: std::ops::Deref<Target = T>; - | ------------------------------------------- required by `UnsafeCopy::Item` + | ---------- required by this bound in `UnsafeCopy::Item` ... LL | impl<T: Copy + std::ops::Deref> UnsafeCopy<T> for T { | - this type parameter diff --git a/src/test/ui/generic-associated-types/unsatisfied-outlives-bound.rs b/src/test/ui/generic-associated-types/unsatisfied-outlives-bound.rs index 7510c58d574..d957cae3081 100644 --- a/src/test/ui/generic-associated-types/unsatisfied-outlives-bound.rs +++ b/src/test/ui/generic-associated-types/unsatisfied-outlives-bound.rs @@ -7,7 +7,7 @@ trait ATy { impl<'b> ATy for &'b () { type Item<'a> = &'b (); - //~^ ERROR does not fulfill the required lifetime + //~^ ERROR lifetime bound not satisfied } trait StaticTy { @@ -16,7 +16,7 @@ trait StaticTy { impl StaticTy for () { type Item<'a> = &'a (); - //~^ ERROR does not fulfill the required lifetime + //~^ ERROR lifetime bound not satisfied } fn main() {} diff --git a/src/test/ui/generic-associated-types/unsatisfied-outlives-bound.stderr b/src/test/ui/generic-associated-types/unsatisfied-outlives-bound.stderr index 5d612284a21..f8b96ef3b8a 100644 --- a/src/test/ui/generic-associated-types/unsatisfied-outlives-bound.stderr +++ b/src/test/ui/generic-associated-types/unsatisfied-outlives-bound.stderr @@ -1,23 +1,33 @@ -error[E0477]: the type `&'b ()` does not fulfill the required lifetime +error[E0478]: lifetime bound not satisfied --> $DIR/unsatisfied-outlives-bound.rs:9:5 | LL | type Item<'a> = &'b (); | ^^^^^^^^^^^^^^^^^^^^^^^ | -note: type must outlive the lifetime `'a` as defined on the associated item at 9:15 +note: lifetime parameter instantiated with the lifetime `'b` as defined on the impl at 8:6 + --> $DIR/unsatisfied-outlives-bound.rs:8:6 + | +LL | impl<'b> ATy for &'b () { + | ^^ +note: but lifetime parameter must outlive the lifetime `'a` as defined on the associated item at 9:15 --> $DIR/unsatisfied-outlives-bound.rs:9:15 | LL | type Item<'a> = &'b (); | ^^ -error[E0477]: the type `&'a ()` does not fulfill the required lifetime +error[E0478]: lifetime bound not satisfied --> $DIR/unsatisfied-outlives-bound.rs:18:5 | LL | type Item<'a> = &'a (); | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: type must satisfy the static lifetime +note: lifetime parameter instantiated with the lifetime `'a` as defined on the associated item at 18:15 + --> $DIR/unsatisfied-outlives-bound.rs:18:15 + | +LL | type Item<'a> = &'a (); + | ^^ + = note: but lifetime parameter must outlive the static lifetime error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0477`. +For more information about this error, try `rustc --explain E0478`. diff --git a/src/test/ui/inference/cannot-infer-async-enabled-impl-trait-bindings.stderr b/src/test/ui/inference/cannot-infer-async-enabled-impl-trait-bindings.stderr index b6e3bb190ea..ec03d18924f 100644 --- a/src/test/ui/inference/cannot-infer-async-enabled-impl-trait-bindings.stderr +++ b/src/test/ui/inference/cannot-infer-async-enabled-impl-trait-bindings.stderr @@ -7,13 +7,13 @@ LL | #![feature(impl_trait_in_bindings)] = note: `#[warn(incomplete_features)]` on by default = note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information -error[E0282]: type annotations needed for `impl Future` - --> $DIR/cannot-infer-async-enabled-impl-trait-bindings.rs:13:9 +error[E0282]: type annotations needed for `impl std::future::Future` + --> $DIR/cannot-infer-async-enabled-impl-trait-bindings.rs:13:20 | LL | let fut = async { | --- consider giving `fut` the explicit type `impl Future`, with the type parameters specified LL | make_unit()?; - | ^^^^^^^^^^^^ cannot infer type + | ^ cannot infer type error: aborting due to previous error; 1 warning emitted diff --git a/src/test/ui/inference/cannot-infer-async.stderr b/src/test/ui/inference/cannot-infer-async.stderr index bf31fb85cf6..92a9045f6db 100644 --- a/src/test/ui/inference/cannot-infer-async.stderr +++ b/src/test/ui/inference/cannot-infer-async.stderr @@ -1,10 +1,10 @@ error[E0282]: type annotations needed - --> $DIR/cannot-infer-async.rs:11:9 + --> $DIR/cannot-infer-async.rs:11:20 | LL | let fut = async { | --- consider giving `fut` a type LL | make_unit()?; - | ^^^^^^^^^^^^ cannot infer type + | ^ cannot infer type error: aborting due to previous error diff --git a/src/test/ui/inference/cannot-infer-closure.stderr b/src/test/ui/inference/cannot-infer-closure.stderr index c26c24f1dc5..d5366e422db 100644 --- a/src/test/ui/inference/cannot-infer-closure.stderr +++ b/src/test/ui/inference/cannot-infer-closure.stderr @@ -1,8 +1,8 @@ error[E0282]: type annotations needed for the closure `fn((), ()) -> std::result::Result<(), _>` - --> $DIR/cannot-infer-closure.rs:3:9 + --> $DIR/cannot-infer-closure.rs:3:15 | LL | Err(a)?; - | ^^^^^^^ cannot infer type + | ^ cannot infer type | help: give this closure an explicit return type without `_` placeholders | diff --git a/src/test/ui/issues/issue-20605.stderr b/src/test/ui/issues/issue-20605.stderr index e8d16a55e92..25fa575fc60 100644 --- a/src/test/ui/issues/issue-20605.stderr +++ b/src/test/ui/issues/issue-20605.stderr @@ -4,8 +4,9 @@ error[E0277]: the size for values of type `dyn Iterator<Item = &'a mut u8>` cann LL | for item in *things { *item = 0 } | ^^^^^^^ doesn't have a size known at compile-time | - = help: the trait `Sized` is not implemented for `dyn Iterator<Item = &'a mut u8>` - = note: required by `into_iter` + = help: the trait `std::marker::Sized` is not implemented for `dyn std::iter::Iterator<Item = &'a mut u8>` + = note: required because of the requirements on the impl of `std::iter::IntoIterator` for `dyn std::iter::Iterator<Item = &'a mut u8>` + = note: required by `std::iter::IntoIterator::into_iter` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-20831-debruijn.rs b/src/test/ui/issues/issue-20831-debruijn.rs index d0e15cb393a..20d980763ea 100644 --- a/src/test/ui/issues/issue-20831-debruijn.rs +++ b/src/test/ui/issues/issue-20831-debruijn.rs @@ -28,9 +28,6 @@ impl<'a> Publisher<'a> for MyStruct<'a> { fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) { // Not obvious, but there is an implicit lifetime here -------^ //~^^ ERROR cannot infer - //~| ERROR cannot infer - //~| ERROR mismatched types - //~| ERROR mismatched types // // The fact that `Publisher` is using an implicit lifetime is // what was causing the debruijn accounting to be off, so diff --git a/src/test/ui/issues/issue-20831-debruijn.stderr b/src/test/ui/issues/issue-20831-debruijn.stderr index 1ab89e818e3..1764dd3cf67 100644 --- a/src/test/ui/issues/issue-20831-debruijn.stderr +++ b/src/test/ui/issues/issue-20831-debruijn.stderr @@ -1,88 +1,20 @@ -error[E0308]: mismatched types - --> $DIR/issue-20831-debruijn.rs:28:5 - | -LL | / fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) { -LL | | // Not obvious, but there is an implicit lifetime here -------^ -LL | | -LL | | -... | -LL | | self.sub = t; -LL | | } - | |_____^ lifetime mismatch - | - = note: expected type `'a` - found type `'_` -note: the anonymous lifetime #2 defined on the method body at 28:5... - --> $DIR/issue-20831-debruijn.rs:28:5 +error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements + --> $DIR/issue-20831-debruijn.rs:28:33 | LL | fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...does not necessarily outlive the lifetime `'a` as defined on the impl at 26:6 - --> $DIR/issue-20831-debruijn.rs:26:6 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -LL | impl<'a> Publisher<'a> for MyStruct<'a> { - | ^^ - -error[E0308]: mismatched types +note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the method body at 28:5... --> $DIR/issue-20831-debruijn.rs:28:5 | LL | / fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) { LL | | // Not obvious, but there is an implicit lifetime here -------^ LL | | -LL | | +LL | | // ... | LL | | self.sub = t; LL | | } - | |_____^ lifetime mismatch - | - = note: expected type `'a` - found type `'_` -note: the lifetime `'a` as defined on the impl at 26:6... - --> $DIR/issue-20831-debruijn.rs:26:6 - | -LL | impl<'a> Publisher<'a> for MyStruct<'a> { - | ^^ -note: ...does not necessarily outlive the anonymous lifetime #2 defined on the method body at 28:5 - --> $DIR/issue-20831-debruijn.rs:28:5 - | -LL | fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements - --> $DIR/issue-20831-debruijn.rs:28:33 - | -LL | fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the method body at 28:5... - --> $DIR/issue-20831-debruijn.rs:28:5 - | -LL | fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...but the lifetime must also be valid for the lifetime `'a` as defined on the impl at 26:6... - --> $DIR/issue-20831-debruijn.rs:26:6 - | -LL | impl<'a> Publisher<'a> for MyStruct<'a> { - | ^^ -note: ...so that the types are compatible - --> $DIR/issue-20831-debruijn.rs:28:33 - | -LL | fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: expected `Publisher<'_>` - found `Publisher<'_>` - -error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements - --> $DIR/issue-20831-debruijn.rs:28:33 - | -LL | fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the method body at 28:5... - --> $DIR/issue-20831-debruijn.rs:28:5 - | -LL | fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | |_____^ note: ...but the lifetime must also be valid for the lifetime `'a` as defined on the impl at 26:6... --> $DIR/issue-20831-debruijn.rs:26:6 | @@ -96,7 +28,6 @@ LL | fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher = note: expected `Publisher<'_>` found `Publisher<'_>` -error: aborting due to 4 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0308, E0495. -For more information about an error, try `rustc --explain E0308`. +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/issues/issue-21946.rs b/src/test/ui/issues/issue-21946.rs index 0a9f8f50bdc..d0c052cb2fd 100644 --- a/src/test/ui/issues/issue-21946.rs +++ b/src/test/ui/issues/issue-21946.rs @@ -5,7 +5,6 @@ trait Foo { struct FooStruct; impl Foo for FooStruct { - //~^ ERROR overflow evaluating the requirement `<FooStruct as Foo>::A == _` type A = <FooStruct as Foo>::A; //~^ ERROR overflow evaluating the requirement `<FooStruct as Foo>::A == _` } diff --git a/src/test/ui/issues/issue-21946.stderr b/src/test/ui/issues/issue-21946.stderr index 582ce393d7f..8b96e0f3382 100644 --- a/src/test/ui/issues/issue-21946.stderr +++ b/src/test/ui/issues/issue-21946.stderr @@ -1,15 +1,9 @@ -error[E0275]: overflow evaluating the requirement `<FooStruct as Foo>::A == _` - --> $DIR/issue-21946.rs:7:6 - | -LL | impl Foo for FooStruct { - | ^^^ - -error[E0275]: overflow evaluating the requirement `<FooStruct as Foo>::A == _` - --> $DIR/issue-21946.rs:9:5 +error[E0275]: overflow evaluating the requirement `<FooStruct as Foo>::A` + --> $DIR/issue-21946.rs:8:5 | LL | type A = <FooStruct as Foo>::A; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0275`. diff --git a/src/test/ui/issues/issue-23122-1.rs b/src/test/ui/issues/issue-23122-1.rs index d6f64650f36..0937e029ef4 100644 --- a/src/test/ui/issues/issue-23122-1.rs +++ b/src/test/ui/issues/issue-23122-1.rs @@ -5,7 +5,6 @@ trait Next { struct GetNext<T: Next> { t: T } impl<T: Next> Next for GetNext<T> { - //~^ ERROR overflow evaluating the requirement type Next = <GetNext<T> as Next>::Next; //~^ ERROR overflow evaluating the requirement } diff --git a/src/test/ui/issues/issue-23122-1.stderr b/src/test/ui/issues/issue-23122-1.stderr index 4e2e837c07c..f8374905370 100644 --- a/src/test/ui/issues/issue-23122-1.stderr +++ b/src/test/ui/issues/issue-23122-1.stderr @@ -1,15 +1,9 @@ -error[E0275]: overflow evaluating the requirement `<GetNext<T> as Next>::Next == _` - --> $DIR/issue-23122-1.rs:7:15 - | -LL | impl<T: Next> Next for GetNext<T> { - | ^^^^ - -error[E0275]: overflow evaluating the requirement `<GetNext<T> as Next>::Next == _` - --> $DIR/issue-23122-1.rs:9:5 +error[E0275]: overflow evaluating the requirement `<GetNext<T> as Next>::Next` + --> $DIR/issue-23122-1.rs:8:5 | LL | type Next = <GetNext<T> as Next>::Next; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0275`. diff --git a/src/test/ui/issues/issue-23122-2.rs b/src/test/ui/issues/issue-23122-2.rs index 695712d2cc9..84abebf6b74 100644 --- a/src/test/ui/issues/issue-23122-2.rs +++ b/src/test/ui/issues/issue-23122-2.rs @@ -5,7 +5,6 @@ trait Next { struct GetNext<T: Next> { t: T } impl<T: Next> Next for GetNext<T> { - //~^ ERROR overflow evaluating the requirement type Next = <GetNext<T::Next> as Next>::Next; //~^ ERROR overflow evaluating the requirement } diff --git a/src/test/ui/issues/issue-23122-2.stderr b/src/test/ui/issues/issue-23122-2.stderr index 60dbb15d0f9..0d645bbcea5 100644 --- a/src/test/ui/issues/issue-23122-2.stderr +++ b/src/test/ui/issues/issue-23122-2.stderr @@ -1,14 +1,5 @@ -error[E0275]: overflow evaluating the requirement `<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<T as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next: Sized` - --> $DIR/issue-23122-2.rs:7:15 - | -LL | impl<T: Next> Next for GetNext<T> { - | ^^^^ - | - = help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`issue_23122_2`) - = note: required because of the requirements on the impl of `Next` for `GetNext<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<T as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next>` - -error[E0275]: overflow evaluating the requirement `<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<T as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next: Sized` - --> $DIR/issue-23122-2.rs:9:5 +error[E0275]: overflow evaluating the requirement `<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<T as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next: std::marker::Sized` + --> $DIR/issue-23122-2.rs:8:5 | LL | type Next = <GetNext<T::Next> as Next>::Next; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -16,6 +7,6 @@ LL | type Next = <GetNext<T::Next> as Next>::Next; = help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`issue_23122_2`) = note: required because of the requirements on the impl of `Next` for `GetNext<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<T as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next>` -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0275`. diff --git a/src/test/ui/issues/issue-24204.rs b/src/test/ui/issues/issue-24204.rs index 61671b32e9b..df72283de23 100644 --- a/src/test/ui/issues/issue-24204.rs +++ b/src/test/ui/issues/issue-24204.rs @@ -12,6 +12,6 @@ trait Trait: Sized { } fn test<T: Trait<B=i32>>(b: i32) -> T where T::A: MultiDispatch<i32> { T::new(b) } -//~^ ERROR type mismatch resolving +//~^ ERROR mismatched types fn main() {} diff --git a/src/test/ui/issues/issue-24204.stderr b/src/test/ui/issues/issue-24204.stderr index d5cbcf786bf..9d66c9ff0a8 100644 --- a/src/test/ui/issues/issue-24204.stderr +++ b/src/test/ui/issues/issue-24204.stderr @@ -1,15 +1,10 @@ -error[E0271]: type mismatch resolving `<<T as Trait>::A as MultiDispatch<i32>>::O == T` - --> $DIR/issue-24204.rs:14:12 +error[E0308]: mismatched types + --> $DIR/issue-24204.rs:14:72 | -LL | trait Trait: Sized { - | ----- required by a bound in this -LL | type A: MultiDispatch<Self::B, O = Self>; - | -------- required by this bound in `Trait` -... LL | fn test<T: Trait<B=i32>>(b: i32) -> T where T::A: MultiDispatch<i32> { T::new(b) } - | - ^^^^^^^^^^^^ expected type parameter `T`, found associated type - | | - | this type parameter + | - - ^^^^^^^^^ expected type parameter `T`, found associated type + | | | + | this type parameter expected `T` because of return type | = note: expected type parameter `T` found associated type `<<T as Trait>::A as MultiDispatch<i32>>::O` @@ -17,4 +12,4 @@ LL | fn test<T: Trait<B=i32>>(b: i32) -> T where T::A: MultiDispatch<i32> { T::n error: aborting due to previous error -For more information about this error, try `rustc --explain E0271`. +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/issues/issue-28098.stderr b/src/test/ui/issues/issue-28098.stderr index df552fc2d0e..04075911111 100644 --- a/src/test/ui/issues/issue-28098.stderr +++ b/src/test/ui/issues/issue-28098.stderr @@ -13,8 +13,9 @@ error[E0277]: `bool` is not an iterator LL | for _ in false {} | ^^^^^ `bool` is not an iterator | - = help: the trait `Iterator` is not implemented for `bool` - = note: required by `into_iter` + = help: the trait `std::iter::Iterator` is not implemented for `bool` + = note: required because of the requirements on the impl of `std::iter::IntoIterator` for `bool` + = note: required by `std::iter::IntoIterator::into_iter` error[E0277]: `()` is not an iterator --> $DIR/issue-28098.rs:9:28 diff --git a/src/test/ui/issues/issue-33941.stderr b/src/test/ui/issues/issue-33941.stderr index aeab923d2df..81d97bdbf12 100644 --- a/src/test/ui/issues/issue-33941.stderr +++ b/src/test/ui/issues/issue-33941.stderr @@ -15,7 +15,9 @@ LL | for _ in HashMap::new().iter().cloned() {} | = note: expected tuple `(&_, &_)` found reference `&_` - = note: required because of the requirements on the impl of `Iterator` for `Cloned<std::collections::hash_map::Iter<'_, _, _>>` + = note: required because of the requirements on the impl of `std::iter::Iterator` for `std::iter::Cloned<std::collections::hash_map::Iter<'_, _, _>>` + = note: required because of the requirements on the impl of `std::iter::IntoIterator` for `std::iter::Cloned<std::collections::hash_map::Iter<'_, _, _>>` + = note: required by `std::iter::IntoIterator::into_iter` error[E0271]: type mismatch resolving `<std::collections::hash_map::Iter<'_, _, _> as Iterator>::Item == &_` --> $DIR/issue-33941.rs:4:14 diff --git a/src/test/ui/issues/issue-38091.stderr b/src/test/ui/issues/issue-38091.stderr index 81beec80263..f47fd8d1b0d 100644 --- a/src/test/ui/issues/issue-38091.stderr +++ b/src/test/ui/issues/issue-38091.stderr @@ -11,7 +11,7 @@ error[E0277]: the trait bound `(): Valid` is not satisfied --> $DIR/issue-38091.rs:9:5 | LL | type Ty: Valid; - | --------------- required by `Iterate::Ty` + | ----- required by this bound in `Iterate::Ty` ... LL | default type Ty = (); | ^^^^^^^^^^^^^^^^^^^^^ the trait `Valid` is not implemented for `()` diff --git a/src/test/ui/issues/issue-43784-associated-type.stderr b/src/test/ui/issues/issue-43784-associated-type.stderr index 039852ad165..7b656ef8559 100644 --- a/src/test/ui/issues/issue-43784-associated-type.stderr +++ b/src/test/ui/issues/issue-43784-associated-type.stderr @@ -1,8 +1,11 @@ -error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/issue-43784-associated-type.rs:14:18 +error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied + --> $DIR/issue-43784-associated-type.rs:14:5 | +LL | type Assoc: Partial<Self>; + | ------------- required by this bound in `Complete::Assoc` +... LL | type Assoc = T; - | ^ the trait `Copy` is not implemented for `T` + | ^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` | help: consider restricting type parameter `T` | diff --git a/src/test/ui/issues/issue-43784-supertrait.stderr b/src/test/ui/issues/issue-43784-supertrait.stderr index d92e4fa9e4a..c73536ba973 100644 --- a/src/test/ui/issues/issue-43784-supertrait.stderr +++ b/src/test/ui/issues/issue-43784-supertrait.stderr @@ -1,6 +1,9 @@ error[E0277]: the trait bound `T: Copy` is not satisfied --> $DIR/issue-43784-supertrait.rs:8:9 | +LL | pub trait Complete: Partial { + | ------- required by this bound in `Complete` +... LL | impl<T> Complete for T {} | ^^^^^^^^ the trait `Copy` is not implemented for `T` | diff --git a/src/test/ui/issues/issue-65673.stderr b/src/test/ui/issues/issue-65673.stderr index aa43ac9414f..64cc0bab3f3 100644 --- a/src/test/ui/issues/issue-65673.stderr +++ b/src/test/ui/issues/issue-65673.stderr @@ -1,13 +1,11 @@ error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time - --> $DIR/issue-65673.rs:9:16 + --> $DIR/issue-65673.rs:9:5 | -LL | trait WithType { - | -------- required by a bound in this LL | type Ctx; - | --------- required by this bound in `WithType` + | --------- required by this bound in `WithType::Ctx` ... LL | type Ctx = dyn Alias<T>; - | ^^^^^^^^^^^^ doesn't have a size known at compile-time + | ^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `(dyn Trait + 'static)` diff --git a/src/test/ui/never_type/issue-51506.stderr b/src/test/ui/never_type/issue-51506.stderr index c54cbe9b4d1..16d93c18900 100644 --- a/src/test/ui/never_type/issue-51506.stderr +++ b/src/test/ui/never_type/issue-51506.stderr @@ -2,7 +2,7 @@ error[E0277]: `!` is not an iterator --> $DIR/issue-51506.rs:13:5 | LL | type Out: Iterator<Item = u32>; - | ------------------------------- required by `Trait::Out` + | -------------------- required by this bound in `Trait::Out` ... LL | default type Out = !; | ^^^^^^^^^^^^^^^^^^^^^ `!` is not an iterator diff --git a/src/test/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.rs b/src/test/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.rs index d3964a7f515..44dcd191d1b 100644 --- a/src/test/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.rs +++ b/src/test/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.rs @@ -32,5 +32,4 @@ fn main() { let _x = <fn(&())>::make_f(); //~^ higher-ranked subtype error //~| higher-ranked subtype error - //~| higher-ranked subtype error } diff --git a/src/test/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.stderr b/src/test/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.stderr index 70fb877d716..190b520c678 100644 --- a/src/test/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.stderr +++ b/src/test/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.stderr @@ -10,11 +10,5 @@ error: higher-ranked subtype error LL | let _x = <fn(&())>::make_f(); | ^^^^^^^^^^^^^^^^^^^ -error: higher-ranked subtype error - --> $DIR/impl-fn-ignore-binder-via-bottom.rs:32:14 - | -LL | let _x = <fn(&())>::make_f(); - | ^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors diff --git a/src/test/ui/privacy/private-in-public-assoc-ty.rs b/src/test/ui/privacy/private-in-public-assoc-ty.rs index 5238894a974..fdf0bc38391 100644 --- a/src/test/ui/privacy/private-in-public-assoc-ty.rs +++ b/src/test/ui/privacy/private-in-public-assoc-ty.rs @@ -29,7 +29,11 @@ mod m { //~| WARN this was previously accepted type Alias1: PrivTr; type Alias2: PubTrAux1<Priv> = u8; + //~^ WARN private type `m::Priv` in public interface + //~| WARN this was previously accepted type Alias3: PubTrAux2<A = Priv> = u8; + //~^ WARN private type `m::Priv` in public interface + //~| WARN this was previously accepted type Alias4 = Priv; //~^ ERROR private type `Priv` in public interface diff --git a/src/test/ui/privacy/private-in-public-assoc-ty.stderr b/src/test/ui/privacy/private-in-public-assoc-ty.stderr index acc6e20cf33..768dca17e07 100644 --- a/src/test/ui/privacy/private-in-public-assoc-ty.stderr +++ b/src/test/ui/privacy/private-in-public-assoc-ty.stderr @@ -10,14 +10,8 @@ LL | type A = Priv; warning: private trait `PrivTr` in public interface (error E0445) --> $DIR/private-in-public-assoc-ty.rs:23:5 | -LL | / pub trait PubTr { -LL | | -LL | | -LL | | -... | -LL | | fn infer_exist() -> Self::Exist; -LL | | } - | |_____^ +LL | type Alias1: PrivTr; + | ^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(private_in_public)]` on by default = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! @@ -26,14 +20,8 @@ LL | | } warning: private type `Priv` in public interface (error E0446) --> $DIR/private-in-public-assoc-ty.rs:23:5 | -LL | / pub trait PubTr { -LL | | -LL | | -LL | | -... | -LL | | fn infer_exist() -> Self::Exist; -LL | | } - | |_____^ +LL | type Alias2: PubTrAux1<Priv> = u8; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537> @@ -41,14 +29,8 @@ LL | | } warning: private type `Priv` in public interface (error E0446) --> $DIR/private-in-public-assoc-ty.rs:23:5 | -LL | / pub trait PubTr { -LL | | -LL | | -LL | | -... | -LL | | fn infer_exist() -> Self::Exist; -LL | | } - | |_____^ +LL | type Alias3: PubTrAux2<A = Priv> = u8; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537> diff --git a/src/test/ui/privacy/private-in-public-warn.rs b/src/test/ui/privacy/private-in-public-warn.rs index 3022b470b7d..1c8706d8ad2 100644 --- a/src/test/ui/privacy/private-in-public-warn.rs +++ b/src/test/ui/privacy/private-in-public-warn.rs @@ -55,9 +55,9 @@ mod traits { pub trait Tr2<T: PrivTr> {} //~ ERROR private trait `traits::PrivTr` in public interface //~^ WARNING hard error pub trait Tr3 { + type Alias: PrivTr; //~^ ERROR private trait `traits::PrivTr` in public interface //~| WARNING hard error - type Alias: PrivTr; fn f<T: PrivTr>(arg: T) {} //~ ERROR private trait `traits::PrivTr` in public interface //~^ WARNING hard error } diff --git a/src/test/ui/privacy/private-in-public-warn.stderr b/src/test/ui/privacy/private-in-public-warn.stderr index 36577a60102..f50dc48f8ad 100644 --- a/src/test/ui/privacy/private-in-public-warn.stderr +++ b/src/test/ui/privacy/private-in-public-warn.stderr @@ -130,16 +130,10 @@ LL | pub trait Tr2<T: PrivTr> {} = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537> error: private trait `traits::PrivTr` in public interface (error E0445) - --> $DIR/private-in-public-warn.rs:57:5 - | -LL | / pub trait Tr3 { -LL | | -LL | | -LL | | type Alias: PrivTr; -LL | | fn f<T: PrivTr>(arg: T) {} -LL | | -LL | | } - | |_____^ + --> $DIR/private-in-public-warn.rs:58:9 + | +LL | type Alias: PrivTr; + | ^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537> diff --git a/src/test/ui/privacy/pub-priv-dep/pub-priv1.rs b/src/test/ui/privacy/pub-priv-dep/pub-priv1.rs index e485263affc..5476e35b5f6 100644 --- a/src/test/ui/privacy/pub-priv-dep/pub-priv1.rs +++ b/src/test/ui/privacy/pub-priv-dep/pub-priv1.rs @@ -1,5 +1,5 @@ - // aux-crate:priv:priv_dep=priv_dep.rs - // aux-build:pub_dep.rs +// aux-crate:priv:priv_dep=priv_dep.rs +// aux-build:pub_dep.rs #![deny(exported_private_dependencies)] // This crate is a private dependency @@ -7,20 +7,20 @@ extern crate priv_dep; // This crate is a public dependency extern crate pub_dep; -use priv_dep::{OtherType, OtherTrait}; +use priv_dep::{OtherTrait, OtherType}; use pub_dep::PubType; // Type from private dependency used in private // type - this is fine struct PrivateType { - field: OtherType + field: OtherType, } pub struct PublicType { pub field: OtherType, //~^ ERROR type `OtherType` from private dependency 'priv_dep' in public interface - priv_field: OtherType, // Private field - this is fine - pub other_field: PubType // Type from public dependency - this is fine + priv_field: OtherType, // Private field - this is fine + pub other_field: PubType, // Type from public dependency - this is fine } impl PublicType { @@ -32,14 +32,13 @@ impl PublicType { pub trait MyPubTrait { type Foo: OtherTrait; + //~^ ERROR trait `priv_dep::OtherTrait` from private dependency 'priv_dep' in public interface } //~^^^ ERROR trait `OtherTrait` from private dependency 'priv_dep' in public interface pub struct AllowedPrivType { #[allow(exported_private_dependencies)] - pub allowed: OtherType + pub allowed: OtherType, } - - fn main() {} diff --git a/src/test/ui/privacy/pub-priv-dep/pub-priv1.stderr b/src/test/ui/privacy/pub-priv-dep/pub-priv1.stderr index 3b5b7823443..e6fd6fc7bb8 100644 --- a/src/test/ui/privacy/pub-priv-dep/pub-priv1.stderr +++ b/src/test/ui/privacy/pub-priv-dep/pub-priv1.stderr @@ -19,10 +19,8 @@ LL | pub fn pub_fn(param: OtherType) {} error: trait `OtherTrait` from private dependency 'priv_dep' in public interface --> $DIR/pub-priv1.rs:33:1 | -LL | / pub trait MyPubTrait { -LL | | type Foo: OtherTrait; -LL | | } - | |_^ +LL | type Foo: OtherTrait; + | ^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/src/test/ui/question-mark-type-infer.stderr b/src/test/ui/question-mark-type-infer.stderr index f530534ec80..a896d587533 100644 --- a/src/test/ui/question-mark-type-infer.stderr +++ b/src/test/ui/question-mark-type-infer.stderr @@ -1,4 +1,4 @@ -error[E0284]: type annotations needed +error[E0283]: type annotations needed --> $DIR/question-mark-type-infer.rs:12:21 | LL | l.iter().map(f).collect()? @@ -12,4 +12,4 @@ LL | l.iter().map(f).collect::<B>()? error: aborting due to previous error -For more information about this error, try `rustc --explain E0284`. +For more information about this error, try `rustc --explain E0283`. diff --git a/src/test/ui/range/range-1.stderr b/src/test/ui/range/range-1.stderr index a7557320faa..e380e5b2f91 100644 --- a/src/test/ui/range/range-1.stderr +++ b/src/test/ui/range/range-1.stderr @@ -17,7 +17,7 @@ error[E0277]: the size for values of type `[{integer}]` cannot be known at compi | LL | let range = *arr..; | ^^^^^^ doesn't have a size known at compile-time - | + | ::: $SRC_DIR/core/src/ops/range.rs:LL:COL | LL | pub struct RangeFrom<Idx> { diff --git a/src/test/ui/regions/regions-assoc-type-region-bound-in-trait-not-met.rs b/src/test/ui/regions/regions-assoc-type-region-bound-in-trait-not-met.rs index 26cb40bb5c2..0f86e37b7e5 100644 --- a/src/test/ui/regions/regions-assoc-type-region-bound-in-trait-not-met.rs +++ b/src/test/ui/regions/regions-assoc-type-region-bound-in-trait-not-met.rs @@ -12,13 +12,13 @@ impl<'a> Foo<'a> for &'a i16 { } impl<'a> Foo<'static> for &'a i32 { - //~^ ERROR cannot infer type Value = &'a i32; + //~^ ERROR lifetime bound not satisfied } impl<'a,'b> Foo<'b> for &'a i64 { - //~^ ERROR cannot infer type Value = &'a i32; + //~^ ERROR lifetime bound not satisfied } fn main() { } diff --git a/src/test/ui/regions/regions-assoc-type-region-bound-in-trait-not-met.stderr b/src/test/ui/regions/regions-assoc-type-region-bound-in-trait-not-met.stderr index c134b3b3ed5..feb9c90bc8f 100644 --- a/src/test/ui/regions/regions-assoc-type-region-bound-in-trait-not-met.stderr +++ b/src/test/ui/regions/regions-assoc-type-region-bound-in-trait-not-met.stderr @@ -1,57 +1,33 @@ -error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements - --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:14:10 +error[E0478]: lifetime bound not satisfied + --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:15:5 | -LL | impl<'a> Foo<'static> for &'a i32 { - | ^^^^^^^^^^^^ +LL | type Value = &'a i32; + | ^^^^^^^^^^^^^^^^^^^^^ | -note: first, the lifetime cannot outlive the lifetime `'a` as defined on the impl at 14:6... +note: lifetime parameter instantiated with the lifetime `'a` as defined on the impl at 14:6 --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:14:6 | LL | impl<'a> Foo<'static> for &'a i32 { | ^^ -note: ...so that the types are compatible - --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:14:10 - | -LL | impl<'a> Foo<'static> for &'a i32 { - | ^^^^^^^^^^^^ - = note: expected `Foo<'static>` - found `Foo<'static>` - = note: but, the lifetime must be valid for the static lifetime... -note: ...so that the type `&i32` will meet its required lifetime bounds - --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:14:10 - | -LL | impl<'a> Foo<'static> for &'a i32 { - | ^^^^^^^^^^^^ + = note: but lifetime parameter must outlive the static lifetime -error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements - --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:19:13 +error[E0478]: lifetime bound not satisfied + --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:20:5 | -LL | impl<'a,'b> Foo<'b> for &'a i64 { - | ^^^^^^^ +LL | type Value = &'a i32; + | ^^^^^^^^^^^^^^^^^^^^^ | -note: first, the lifetime cannot outlive the lifetime `'a` as defined on the impl at 19:6... +note: lifetime parameter instantiated with the lifetime `'a` as defined on the impl at 19:6 --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:19:6 | LL | impl<'a,'b> Foo<'b> for &'a i64 { | ^^ -note: ...so that the types are compatible - --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:19:13 - | -LL | impl<'a,'b> Foo<'b> for &'a i64 { - | ^^^^^^^ - = note: expected `Foo<'b>` - found `Foo<'_>` -note: but, the lifetime must be valid for the lifetime `'b` as defined on the impl at 19:9... +note: but lifetime parameter must outlive the lifetime `'b` as defined on the impl at 19:9 --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:19:9 | LL | impl<'a,'b> Foo<'b> for &'a i64 { | ^^ -note: ...so that the type `&i32` will meet its required lifetime bounds - --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:19:13 - | -LL | impl<'a,'b> Foo<'b> for &'a i64 { - | ^^^^^^^ error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0495`. +For more information about this error, try `rustc --explain E0478`. diff --git a/src/test/ui/regions/regions-assoc-type-static-bound-in-trait-not-met.rs b/src/test/ui/regions/regions-assoc-type-static-bound-in-trait-not-met.rs index 599cd0bb756..65b54b45a0a 100644 --- a/src/test/ui/regions/regions-assoc-type-static-bound-in-trait-not-met.rs +++ b/src/test/ui/regions/regions-assoc-type-static-bound-in-trait-not-met.rs @@ -7,8 +7,8 @@ trait Foo { } impl<'a> Foo for &'a i32 { - //~^ ERROR cannot infer type Value = &'a i32; + //~^ ERROR lifetime bound not satisfied } impl<'a> Foo for i32 { diff --git a/src/test/ui/regions/regions-assoc-type-static-bound-in-trait-not-met.stderr b/src/test/ui/regions/regions-assoc-type-static-bound-in-trait-not-met.stderr index ac8c55ccc8f..9b98d14a978 100644 --- a/src/test/ui/regions/regions-assoc-type-static-bound-in-trait-not-met.stderr +++ b/src/test/ui/regions/regions-assoc-type-static-bound-in-trait-not-met.stderr @@ -1,28 +1,16 @@ -error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements - --> $DIR/regions-assoc-type-static-bound-in-trait-not-met.rs:9:10 +error[E0478]: lifetime bound not satisfied + --> $DIR/regions-assoc-type-static-bound-in-trait-not-met.rs:10:5 | -LL | impl<'a> Foo for &'a i32 { - | ^^^ +LL | type Value = &'a i32; + | ^^^^^^^^^^^^^^^^^^^^^ | -note: first, the lifetime cannot outlive the lifetime `'a` as defined on the impl at 9:6... +note: lifetime parameter instantiated with the lifetime `'a` as defined on the impl at 9:6 --> $DIR/regions-assoc-type-static-bound-in-trait-not-met.rs:9:6 | LL | impl<'a> Foo for &'a i32 { | ^^ -note: ...so that the types are compatible - --> $DIR/regions-assoc-type-static-bound-in-trait-not-met.rs:9:10 - | -LL | impl<'a> Foo for &'a i32 { - | ^^^ - = note: expected `Foo` - found `Foo` - = note: but, the lifetime must be valid for the static lifetime... -note: ...so that the type `&i32` will meet its required lifetime bounds - --> $DIR/regions-assoc-type-static-bound-in-trait-not-met.rs:9:10 - | -LL | impl<'a> Foo for &'a i32 { - | ^^^ + = note: but lifetime parameter must outlive the static lifetime error: aborting due to previous error -For more information about this error, try `rustc --explain E0495`. +For more information about this error, try `rustc --explain E0478`. diff --git a/src/test/ui/specialization/deafult-associated-type-bound-1.stderr b/src/test/ui/specialization/deafult-associated-type-bound-1.stderr index 612e22c204f..4c21f8db8fa 100644 --- a/src/test/ui/specialization/deafult-associated-type-bound-1.stderr +++ b/src/test/ui/specialization/deafult-associated-type-bound-1.stderr @@ -11,7 +11,7 @@ error[E0277]: the trait bound `str: Clone` is not satisfied --> $DIR/deafult-associated-type-bound-1.rs:18:5 | LL | type U: Clone; - | -------------- required by `X::U` + | ----- required by this bound in `X::U` ... LL | default type U = str; | ^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `str` diff --git a/src/test/ui/specialization/deafult-associated-type-bound-2.stderr b/src/test/ui/specialization/deafult-associated-type-bound-2.stderr index a14024c160f..8c9da81d277 100644 --- a/src/test/ui/specialization/deafult-associated-type-bound-2.stderr +++ b/src/test/ui/specialization/deafult-associated-type-bound-2.stderr @@ -11,7 +11,7 @@ error[E0277]: can't compare `&'static B` with `B` --> $DIR/deafult-associated-type-bound-2.rs:16:5 | LL | type U: PartialEq<T>; - | --------------------- required by `X::U` + | ------------ required by this bound in `X::U` ... LL | default type U = &'static B; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `&'static B == B` diff --git a/src/test/ui/specialization/deafult-generic-associated-type-bound.rs b/src/test/ui/specialization/deafult-generic-associated-type-bound.rs index 8a94ea658d2..f14588e6e02 100644 --- a/src/test/ui/specialization/deafult-generic-associated-type-bound.rs +++ b/src/test/ui/specialization/deafult-generic-associated-type-bound.rs @@ -6,7 +6,7 @@ //~^^ WARNING the feature `generic_associated_types` is incomplete trait X { - type U<'a>: PartialEq<&'a Self>; + type U<'a>: PartialEq<&'a Self> where Self: 'a; fn unsafe_compare<'b>(x: Option<Self::U<'b>>, y: Option<&'b Self>) { match (x, y) { (Some(a), Some(b)) => a == b, diff --git a/src/test/ui/specialization/deafult-generic-associated-type-bound.stderr b/src/test/ui/specialization/deafult-generic-associated-type-bound.stderr index 556feda642b..f145b90f216 100644 --- a/src/test/ui/specialization/deafult-generic-associated-type-bound.stderr +++ b/src/test/ui/specialization/deafult-generic-associated-type-bound.stderr @@ -18,8 +18,8 @@ LL | #![feature(generic_associated_types)] error[E0277]: can't compare `T` with `T` --> $DIR/deafult-generic-associated-type-bound.rs:19:5 | -LL | type U<'a>: PartialEq<&'a Self>; - | -------------------------------- required by `X::U` +LL | type U<'a>: PartialEq<&'a Self> where Self: 'a; + | ------------------- required by this bound in `X::U` ... LL | default type U<'a> = &'a T; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `T == T` diff --git a/src/test/ui/specialization/issue-44861.stderr b/src/test/ui/specialization/issue-44861.stderr index be7196a63ce..3935a4a5f99 100644 --- a/src/test/ui/specialization/issue-44861.stderr +++ b/src/test/ui/specialization/issue-44861.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `(): CoerceUnsized<*const [u8]>` is not satisfied --> $DIR/issue-44861.rs:21:5 | LL | type Data2: CoerceUnsized<*const [u8]>; - | --------------------------------------- required by `Smartass::Data2` + | -------------------------- required by this bound in `Smartass::Data2` ... LL | default type Data2 = (); | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `CoerceUnsized<*const [u8]>` is not implemented for `()` diff --git a/src/test/ui/specialization/issue-59435.stderr b/src/test/ui/specialization/issue-59435.stderr index ee5c0615927..f3f8b022b01 100644 --- a/src/test/ui/specialization/issue-59435.stderr +++ b/src/test/ui/specialization/issue-59435.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `MyStruct: Default` is not satisfied --> $DIR/issue-59435.rs:11:5 | LL | type MyType: Default; - | --------------------- required by `MyTrait::MyType` + | ------- required by this bound in `MyTrait::MyType` ... LL | default type MyType = MyStruct; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `MyStruct` diff --git a/src/test/ui/suggestions/missing-assoc-type-bound-restriction.rs b/src/test/ui/suggestions/missing-assoc-type-bound-restriction.rs index 394512c5794..8218fecc3f1 100644 --- a/src/test/ui/suggestions/missing-assoc-type-bound-restriction.rs +++ b/src/test/ui/suggestions/missing-assoc-type-bound-restriction.rs @@ -15,11 +15,9 @@ impl<A, T> Child<A> for ChildWrapper<T> where T: Child<A> {} struct ParentWrapper<T>(T); impl<A, T: Parent<Ty = A>> Parent for ParentWrapper<T> { - //~^ ERROR the trait bound `<T as Parent>::Assoc: Child<A>` is not satisfied type Ty = A; type Assoc = ChildWrapper<T::Assoc>; //~^ ERROR the trait bound `<T as Parent>::Assoc: Child<A>` is not satisfied - //~| ERROR the trait bound `<T as Parent>::Assoc: Child<A>` is not satisfied } fn main() {} diff --git a/src/test/ui/suggestions/missing-assoc-type-bound-restriction.stderr b/src/test/ui/suggestions/missing-assoc-type-bound-restriction.stderr index a8ea2147961..676e2fb1a51 100644 --- a/src/test/ui/suggestions/missing-assoc-type-bound-restriction.stderr +++ b/src/test/ui/suggestions/missing-assoc-type-bound-restriction.stderr @@ -1,55 +1,18 @@ error[E0277]: the trait bound `<T as Parent>::Assoc: Child<A>` is not satisfied - --> $DIR/missing-assoc-type-bound-restriction.rs:17:19 + --> $DIR/missing-assoc-type-bound-restriction.rs:19:5 | -LL | trait Parent { - | ------ required by a bound in this -LL | type Ty; LL | type Assoc: Child<Self::Ty>; - | --------------- required by this bound in `Parent` -... -LL | impl<A, T: Parent<Ty = A>> Parent for ParentWrapper<T> { - | ^^^^^^ the trait `Child<A>` is not implemented for `<T as Parent>::Assoc` - | -help: consider further restricting the associated type - | -LL | impl<A, T: Parent<Ty = A>> Parent for ParentWrapper<T> where <T as Parent>::Assoc: Child<A> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0277]: the trait bound `<T as Parent>::Assoc: Child<A>` is not satisfied - --> $DIR/missing-assoc-type-bound-restriction.rs:20:18 - | -LL | trait Parent { - | ------ required by a bound in this -LL | type Ty; -LL | type Assoc: Child<Self::Ty>; - | --------------- required by this bound in `Parent` -... -LL | type Assoc = ChildWrapper<T::Assoc>; - | ^^^^^^^^^^^^^^^^^^^^^^ the trait `Child<A>` is not implemented for `<T as Parent>::Assoc` - | - = note: required because of the requirements on the impl of `Child<A>` for `ChildWrapper<<T as Parent>::Assoc>` -help: consider further restricting the associated type - | -LL | impl<A, T: Parent<Ty = A>> Parent for ParentWrapper<T> where <T as Parent>::Assoc: Child<A> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0277]: the trait bound `<T as Parent>::Assoc: Child<A>` is not satisfied - --> $DIR/missing-assoc-type-bound-restriction.rs:20:5 - | -LL | trait Parent { - | ------ required by a bound in this -LL | type Ty; -LL | type Assoc: Child<Self::Ty>; - | --------------- required by this bound in `Parent` + | --------------- required by this bound in `Parent::Assoc` ... LL | type Assoc = ChildWrapper<T::Assoc>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Child<A>` is not implemented for `<T as Parent>::Assoc` | + = note: required because of the requirements on the impl of `Child<A>` for `ChildWrapper<<T as Parent>::Assoc>` help: consider further restricting the associated type | LL | impl<A, T: Parent<Ty = A>> Parent for ParentWrapper<T> where <T as Parent>::Assoc: Child<A> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/traits/cycle-cache-err-60010.rs b/src/test/ui/traits/cycle-cache-err-60010.rs index cbddef082be..62d558fde88 100644 --- a/src/test/ui/traits/cycle-cache-err-60010.rs +++ b/src/test/ui/traits/cycle-cache-err-60010.rs @@ -28,7 +28,9 @@ struct SalsaStorage { } impl Database for RootDatabase { - type Storage = SalsaStorage; //~ ERROR overflow + // This would also be an error if we didn't abort compilation on the error + // above. + type Storage = SalsaStorage; } impl HasQueryGroup for RootDatabase {} impl<DB> Query<DB> for ParseQuery diff --git a/src/test/ui/traits/traits-inductive-overflow-two-traits.rs b/src/test/ui/traits/traits-inductive-overflow-two-traits.rs index 63dd1419200..463b55d8581 100644 --- a/src/test/ui/traits/traits-inductive-overflow-two-traits.rs +++ b/src/test/ui/traits/traits-inductive-overflow-two-traits.rs @@ -9,6 +9,7 @@ pub trait Magic { } impl<T: Magic> Magic for T { type X = Self; + //~^ ERROR E0277 } fn check<T: Trait>() {} diff --git a/src/test/ui/traits/traits-inductive-overflow-two-traits.stderr b/src/test/ui/traits/traits-inductive-overflow-two-traits.stderr index f66cfce55c9..dbe0146cafa 100644 --- a/src/test/ui/traits/traits-inductive-overflow-two-traits.stderr +++ b/src/test/ui/traits/traits-inductive-overflow-two-traits.stderr @@ -1,5 +1,19 @@ +error[E0277]: `T` cannot be shared between threads safely + --> $DIR/traits-inductive-overflow-two-traits.rs:11:5 + | +LL | type X: Trait; + | ----- required by this bound in `Magic::X` +... +LL | type X = Self; + | ^^^^^^^^^^^^^^ `T` cannot be shared between threads safely + | +help: consider further restricting this bound + | +LL | impl<T: Magic + std::marker::Sync> Magic for T { + | ^^^^^^^^^^^^^^^^^^^ + error[E0275]: overflow evaluating the requirement `*mut (): Magic` - --> $DIR/traits-inductive-overflow-two-traits.rs:19:5 + --> $DIR/traits-inductive-overflow-two-traits.rs:20:5 | LL | fn wizard<T: Magic>() { check::<<T as Magic>::X>(); } | ----- required by this bound in `wizard` @@ -7,6 +21,7 @@ LL | fn wizard<T: Magic>() { check::<<T as Magic>::X>(); } LL | wizard::<*mut ()>(); | ^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0275`. +Some errors have detailed explanations: E0275, E0277. +For more information about an error, try `rustc --explain E0275`. diff --git a/src/test/ui/try-block/try-block-bad-type.stderr b/src/test/ui/try-block/try-block-bad-type.stderr index 03d5d3661dd..dfc1c342a50 100644 --- a/src/test/ui/try-block/try-block-bad-type.stderr +++ b/src/test/ui/try-block/try-block-bad-type.stderr @@ -41,7 +41,7 @@ LL | let res: i32 = try { 5 }; | = note: required by `from_ok` -error: aborting due to 5 previous errors +error: aborting due to 6 previous errors Some errors have detailed explanations: E0271, E0277. For more information about an error, try `rustc --explain E0271`. |
