diff options
| author | bors <bors@rust-lang.org> | 2021-08-25 20:08:00 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-08-25 20:08:00 +0000 |
| commit | 0afc20860eb98a29d9bbeea80f2acc5be38c6bf3 (patch) | |
| tree | efaa6ae3d70c1f56bd4c9fb74a91e727743cbf02 /src | |
| parent | 7b0e554ee2c94e9b3865a8c2d24d720224512dec (diff) | |
| parent | 994a6bb667d8a0ae7bbc777f4d33994692dd7266 (diff) | |
| download | rust-0afc20860eb98a29d9bbeea80f2acc5be38c6bf3.tar.gz rust-0afc20860eb98a29d9bbeea80f2acc5be38c6bf3.zip | |
Auto merge of #85499 - jackh726:assoc-type-norm-rebase, r=nikomatsakis
Normalize projections under binders Fixes #70243 Fixes #70120 Fixes #62529 Fixes #87219 Issues to followup on after (probably fixed, but no test added here): #76956 #56556 #79207 #85636 r? `@nikomatsakis`
Diffstat (limited to 'src')
49 files changed, 597 insertions, 286 deletions
diff --git a/src/test/ui/associated-type-bounds/issue-83017.rs b/src/test/ui/associated-type-bounds/issue-83017.rs index 8f0a9ea3566..a02208661f1 100644 --- a/src/test/ui/associated-type-bounds/issue-83017.rs +++ b/src/test/ui/associated-type-bounds/issue-83017.rs @@ -1,3 +1,5 @@ +// check-pass + #![feature(associated_type_bounds)] trait TraitA<'a> { @@ -34,6 +36,4 @@ where fn main() { foo::<Z>(); - //~^ ERROR: the trait bound `for<'a, 'b> <Z as TraitA<'a>>::AsA: TraitB<'a, 'b>` is not satisfied - //~| ERROR: the trait bound `for<'a, 'b, 'c> <<Z as TraitA<'a>>::AsA as TraitB<'a, 'b>>::AsB: TraitC<'a, 'b, 'c>` is not satisfied } diff --git a/src/test/ui/associated-type-bounds/issue-83017.stderr b/src/test/ui/associated-type-bounds/issue-83017.stderr deleted file mode 100644 index af86990ac66..00000000000 --- a/src/test/ui/associated-type-bounds/issue-83017.stderr +++ /dev/null @@ -1,33 +0,0 @@ -error[E0277]: the trait bound `for<'a, 'b> <Z as TraitA<'a>>::AsA: TraitB<'a, 'b>` is not satisfied - --> $DIR/issue-83017.rs:36:5 - | -LL | foo::<Z>(); - | ^^^^^^^^ the trait `for<'a, 'b> TraitB<'a, 'b>` is not implemented for `<Z as TraitA<'a>>::AsA` - | -note: required by a bound in `foo` - --> $DIR/issue-83017.rs:31:32 - | -LL | fn foo<T>() - | --- required by a bound in this -LL | where -LL | for<'a> T: TraitA<'a, AsA: for<'b> TraitB<'a, 'b, AsB: for<'c> TraitC<'a, 'b, 'c>>>, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `foo` - -error[E0277]: the trait bound `for<'a, 'b, 'c> <<Z as TraitA<'a>>::AsA as TraitB<'a, 'b>>::AsB: TraitC<'a, 'b, 'c>` is not satisfied - --> $DIR/issue-83017.rs:36:5 - | -LL | foo::<Z>(); - | ^^^^^^^^ the trait `for<'a, 'b, 'c> TraitC<'a, 'b, 'c>` is not implemented for `<<Z as TraitA<'a>>::AsA as TraitB<'a, 'b>>::AsB` - | -note: required by a bound in `foo` - --> $DIR/issue-83017.rs:31:60 - | -LL | fn foo<T>() - | --- required by a bound in this -LL | where -LL | for<'a> T: TraitA<'a, AsA: for<'b> TraitB<'a, 'b, AsB: for<'c> TraitC<'a, 'b, 'c>>>, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `foo` - -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/higher-ranked-projection.bad.nll.stderr b/src/test/ui/associated-types/higher-ranked-projection.bad.nll.stderr index 59e27cd2e7d..e3bd0c2276e 100644 --- a/src/test/ui/associated-types/higher-ranked-projection.bad.nll.stderr +++ b/src/test/ui/associated-types/higher-ranked-projection.bad.nll.stderr @@ -4,8 +4,8 @@ error[E0308]: mismatched types LL | foo(()); | ^^^^^^^ one type is more general than the other | - = note: expected type `&'a ()` - found reference `&()` + = note: expected reference `&'a ()` + found reference `&()` error: aborting due to previous error diff --git a/src/test/ui/associated-types/higher-ranked-projection.bad.stderr b/src/test/ui/associated-types/higher-ranked-projection.bad.stderr index e2847b6b72b..1ac72e4b90c 100644 --- a/src/test/ui/associated-types/higher-ranked-projection.bad.stderr +++ b/src/test/ui/associated-types/higher-ranked-projection.bad.stderr @@ -4,8 +4,8 @@ error[E0308]: mismatched types LL | foo(()); | ^^^ lifetime mismatch | - = note: expected type `&'a ()` - found type `&()` + = note: expected reference `&'a ()` + found type `&()` note: the lifetime requirement is introduced here --> $DIR/higher-ranked-projection.rs:15:33 | diff --git a/src/test/ui/associated-types/hr-associated-type-bound-1.rs b/src/test/ui/associated-types/hr-associated-type-bound-1.rs index cdf32dd82a6..db414164e16 100644 --- a/src/test/ui/associated-types/hr-associated-type-bound-1.rs +++ b/src/test/ui/associated-types/hr-associated-type-bound-1.rs @@ -10,7 +10,7 @@ where impl X<'_> for i32 { type U = str; - //~^ ERROR the trait bound `for<'b> <i32 as X<'b>>::U: Clone` + //~^ ERROR the trait bound `str: Clone` } fn main() { diff --git a/src/test/ui/associated-types/hr-associated-type-bound-1.stderr b/src/test/ui/associated-types/hr-associated-type-bound-1.stderr index 0bcc9be5c43..4eed5c9a008 100644 --- a/src/test/ui/associated-types/hr-associated-type-bound-1.stderr +++ b/src/test/ui/associated-types/hr-associated-type-bound-1.stderr @@ -1,11 +1,9 @@ -error[E0277]: the trait bound `for<'b> <i32 as X<'b>>::U: Clone` is not satisfied +error[E0277]: the trait bound `str: Clone` is not satisfied --> $DIR/hr-associated-type-bound-1.rs:12:14 | LL | type U = str; - | ^^^ the trait `for<'b> Clone` is not implemented for `<i32 as X<'b>>::U` + | ^^^ the trait `Clone` is not implemented for `str` | - = help: the following implementations were found: - <&T as Clone> note: required by a bound in `X` --> $DIR/hr-associated-type-bound-1.rs:3:33 | diff --git a/src/test/ui/associated-types/hr-associated-type-bound-2.rs b/src/test/ui/associated-types/hr-associated-type-bound-2.rs index 78ee28b17d4..2eb956c8dbb 100644 --- a/src/test/ui/associated-types/hr-associated-type-bound-2.rs +++ b/src/test/ui/associated-types/hr-associated-type-bound-2.rs @@ -8,14 +8,13 @@ where } } -impl X<'_> for u32 +impl X<'_> for u32 //~ overflow evaluating the requirement `for<'b> u32: X<'b>` where for<'b> <Self as X<'b>>::U: Clone, { - type U = str; + type U = str; //~ overflow evaluating the requirement `for<'b> u32: X<'b>` } fn main() { 1u32.f("abc"); - //~^ ERROR the method } diff --git a/src/test/ui/associated-types/hr-associated-type-bound-2.stderr b/src/test/ui/associated-types/hr-associated-type-bound-2.stderr index 043d1ac76de..079989f2331 100644 --- a/src/test/ui/associated-types/hr-associated-type-bound-2.stderr +++ b/src/test/ui/associated-types/hr-associated-type-bound-2.stderr @@ -1,13 +1,38 @@ -error[E0599]: the method `f` exists for type `u32`, but its trait bounds were not satisfied - --> $DIR/hr-associated-type-bound-2.rs:19:10 +error[E0275]: overflow evaluating the requirement `for<'b> u32: X<'b>` + --> $DIR/hr-associated-type-bound-2.rs:11:1 | -LL | 1u32.f("abc"); - | ^ method cannot be called on `u32` due to unsatisfied trait bounds +LL | / impl X<'_> for u32 +LL | | where +LL | | for<'b> <Self as X<'b>>::U: Clone, +LL | | { +LL | | type U = str; +LL | | } + | |_^ | - = note: the following trait bounds were not satisfied: - `<u32 as X<'b>>::U: Clone` - which is required by `u32: X` + = help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`hr_associated_type_bound_2`) +note: required because of the requirements on the impl of `for<'b> X<'b>` for `u32` + --> $DIR/hr-associated-type-bound-2.rs:11:6 + | +LL | impl X<'_> for u32 + | ^^^^^ ^^^ + = note: 128 redundant requirements hidden + = note: required because of the requirements on the impl of `for<'b> X<'b>` for `u32` + +error[E0275]: overflow evaluating the requirement `for<'b> u32: X<'b>` + --> $DIR/hr-associated-type-bound-2.rs:15:5 + | +LL | type U = str; + | ^^^^^^^^^^^^^ + | + = help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`hr_associated_type_bound_2`) +note: required because of the requirements on the impl of `for<'b> X<'b>` for `u32` + --> $DIR/hr-associated-type-bound-2.rs:11:6 + | +LL | impl X<'_> for u32 + | ^^^^^ ^^^ + = note: 128 redundant requirements hidden + = note: required because of the requirements on the impl of `for<'b> X<'b>` for `u32` -error: aborting due to previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0599`. +For more information about this error, try `rustc --explain E0275`. diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-1.rs b/src/test/ui/associated-types/hr-associated-type-bound-param-1.rs index 0a81f373ad4..bbeeb145d1f 100644 --- a/src/test/ui/associated-types/hr-associated-type-bound-param-1.rs +++ b/src/test/ui/associated-types/hr-associated-type-bound-param-1.rs @@ -12,7 +12,7 @@ where impl<'a> Y<'a, u8> for u8 { type V = str; - //~^ ERROR the trait bound `for<'b> <u8 as Y<'b, u8>>::V: Clone` is not satisfied + //~^ ERROR the trait bound `str: Clone` is not satisfied } fn main() { diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-1.stderr b/src/test/ui/associated-types/hr-associated-type-bound-param-1.stderr index e16931ee09f..99f95c20051 100644 --- a/src/test/ui/associated-types/hr-associated-type-bound-param-1.stderr +++ b/src/test/ui/associated-types/hr-associated-type-bound-param-1.stderr @@ -1,11 +1,9 @@ -error[E0277]: the trait bound `for<'b> <u8 as Y<'b, u8>>::V: Clone` is not satisfied +error[E0277]: the trait bound `str: Clone` is not satisfied --> $DIR/hr-associated-type-bound-param-1.rs:14:14 | LL | type V = str; - | ^^^ the trait `for<'b> Clone` is not implemented for `<u8 as Y<'b, u8>>::V` + | ^^^ the trait `Clone` is not implemented for `str` | - = help: the following implementations were found: - <&T as Clone> note: required by a bound in `Y` --> $DIR/hr-associated-type-bound-param-1.rs:4:36 | diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-2.rs b/src/test/ui/associated-types/hr-associated-type-bound-param-2.rs index a04144ba06b..5193400882d 100644 --- a/src/test/ui/associated-types/hr-associated-type-bound-param-2.rs +++ b/src/test/ui/associated-types/hr-associated-type-bound-param-2.rs @@ -2,8 +2,8 @@ trait Z<'a, T: ?Sized> where T: Z<'a, u16>, - //~^ the trait bound `for<'b> <u16 as Z<'b, u16>>::W: Clone` is not satisfied - //~| the trait bound `for<'b> <u16 as Z<'b, u16>>::W: Clone` is not satisfied + //~^ the trait bound `str: Clone` is not satisfied + //~| the trait bound `str: Clone` is not satisfied for<'b> <T as Z<'b, u16>>::W: Clone, { type W: ?Sized; @@ -14,7 +14,7 @@ where impl<'a> Z<'a, u16> for u16 { type W = str; - //~^ ERROR the trait bound `for<'b> <u16 as Z<'b, u16>>::W: Clone + //~^ ERROR the trait bound `str: Clone } fn main() { diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-2.stderr b/src/test/ui/associated-types/hr-associated-type-bound-param-2.stderr index 0c9f2a3978c..730229b5208 100644 --- a/src/test/ui/associated-types/hr-associated-type-bound-param-2.stderr +++ b/src/test/ui/associated-types/hr-associated-type-bound-param-2.stderr @@ -1,11 +1,9 @@ -error[E0277]: the trait bound `for<'b> <u16 as Z<'b, u16>>::W: Clone` is not satisfied +error[E0277]: the trait bound `str: Clone` is not satisfied --> $DIR/hr-associated-type-bound-param-2.rs:4:8 | LL | T: Z<'a, u16>, - | ^^^^^^^^^^ the trait `for<'b> Clone` is not implemented for `<u16 as Z<'b, u16>>::W` + | ^^^^^^^^^^ the trait `Clone` is not implemented for `str` | - = help: the following implementations were found: - <&T as Clone> note: required by a bound in `Z` --> $DIR/hr-associated-type-bound-param-2.rs:7:35 | @@ -15,14 +13,12 @@ LL | trait Z<'a, T: ?Sized> LL | for<'b> <T as Z<'b, u16>>::W: Clone, | ^^^^^ required by this bound in `Z` -error[E0277]: the trait bound `for<'b> <u16 as Z<'b, u16>>::W: Clone` is not satisfied +error[E0277]: the trait bound `str: Clone` is not satisfied --> $DIR/hr-associated-type-bound-param-2.rs:4:8 | LL | T: Z<'a, u16>, - | ^^^^^^^^^^ the trait `for<'b> Clone` is not implemented for `<u16 as Z<'b, u16>>::W` + | ^^^^^^^^^^ the trait `Clone` is not implemented for `str` | - = help: the following implementations were found: - <&T as Clone> note: required by a bound in `Z` --> $DIR/hr-associated-type-bound-param-2.rs:7:35 | @@ -32,14 +28,12 @@ LL | trait Z<'a, T: ?Sized> LL | for<'b> <T as Z<'b, u16>>::W: Clone, | ^^^^^ required by this bound in `Z` -error[E0277]: the trait bound `for<'b> <u16 as Z<'b, u16>>::W: Clone` is not satisfied +error[E0277]: the trait bound `str: Clone` is not satisfied --> $DIR/hr-associated-type-bound-param-2.rs:16:14 | LL | type W = str; - | ^^^ the trait `for<'b> Clone` is not implemented for `<u16 as Z<'b, u16>>::W` + | ^^^ the trait `Clone` is not implemented for `str` | - = help: the following implementations were found: - <&T as Clone> note: required by a bound in `Z` --> $DIR/hr-associated-type-bound-param-2.rs:7:35 | diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-3.rs b/src/test/ui/associated-types/hr-associated-type-bound-param-3.rs index 1af63bf9070..fda7d811185 100644 --- a/src/test/ui/associated-types/hr-associated-type-bound-param-3.rs +++ b/src/test/ui/associated-types/hr-associated-type-bound-param-3.rs @@ -11,7 +11,7 @@ where impl<S, T> X<'_, (T,)> for (S,) { type U = str; - //~^ ERROR the trait bound `for<'b> <(T,) as X<'b, (T,)>>::U: Clone` is not satisfied + //~^ ERROR the trait bound `str: Clone` is not satisfied } pub fn main() { diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-3.stderr b/src/test/ui/associated-types/hr-associated-type-bound-param-3.stderr index b1bc1dfbb11..9935445c306 100644 --- a/src/test/ui/associated-types/hr-associated-type-bound-param-3.stderr +++ b/src/test/ui/associated-types/hr-associated-type-bound-param-3.stderr @@ -1,11 +1,9 @@ -error[E0277]: the trait bound `for<'b> <(T,) as X<'b, (T,)>>::U: Clone` is not satisfied +error[E0277]: the trait bound `str: Clone` is not satisfied --> $DIR/hr-associated-type-bound-param-3.rs:13:14 | LL | type U = str; - | ^^^ the trait `for<'b> Clone` is not implemented for `<(T,) as X<'b, (T,)>>::U` + | ^^^ the trait `Clone` is not implemented for `str` | - = help: the following implementations were found: - <&T as Clone> note: required by a bound in `X` --> $DIR/hr-associated-type-bound-param-3.rs:4:33 | diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-4.rs b/src/test/ui/associated-types/hr-associated-type-bound-param-4.rs index 6f06b925bd2..20c8157ed97 100644 --- a/src/test/ui/associated-types/hr-associated-type-bound-param-4.rs +++ b/src/test/ui/associated-types/hr-associated-type-bound-param-4.rs @@ -11,7 +11,7 @@ where impl<S, T> X<'_, T> for (S,) { type U = str; - //~^ ERROR the trait bound `for<'b> <(T,) as X<'b, T>>::U: Clone` is not satisfied + //~^ ERROR the trait bound `str: Clone` is not satisfied } pub fn main() { diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-4.stderr b/src/test/ui/associated-types/hr-associated-type-bound-param-4.stderr index 0bd404f8a41..c26324ee625 100644 --- a/src/test/ui/associated-types/hr-associated-type-bound-param-4.stderr +++ b/src/test/ui/associated-types/hr-associated-type-bound-param-4.stderr @@ -1,11 +1,9 @@ -error[E0277]: the trait bound `for<'b> <(T,) as X<'b, T>>::U: Clone` is not satisfied +error[E0277]: the trait bound `str: Clone` is not satisfied --> $DIR/hr-associated-type-bound-param-4.rs:13:14 | LL | type U = str; - | ^^^ the trait `for<'b> Clone` is not implemented for `<(T,) as X<'b, T>>::U` + | ^^^ the trait `Clone` is not implemented for `str` | - = help: the following implementations were found: - <&T as Clone> note: required by a bound in `X` --> $DIR/hr-associated-type-bound-param-4.rs:4:36 | diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-5.rs b/src/test/ui/associated-types/hr-associated-type-bound-param-5.rs index fc3a85171e2..920aa835280 100644 --- a/src/test/ui/associated-types/hr-associated-type-bound-param-5.rs +++ b/src/test/ui/associated-types/hr-associated-type-bound-param-5.rs @@ -25,14 +25,12 @@ where impl<S, T> X<'_, Vec<T>> for S { type U = str; - //~^ ERROR the trait bound `for<'b> <Box<T> as X<'b, Box<T>>>::U: Clone` is not satisfied - //~| ERROR the trait bound `for<'b> <Vec<T> as X<'b, Vec<T>>>::U: Clone` is not satisfied + //~^ ERROR the trait bound `str: Clone` is not satisfied } impl<S, T> X<'_, Box<T>> for S { type U = str; - //~^ ERROR the trait bound `for<'b> <Box<T> as X<'b, Box<T>>>::U: Clone` is not satisfied - //~| ERROR the trait bound `for<'b> <Vec<T> as X<'b, Vec<T>>>::U: Clone` is not satisfied + //~^ ERROR the trait bound `str: Clone` is not satisfied } pub fn main() { diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-5.stderr b/src/test/ui/associated-types/hr-associated-type-bound-param-5.stderr index 59c0a7268cc..63cd89316b3 100644 --- a/src/test/ui/associated-types/hr-associated-type-bound-param-5.stderr +++ b/src/test/ui/associated-types/hr-associated-type-bound-param-5.stderr @@ -1,11 +1,9 @@ -error[E0277]: the trait bound `for<'b> <Box<T> as X<'b, Box<T>>>::U: Clone` is not satisfied +error[E0277]: the trait bound `str: Clone` is not satisfied --> $DIR/hr-associated-type-bound-param-5.rs:27:14 | LL | type U = str; - | ^^^ the trait `for<'b> Clone` is not implemented for `<Box<T> as X<'b, Box<T>>>::U` + | ^^^ the trait `Clone` is not implemented for `str` | - = help: the following implementations were found: - <&T as Clone> note: required by a bound in `X` --> $DIR/hr-associated-type-bound-param-5.rs:18:45 | @@ -15,31 +13,12 @@ LL | trait X<'a, T: Cycle + for<'b> X<'b, T>> LL | for<'b> <T::Next as X<'b, T::Next>>::U: Clone, | ^^^^^ required by this bound in `X` -error[E0277]: the trait bound `for<'b> <Vec<T> as X<'b, Vec<T>>>::U: Clone` is not satisfied - --> $DIR/hr-associated-type-bound-param-5.rs:27:14 - | -LL | type U = str; - | ^^^ the trait `for<'b> Clone` is not implemented for `<Vec<T> as X<'b, Vec<T>>>::U` - | - = help: the following implementations were found: - <&T as Clone> -note: required by a bound in `X` - --> $DIR/hr-associated-type-bound-param-5.rs:16:33 - | -LL | trait X<'a, T: Cycle + for<'b> X<'b, T>> - | - required by a bound in this -LL | where -LL | for<'b> <T as X<'b, T>>::U: Clone, - | ^^^^^ required by this bound in `X` - -error[E0277]: the trait bound `for<'b> <Vec<T> as X<'b, Vec<T>>>::U: Clone` is not satisfied - --> $DIR/hr-associated-type-bound-param-5.rs:33:14 +error[E0277]: the trait bound `str: Clone` is not satisfied + --> $DIR/hr-associated-type-bound-param-5.rs:32:14 | LL | type U = str; - | ^^^ the trait `for<'b> Clone` is not implemented for `<Vec<T> as X<'b, Vec<T>>>::U` + | ^^^ the trait `Clone` is not implemented for `str` | - = help: the following implementations were found: - <&T as Clone> note: required by a bound in `X` --> $DIR/hr-associated-type-bound-param-5.rs:18:45 | @@ -49,23 +28,6 @@ LL | trait X<'a, T: Cycle + for<'b> X<'b, T>> LL | for<'b> <T::Next as X<'b, T::Next>>::U: Clone, | ^^^^^ required by this bound in `X` -error[E0277]: the trait bound `for<'b> <Box<T> as X<'b, Box<T>>>::U: Clone` is not satisfied - --> $DIR/hr-associated-type-bound-param-5.rs:33:14 - | -LL | type U = str; - | ^^^ the trait `for<'b> Clone` is not implemented for `<Box<T> as X<'b, Box<T>>>::U` - | - = help: the following implementations were found: - <&T as Clone> -note: required by a bound in `X` - --> $DIR/hr-associated-type-bound-param-5.rs:16:33 - | -LL | trait X<'a, T: Cycle + for<'b> X<'b, T>> - | - required by a bound in this -LL | where -LL | for<'b> <T as X<'b, T>>::U: Clone, - | ^^^^^ required by this bound in `X` - -error: aborting due to 4 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/hr-associated-type-bound-param-6.rs b/src/test/ui/associated-types/hr-associated-type-bound-param-6.rs index 04b88c7f4fc..482047b0959 100644 --- a/src/test/ui/associated-types/hr-associated-type-bound-param-6.rs +++ b/src/test/ui/associated-types/hr-associated-type-bound-param-6.rs @@ -12,7 +12,6 @@ where impl<S, T> X<'_, T> for (S,) { //~^ ERROR the trait bound `for<'b> T: X<'b, T>` is not satisfied type U = str; - //~^ ERROR the trait bound `for<'b> <T as X<'b, T>>::U: Clone` is not satisfied } pub fn main() { diff --git a/src/test/ui/associated-types/hr-associated-type-bound-param-6.stderr b/src/test/ui/associated-types/hr-associated-type-bound-param-6.stderr index bce5737af1b..bd6e627a3d0 100644 --- a/src/test/ui/associated-types/hr-associated-type-bound-param-6.stderr +++ b/src/test/ui/associated-types/hr-associated-type-bound-param-6.stderr @@ -1,39 +1,14 @@ -error[E0277]: the trait bound `for<'b> <T as X<'b, T>>::U: Clone` is not satisfied - --> $DIR/hr-associated-type-bound-param-6.rs:14:14 - | -LL | type U = str; - | ^^^ the trait `for<'b> Clone` is not implemented for `<T as X<'b, T>>::U` - | - = help: the following implementations were found: - <&T as Clone> -note: required by a bound in `X` - --> $DIR/hr-associated-type-bound-param-6.rs:4:33 - | -LL | trait X<'a, T> - | - required by a bound in this -... -LL | for<'b> <T as X<'b, T>>::U: Clone, - | ^^^^^ required by this bound in `X` - error[E0277]: the trait bound `for<'b> T: X<'b, T>` is not satisfied --> $DIR/hr-associated-type-bound-param-6.rs:12:12 | LL | impl<S, T> X<'_, T> for (S,) { | ^^^^^^^^ the trait `for<'b> X<'b, T>` is not implemented for `T` | -note: required by a bound in `X` - --> $DIR/hr-associated-type-bound-param-6.rs:3:16 - | -LL | trait X<'a, T> - | - required by a bound in this -LL | where -LL | for<'b> T: X<'b, T>, - | ^^^^^^^^ required by this bound in `X` help: consider restricting type parameter `T` | LL | impl<S, T: for<'b> X<'b, T>> X<'_, T> for (S,) { | ++++++++++++++++++ -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/associated-types/hr-associated-type-projection-1.rs b/src/test/ui/associated-types/hr-associated-type-projection-1.rs index bad736b64c0..951dd9e97d2 100644 --- a/src/test/ui/associated-types/hr-associated-type-projection-1.rs +++ b/src/test/ui/associated-types/hr-associated-type-projection-1.rs @@ -11,9 +11,8 @@ where } impl<T: Copy + std::ops::Deref> UnsafeCopy<'_, T> for T { - //~^ ERROR the trait bound `for<'b> <T as UnsafeCopy<'b, T>>::Item: Deref` is not satisfied + //~^ type mismatch resolving `<T as Deref>::Target == T` type Item = T; - //~^ ERROR the trait bound `for<'b> <T as UnsafeCopy<'b, T>>::Item: Deref } pub fn main() { diff --git a/src/test/ui/associated-types/hr-associated-type-projection-1.stderr b/src/test/ui/associated-types/hr-associated-type-projection-1.stderr index 20d7a206754..9c29e969de8 100644 --- a/src/test/ui/associated-types/hr-associated-type-projection-1.stderr +++ b/src/test/ui/associated-types/hr-associated-type-projection-1.stderr @@ -1,32 +1,16 @@ -error[E0277]: the trait bound `for<'b> <T as UnsafeCopy<'b, T>>::Item: Deref` is not satisfied - --> $DIR/hr-associated-type-projection-1.rs:15:17 - | -LL | type Item = T; - | ^ the trait `for<'b> Deref` is not implemented for `<T as UnsafeCopy<'b, T>>::Item` - | - = help: the following implementations were found: - <&T as Deref> - <&mut T as Deref> -note: required by a bound in `UnsafeCopy` - --> $DIR/hr-associated-type-projection-1.rs:3:48 - | -LL | trait UnsafeCopy<'a, T: Copy> - | ---------- required by a bound in this -LL | where -LL | for<'b> <Self as UnsafeCopy<'b, T>>::Item: std::ops::Deref<Target = T>, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `UnsafeCopy` - -error[E0277]: the trait bound `for<'b> <T as UnsafeCopy<'b, T>>::Item: Deref` is not satisfied +error[E0271]: type mismatch resolving `<T as Deref>::Target == T` --> $DIR/hr-associated-type-projection-1.rs:13:33 | LL | impl<T: Copy + std::ops::Deref> UnsafeCopy<'_, T> for T { - | ^^^^^^^^^^^^^^^^^ the trait `for<'b> Deref` is not implemented for `<T as UnsafeCopy<'b, T>>::Item` + | - this type parameter ^^^^^^^^^^^^^^^^^ expected associated type, found type parameter `T` | -help: consider further restricting the associated type + = note: expected associated type `<T as Deref>::Target` + found type parameter `T` +help: consider further restricting this bound | -LL | impl<T: Copy + std::ops::Deref> UnsafeCopy<'_, T> for T where for<'b> <T as UnsafeCopy<'b, T>>::Item: Deref { - | +++++++++++++++++++++++++++++++++++++++++++++++++++ +LL | impl<T: Copy + std::ops::Deref + Deref<Target = T>> UnsafeCopy<'_, T> for T { + | +++++++++++++++++++ -error: aborting due to 2 previous errors +error: aborting due to previous error -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0271`. diff --git a/src/test/ui/associated-types/normalization-generality-2.rs b/src/test/ui/associated-types/normalization-generality-2.rs new file mode 100644 index 00000000000..d8790bb2d12 --- /dev/null +++ b/src/test/ui/associated-types/normalization-generality-2.rs @@ -0,0 +1,30 @@ +// build-pass + +// Ensures that we don't regress on "implementation is not general enough" when +// normalizating under binders. Unlike `normalization-generality.rs`, this also produces +// type outlives predicates that we must ignore. + +pub unsafe trait Yokeable<'a> { + type Output: 'a; +} +pub struct Yoke<Y: for<'a> Yokeable<'a>> { + _marker: std::marker::PhantomData<Y>, +} +impl<Y: for<'a> Yokeable<'a>> Yoke<Y> { + pub fn project<P>( + &self, + _f: for<'a> fn(&<Y as Yokeable<'a>>::Output, &'a ()) -> <P as Yokeable<'a>>::Output, + ) -> Yoke<P> + where + P: for<'a> Yokeable<'a>, + { + unimplemented!() + } +} +pub fn slice(y: Yoke<&'static str>) -> Yoke<&'static [u8]> { + y.project(move |yk, _| yk.as_bytes()) +} +unsafe impl<'a, T: 'static + ?Sized> Yokeable<'a> for &'static T { + type Output = &'a T; +} +fn main() {} diff --git a/src/test/ui/closures/issue-41366.rs b/src/test/ui/closures/issue-41366.rs index 909c33f642d..acc1c6ae122 100644 --- a/src/test/ui/closures/issue-41366.rs +++ b/src/test/ui/closures/issue-41366.rs @@ -1,3 +1,5 @@ +// check-pass + trait T<'x> { type V; } @@ -8,6 +10,4 @@ impl<'g> T<'g> for u32 { fn main() { (&|_| ()) as &dyn for<'x> Fn(<u32 as T<'x>>::V); - //~^ ERROR: type mismatch in closure arguments - //~| ERROR: size for values of type `<u32 as T<'_>>::V` cannot be known at compilation time } diff --git a/src/test/ui/closures/issue-41366.stderr b/src/test/ui/closures/issue-41366.stderr deleted file mode 100644 index 06477efac26..00000000000 --- a/src/test/ui/closures/issue-41366.stderr +++ /dev/null @@ -1,32 +0,0 @@ -error[E0631]: type mismatch in closure arguments - --> $DIR/issue-41366.rs:10:5 - | -LL | (&|_| ()) as &dyn for<'x> Fn(<u32 as T<'x>>::V); - | ^^------^ - | | | - | | found signature of `fn(u16) -> _` - | expected signature of `for<'x> fn(<u32 as T<'x>>::V) -> _` - | - = note: required for the cast to the object type `dyn for<'x> Fn(<u32 as T<'x>>::V)` - -error[E0277]: the size for values of type `<u32 as T<'_>>::V` cannot be known at compilation time - --> $DIR/issue-41366.rs:10:8 - | -LL | (&|_| ()) as &dyn for<'x> Fn(<u32 as T<'x>>::V); - | ^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `<u32 as T<'_>>::V` - = help: unsized fn params are gated as an unstable feature -help: consider further restricting the associated type - | -LL | fn main() where <u32 as T<'_>>::V: Sized { - | ++++++++++++++++++++++++++++++ -help: function arguments must have a statically known size, borrowed types always have a known size - | -LL | (&|&_| ()) as &dyn for<'x> Fn(<u32 as T<'x>>::V); - | + - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0277, E0631. -For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-1.rs b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-1.rs new file mode 100644 index 00000000000..24ac566f9df --- /dev/null +++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-1.rs @@ -0,0 +1,88 @@ +// FamilyType (GAT workaround) +pub trait FamilyLt<'a> { + type Out; +} + +struct RefMutFamily<T>(std::marker::PhantomData<T>, ()); +impl<'a, T: 'a> FamilyLt<'a> for RefMutFamily<T> { + type Out = &'a mut T; +} + +pub trait Execute { + type E: Inject; + fn execute(self, value: <<Self::E as Inject>::I as FamilyLt>::Out); +} + +pub trait Inject +where + Self: Sized, +{ + type I: for<'a> FamilyLt<'a>; + fn inject(_: &()) -> <Self::I as FamilyLt>::Out; +} + +impl<T: 'static> Inject for RefMutFamily<T> { + type I = Self; + fn inject(_: &()) -> <Self::I as FamilyLt>::Out { + unimplemented!() + } +} + +// This struct is only used to give a hint to the compiler about the type `Q` +struct Annotate<Q>(std::marker::PhantomData<Q>); +impl<Q> Annotate<Q> { + fn new() -> Self { + Self(std::marker::PhantomData) + } +} + +// This function annotate a closure so it can have Higher-Rank Lifetime Bounds +// +// See 'annotate' workaround: https://github.com/rust-lang/rust/issues/58052 +fn annotate<F, Q>(_q: Annotate<Q>, func: F) -> impl Execute + 'static +where + F: for<'r> FnOnce(<<Q as Inject>::I as FamilyLt<'r>>::Out) + 'static, + Q: Inject + 'static, +{ + let wrapper: Wrapper<Q, F> = Wrapper(std::marker::PhantomData, func); + wrapper +} + +struct Wrapper<Q, F>(std::marker::PhantomData<Q>, F); +impl<Q, F> Execute for Wrapper<Q, F> + where + Q: Inject, + F: for<'r> FnOnce(<<Q as Inject>::I as FamilyLt<'r>>::Out), +{ + type E = Q; + + fn execute(self, value: <<Self::E as Inject>::I as FamilyLt>::Out) { + (self.1)(value) + } +} + +struct Task { + _processor: Box<dyn FnOnce()>, +} + +// This function consume the closure +fn task<P>(processor: P) -> Task +where P: Execute + 'static { + Task { + _processor: Box::new(move || { + let q = P::E::inject(&()); + processor.execute(q); + }) + } +} + +fn main() { + task(annotate( //~ type mismatch + //~^ the size + //~^^ the trait bound + Annotate::<RefMutFamily<usize>>::new(), + |value: &mut usize| { + *value = 2; + } + )); +} diff --git a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-1.stderr b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-1.stderr new file mode 100644 index 00000000000..8311c147ee3 --- /dev/null +++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-1.stderr @@ -0,0 +1,67 @@ +error[E0631]: type mismatch in closure arguments + --> $DIR/issue-62529-1.rs:80:10 + | +LL | task(annotate( + | ^^^^^^^^ expected signature of `for<'r> fn(<RefMutFamily<usize> as FamilyLt<'r>>::Out) -> _` +... +LL | |value: &mut usize| { + | ------------------- found signature of `for<'r> fn(&'r mut usize) -> _` + | +note: required by a bound in `annotate` + --> $DIR/issue-62529-1.rs:44:8 + | +LL | fn annotate<F, Q>(_q: Annotate<Q>, func: F) -> impl Execute + 'static + | -------- required by a bound in this +LL | where +LL | F: for<'r> FnOnce(<<Q as Inject>::I as FamilyLt<'r>>::Out) + 'static, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `annotate` + +error[E0277]: the size for values of type `impl Execute` cannot be known at compilation time + --> $DIR/issue-62529-1.rs:80:10 + | +LL | task(annotate( + | __________^ +LL | | +LL | | +LL | | Annotate::<RefMutFamily<usize>>::new(), +... | +LL | | } +LL | | )); + | |_____^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `impl Execute` +note: required by a bound in `task` + --> $DIR/issue-62529-1.rs:69:9 + | +LL | fn task<P>(processor: P) -> Task + | ^ required by this bound in `task` +help: consider relaxing the implicit `Sized` restriction + | +LL | fn task<P: ?Sized>(processor: P) -> Task + | ++++++++ + +error[E0277]: the trait bound `impl Execute: Execute` is not satisfied + --> $DIR/issue-62529-1.rs:80:10 + | +LL | task(annotate( + | __________^ +LL | | +LL | | +LL | | Annotate::<RefMutFamily<usize>>::new(), +... | +LL | | } +LL | | )); + | |_____^ the trait `Execute` is not implemented for `impl Execute` + | +note: required by a bound in `task` + --> $DIR/issue-62529-1.rs:70:10 + | +LL | fn task<P>(processor: P) -> Task + | ---- required by a bound in this +LL | where P: Execute + 'static { + | ^^^^^^^ required by this bound in `task` + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0277, E0631. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-2.rs b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-2.rs new file mode 100644 index 00000000000..00205473291 --- /dev/null +++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-2.rs @@ -0,0 +1,33 @@ +// check-pass + +use std::marker::PhantomData; + +trait Lt<'a> { + type T; +} +struct Id<T>(PhantomData<T>); +impl<'a,T> Lt<'a> for Id<T> { + type T = T; +} + +struct Ref<T>(PhantomData<T>) where T: ?Sized; +impl<'a,T> Lt<'a> for Ref<T> +where T: 'a + Lt<'a> + ?Sized +{ + type T = &'a T; +} +struct Mut<T>(PhantomData<T>) where T: ?Sized; +impl<'a,T> Lt<'a> for Mut<T> +where T: 'a + Lt<'a> + ?Sized +{ + type T = &'a mut T; +} + +struct C<I,O>(for<'a> fn(<I as Lt<'a>>::T) -> O) where I: for<'a> Lt<'a>; + + +fn main() { + let c = C::<Id<_>,_>(|()| 3); + c.0(()); + +} diff --git a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-3.rs b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-3.rs new file mode 100644 index 00000000000..d84e30f4984 --- /dev/null +++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-3.rs @@ -0,0 +1,32 @@ +trait ATC<'a> { + type Type: Sized; +} + +trait WithDefault: for<'a> ATC<'a> { + fn with_default<F: for<'a> Fn(<Self as ATC<'a>>::Type)>(f: F); +} + +fn call<'b, T: for<'a> ATC<'a>, F: for<'a> Fn(<T as ATC<'a>>::Type)>( + f: F, + x: <T as ATC<'b>>::Type, +) { + f(x); +} + +impl<'a> ATC<'a> for () { + type Type = Self; +} + +impl WithDefault for () { + fn with_default<F: for<'a> Fn(<Self as ATC<'a>>::Type)>(f: F) { + // Errors with a bogus type mismatch. + //f(()); + // Going through another generic function works fine. + call(f, ()); + //~^ expected a + } +} + +fn main() { + // <()>::with_default(|_| {}); +} diff --git a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-3.stderr b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-3.stderr new file mode 100644 index 00000000000..b1107346421 --- /dev/null +++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-3.stderr @@ -0,0 +1,15 @@ +error[E0277]: expected a `Fn<(<_ as ATC<'a>>::Type,)>` closure, found `F` + --> $DIR/issue-62529-3.rs:25:9 + | +LL | call(f, ()); + | ^^^^ expected an `Fn<(<_ as ATC<'a>>::Type,)>` closure, found `F` + | +note: required by a bound in `call` + --> $DIR/issue-62529-3.rs:9:36 + | +LL | fn call<'b, T: for<'a> ATC<'a>, F: for<'a> Fn(<T as ATC<'a>>::Type)>( + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `call` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-4.rs b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-4.rs new file mode 100644 index 00000000000..8c2a59868ca --- /dev/null +++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-4.rs @@ -0,0 +1,39 @@ +// check-pass + +use std::marker::PhantomData; +use std::mem; + +trait Container<'a> { + type Root: 'a; +} + +type RootOf<'a, T> = <T as Container<'a>>::Root; + +struct Test<'a, T> where T: Container<'a> { + pub root: T::Root, + marker: PhantomData<&'a mut &'a mut ()>, +} + +impl<'a, 'b> Container<'b> for &'a str { + type Root = &'b str; +} + +impl<'a, T> Test<'a, T> where T: for<'b> Container<'b> { + fn new(root: RootOf<'a, T>) -> Test<'a, T> { + Test { + root: root, + marker: PhantomData + } + } + + fn with_mut<F, R>(&mut self, f: F) -> R where + F: for<'b> FnOnce(&'b mut RootOf<'b, T>) -> R { + f(unsafe { mem::transmute(&mut self.root) }) + } +} + +fn main() { + let val = "root"; + let mut test: Test<&str> = Test::new(val); + test.with_mut(|_| { }); +} diff --git a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-5.rs b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-5.rs new file mode 100644 index 00000000000..03f257a029c --- /dev/null +++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-5.rs @@ -0,0 +1,27 @@ +// check-pass + +pub struct Struct {} + +pub trait Trait<'a> { + type Assoc; + + fn method() -> Self::Assoc; +} + +impl<'a> Trait<'a> for Struct { + type Assoc = (); + + fn method() -> Self::Assoc {} +} + +pub fn function<F, T>(f: F) +where + F: for<'a> FnOnce(<T as Trait<'a>>::Assoc), + T: for<'b> Trait<'b>, +{ + f(T::method()); +} + +fn main() { + function::<_, Struct>(|_| {}); +} diff --git a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-6.rs b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-6.rs new file mode 100644 index 00000000000..74a4785e478 --- /dev/null +++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-6.rs @@ -0,0 +1,77 @@ +// check-pass + +use std::cell::RefMut; + +fn main() { + StateMachine2::Init.resume(); +} + +enum StateMachine2<'a> { + Init, + #[allow(dead_code)] // match required for ICE + AfterTwoYields { + p: Backed<'a, *mut String>, + }, +} + +impl<'a> StateMachine2<'a> { + fn take(&self) -> Self { + StateMachine2::Init + } +} + +impl<'a> StateMachine2<'a> { + fn resume(&mut self) -> () { + use StateMachine2::*; + match self.take() { + AfterTwoYields { p } => { + p.with(|_| {}); + } + _ => panic!("Resume after completed."), + } + } +} + +unsafe trait Unpack<'a> { + type Unpacked: 'a; + + fn unpack(&self) -> Self::Unpacked { + unsafe { std::mem::transmute_copy(&self) } + } +} + +unsafe trait Pack { + type Packed; + + fn pack(&self) -> Self::Packed { + unsafe { std::mem::transmute_copy(&self) } + } +} + +unsafe impl<'a> Unpack<'a> for String { + type Unpacked = String; +} + +unsafe impl Pack for String { + type Packed = String; +} + +unsafe impl<'a> Unpack<'a> for *mut String { + type Unpacked = &'a mut String; +} + +unsafe impl<'a> Pack for &'a mut String { + type Packed = *mut String; +} + +struct Backed<'a, U>(RefMut<'a, Option<String>>, U); + +impl<'a, 'b, U: Unpack<'b>> Backed<'a, U> { + fn with<F>(self, f: F) -> Backed<'a, ()> + where + F: for<'f> FnOnce(<U as Unpack<'f>>::Unpacked) -> (), + { + let result = f(self.1.unpack()); + Backed(self.0, result) + } +} diff --git a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-70120.rs b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-70120.rs new file mode 100644 index 00000000000..87d1a250f7a --- /dev/null +++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-70120.rs @@ -0,0 +1,29 @@ +pub trait MyTrait<'a> { + type Output: 'a; + fn gimme_value(&self) -> Self::Output; +} + +pub struct MyStruct; + +impl<'a> MyTrait<'a> for MyStruct { + type Output = &'a usize; + fn gimme_value(&self) -> Self::Output { + unimplemented!() + } +} + +fn meow<T, F>(t: T, f: F) +where + T: for<'any> MyTrait<'any>, + F: for<'any2> Fn(<T as MyTrait<'any2>>::Output), +{ + let v = t.gimme_value(); + f(v); +} + +fn main() { + let struc = MyStruct; + meow(struc, |foo| { //~ type mismatch + println!("{:?}", foo); + }) +} diff --git a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-70120.stderr b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-70120.stderr new file mode 100644 index 00000000000..efc956888ee --- /dev/null +++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-70120.stderr @@ -0,0 +1,20 @@ +error[E0631]: type mismatch in closure arguments + --> $DIR/issue-70120.rs:26:5 + | +LL | meow(struc, |foo| { + | ^^^^ ----- found signature of `for<'r> fn(&'r usize) -> _` + | | + | expected signature of `for<'any2> fn(<MyStruct as MyTrait<'any2>>::Output) -> _` + | +note: required by a bound in `meow` + --> $DIR/issue-70120.rs:18:8 + | +LL | fn meow<T, F>(t: T, f: F) + | ---- required by a bound in this +... +LL | F: for<'any2> Fn(<T as MyTrait<'any2>>::Output), + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `meow` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0631`. diff --git a/src/test/ui/hrtb/issue-62203-hrtb-ice.stderr b/src/test/ui/hrtb/issue-62203-hrtb-ice.stderr index 7b81beeed41..97f53bc70e4 100644 --- a/src/test/ui/hrtb/issue-62203-hrtb-ice.stderr +++ b/src/test/ui/hrtb/issue-62203-hrtb-ice.stderr @@ -1,4 +1,4 @@ -error[E0271]: type mismatch resolving `for<'r> <L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39]> as T0<'r, (<Unit2 as Ty<'r>>::V,)>>::O == <_ as Ty<'r>>::V` +error[E0271]: type mismatch resolving `for<'r> <L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39]> as T0<'r, (&'r u8,)>>::O == <_ as Ty<'r>>::V` --> $DIR/issue-62203-hrtb-ice.rs:38:19 | LL | let v = Unit2.m( @@ -9,13 +9,13 @@ LL | let v = Unit2.m( = help: consider constraining the associated type `<_ as Ty<'_>>::V` to `Unit4` = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html -error[E0271]: type mismatch resolving `<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39] as FnOnce<((&u8,),)>>::Output == Unit3` +error[E0271]: type mismatch resolving `for<'r> <[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39] as FnOnce<((&'r u8,),)>>::Output == Unit3` --> $DIR/issue-62203-hrtb-ice.rs:38:19 | LL | let v = Unit2.m( | ^ expected struct `Unit4`, found struct `Unit3` | -note: required because of the requirements on the impl of `for<'r> T0<'r, (<Unit2 as Ty<'r>>::V,)>` for `L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39]>` +note: required because of the requirements on the impl of `for<'r> T0<'r, (&'r u8,)>` for `L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39]>` --> $DIR/issue-62203-hrtb-ice.rs:17:16 | LL | impl<'a, A, T> T0<'a, A> for L<T> diff --git a/src/test/ui/impl-trait/bound-normalization-fail.stderr b/src/test/ui/impl-trait/bound-normalization-fail.stderr index bf04a8c9873..3c720f50d48 100644 --- a/src/test/ui/impl-trait/bound-normalization-fail.stderr +++ b/src/test/ui/impl-trait/bound-normalization-fail.stderr @@ -5,7 +5,7 @@ LL | fn foo_fail<T: Trait>() -> impl FooLike<Output = T::Assoc> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected associated type, found `()` | = note: expected associated type `<T as impl_trait::Trait>::Assoc` - found type `()` + found unit type `()` help: consider constraining the associated type `<T as impl_trait::Trait>::Assoc` to `()` | LL | fn foo_fail<T: Trait<Assoc = ()>>() -> impl FooLike<Output = T::Assoc> { @@ -24,7 +24,7 @@ LL | fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike<Output = T::Assoc> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected associated type, found `()` | = note: expected associated type `<T as lifetimes::Trait<'static>>::Assoc` - found type `()` + found unit type `()` help: consider constraining the associated type `<T as lifetimes::Trait<'static>>::Assoc` to `()` | LL | fn foo2_fail<'a, T: Trait<'a, Assoc = ()>>() -> impl FooLike<Output = T::Assoc> { diff --git a/src/test/ui/issues/issue-35570.rs b/src/test/ui/issues/issue-35570.rs index fafef79ea5b..42cef9a47f2 100644 --- a/src/test/ui/issues/issue-35570.rs +++ b/src/test/ui/issues/issue-35570.rs @@ -1,5 +1,3 @@ -// check-pass - use std::mem; trait Trait1<T> {} @@ -8,6 +6,7 @@ trait Trait2<'a> { } fn _ice(param: Box<dyn for <'a> Trait1<<() as Trait2<'a>>::Ty>>) { +//~^ the trait bound `for<'a> (): Trait2<'a>` is not satisfied let _e: (usize, usize) = unsafe{mem::transmute(param)}; } diff --git a/src/test/ui/issues/issue-35570.stderr b/src/test/ui/issues/issue-35570.stderr new file mode 100644 index 00000000000..dda6145e65a --- /dev/null +++ b/src/test/ui/issues/issue-35570.stderr @@ -0,0 +1,9 @@ +error[E0277]: the trait bound `for<'a> (): Trait2<'a>` is not satisfied + --> $DIR/issue-35570.rs:8:4 + | +LL | fn _ice(param: Box<dyn for <'a> Trait1<<() as Trait2<'a>>::Ty>>) { + | ^^^^ the trait `for<'a> Trait2<'a>` is not implemented for `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/issues/issue-43623.rs b/src/test/ui/issues/issue-43623.rs index 99cae46fd9c..cedcf7c361c 100644 --- a/src/test/ui/issues/issue-43623.rs +++ b/src/test/ui/issues/issue-43623.rs @@ -1,3 +1,5 @@ +// check-pass + pub trait Trait<'a> { type Assoc; } @@ -14,7 +16,6 @@ where F: for<'b> FnMut(<T as Trait<'b>>::Assoc), { break_me::<Type, fn(_)>; - //~^ ERROR: type mismatch in function arguments } fn main() {} diff --git a/src/test/ui/issues/issue-43623.stderr b/src/test/ui/issues/issue-43623.stderr deleted file mode 100644 index b99f367d733..00000000000 --- a/src/test/ui/issues/issue-43623.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0631]: type mismatch in function arguments - --> $DIR/issue-43623.rs:16:5 - | -LL | break_me::<Type, fn(_)>; - | ^^^^^^^^^^^^^^^^^^^^^^^ - | | - | expected signature of `for<'b> fn(<Type as Trait<'b>>::Assoc) -> _` - | found signature of `fn(()) -> _` - | -note: required by a bound in `break_me` - --> $DIR/issue-43623.rs:14:16 - | -LL | pub fn break_me<T, F>(f: F) - | -------- required by a bound in this -... -LL | F: for<'b> FnMut(<T as Trait<'b>>::Assoc), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `break_me` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0631`. diff --git a/src/test/ui/issues/issue-44005.rs b/src/test/ui/issues/issue-44005.rs index 041fcdbf823..ab3b92142c8 100644 --- a/src/test/ui/issues/issue-44005.rs +++ b/src/test/ui/issues/issue-44005.rs @@ -1,4 +1,3 @@ -// build-pass pub trait Foo<'a> { type Bar; fn foo(&'a self) -> Self::Bar; @@ -12,8 +11,9 @@ impl<'a, 'b, T: 'a> Foo<'a> for &'b T { } pub fn uncallable<T, F>(x: T, f: F) - where T: for<'a> Foo<'a>, - F: for<'a> Fn(<T as Foo<'a>>::Bar) +where + T: for<'a> Foo<'a>, + F: for<'a> Fn(<T as Foo<'a>>::Bar), { f(x.foo()); } @@ -24,6 +24,7 @@ pub fn catalyst(x: &i32) { pub fn broken<F: Fn(&i32)>(x: &i32, f: F) { uncallable(x, |y| f(y)); + //~^ type mismatch } -fn main() { } +fn main() {} diff --git a/src/test/ui/issues/issue-44005.stderr b/src/test/ui/issues/issue-44005.stderr new file mode 100644 index 00000000000..307e444e696 --- /dev/null +++ b/src/test/ui/issues/issue-44005.stderr @@ -0,0 +1,20 @@ +error[E0631]: type mismatch in closure arguments + --> $DIR/issue-44005.rs:26:5 + | +LL | uncallable(x, |y| f(y)); + | ^^^^^^^^^^ -------- found signature of `for<'r> fn(&'r i32) -> _` + | | + | expected signature of `for<'a> fn(<&i32 as Foo<'a>>::Bar) -> _` + | +note: required by a bound in `uncallable` + --> $DIR/issue-44005.rs:16:8 + | +LL | pub fn uncallable<T, F>(x: T, f: F) + | ---------- required by a bound in this +... +LL | F: for<'a> Fn(<T as Foo<'a>>::Bar), + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `uncallable` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0631`. diff --git a/src/test/ui/issues/issue-57843.nll.stderr b/src/test/ui/issues/issue-57843.nll.stderr deleted file mode 100644 index 2ab49ec61cf..00000000000 --- a/src/test/ui/issues/issue-57843.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: implementation of `FnOnce` is not general enough - --> $DIR/issue-57843.rs:25:9 - | -LL | Foo(Box::new(|_| ())); - | ^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough - | - = note: closure with signature `fn(&'2 bool)` must implement `FnOnce<(&'1 bool,)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&'2 bool,)>`, for some specific lifetime `'2` - -error: aborting due to previous error - diff --git a/src/test/ui/issues/issue-60218.stderr b/src/test/ui/issues/issue-60218.stderr index a16363d7c87..ac33cfd0402 100644 --- a/src/test/ui/issues/issue-60218.stderr +++ b/src/test/ui/issues/issue-60218.stderr @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `for<'t> <Map<<&'t _ as IntoIterator>::IntoIter, _> as Iterator>::Item: Foo` is not satisfied +error[E0277]: the trait bound `&u32: Foo` is not satisfied --> $DIR/issue-60218.rs:18:5 | LL | trigger_error(vec![], |x: &u32| x) - | ^^^^^^^^^^^^^ the trait `for<'t> Foo` is not implemented for `<Map<<&'t _ as IntoIterator>::IntoIter, _> as Iterator>::Item` + | ^^^^^^^^^^^^^ the trait `Foo` is not implemented for `&u32` | note: required by a bound in `trigger_error` --> $DIR/issue-60218.rs:13:72 diff --git a/src/test/ui/issues/issue-67039-unsound-pin-partialeq.stderr b/src/test/ui/issues/issue-67039-unsound-pin-partialeq.stderr index 036a9300a17..733456a1a8b 100644 --- a/src/test/ui/issues/issue-67039-unsound-pin-partialeq.stderr +++ b/src/test/ui/issues/issue-67039-unsound-pin-partialeq.stderr @@ -4,8 +4,8 @@ error[E0271]: type mismatch resolving `<Rc<Apple> as Deref>::Target == Rc<Apple> LL | let _ = Pin::new(Apple) == Rc::pin(Apple); | ^^ expected struct `Apple`, found struct `Rc` | - = note: expected type `Apple` - found struct `Rc<Apple>` + = note: expected struct `Apple` + found struct `Rc<Apple>` = note: required because of the requirements on the impl of `PartialEq<Pin<Rc<Apple>>>` for `Pin<Apple>` error: aborting due to previous error diff --git a/src/test/ui/mismatched_types/issue-75361-mismatched-impl.stderr b/src/test/ui/mismatched_types/issue-75361-mismatched-impl.stderr index a64cb82305a..9867addaf38 100644 --- a/src/test/ui/mismatched_types/issue-75361-mismatched-impl.stderr +++ b/src/test/ui/mismatched_types/issue-75361-mismatched-impl.stderr @@ -2,10 +2,10 @@ error: `impl` item signature doesn't match `trait` item signature --> $DIR/issue-75361-mismatched-impl.rs:18:3 | LL | fn adjacent_edges(&self) -> Box<dyn MyTrait<Item = &Self::EdgeType>>; - | --------------------------------------------------------------------- expected `fn(&T) -> Box<(dyn MyTrait<Item = &_> + 'static)>` + | --------------------------------------------------------------------- expected `fn(&T) -> Box<(dyn MyTrait<Item = &T> + 'static)>` ... LL | fn adjacent_edges(&self) -> Box<dyn MyTrait<Item = &Self::EdgeType> + '_> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&T) -> Box<dyn MyTrait<Item = &_>>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&T) -> Box<dyn MyTrait<Item = &T>>` | = note: expected `fn(&T) -> Box<(dyn MyTrait<Item = &T> + 'static)>` found `fn(&T) -> Box<dyn MyTrait<Item = &T>>` diff --git a/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.rs b/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.rs index a4272802af5..c1dab6086ef 100644 --- a/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.rs +++ b/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.rs @@ -19,7 +19,7 @@ trait Trait2<'a, 'b> { // since for it to be WF, we would need to know that `'y: 'x`, but we // do not infer that. fn callee<'x, 'y, T>(t: &'x dyn for<'z> Trait1< <T as Trait2<'y, 'z>>::Foo >) - //~^ ERROR reference has a longer lifetime than the data it references + //~^ the trait bound `for<'z> T: Trait2<'y, 'z>` is not satisfied { } diff --git a/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.stderr b/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.stderr index 6470ebf541b..44ef13c740c 100644 --- a/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.stderr +++ b/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.stderr @@ -1,20 +1,14 @@ -error[E0491]: in type `&'x (dyn for<'z> Trait1<<T as Trait2<'y, 'z>>::Foo> + 'x)`, reference has a longer lifetime than the data it references - --> $DIR/regions-implied-bounds-projection-gap-hr-1.rs:21:25 +error[E0277]: the trait bound `for<'z> T: Trait2<'y, 'z>` is not satisfied + --> $DIR/regions-implied-bounds-projection-gap-hr-1.rs:21:4 | LL | fn callee<'x, 'y, T>(t: &'x dyn for<'z> Trait1< <T as Trait2<'y, 'z>>::Foo >) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^ the trait `for<'z> Trait2<'y, 'z>` is not implemented for `T` | -note: the pointer is valid for the lifetime `'x` as defined on the function body at 21:11 - --> $DIR/regions-implied-bounds-projection-gap-hr-1.rs:21:11 +help: consider restricting type parameter `T` | -LL | fn callee<'x, 'y, T>(t: &'x dyn for<'z> Trait1< <T as Trait2<'y, 'z>>::Foo >) - | ^^ -note: but the referenced data is only valid for the lifetime `'y` as defined on the function body at 21:15 - --> $DIR/regions-implied-bounds-projection-gap-hr-1.rs:21:15 - | -LL | fn callee<'x, 'y, T>(t: &'x dyn for<'z> Trait1< <T as Trait2<'y, 'z>>::Foo >) - | ^^ +LL | fn callee<'x, 'y, T: for<'z> Trait2<'y, 'z>>(t: &'x dyn for<'z> Trait1< <T as Trait2<'y, 'z>>::Foo >) + | ++++++++++++++++++++++++ error: aborting due to previous error -For more information about this error, try `rustc --explain E0491`. +For more information about this error, try `rustc --explain E0277`. |
