diff options
Diffstat (limited to '')
49 files changed, 252 insertions, 54 deletions
diff --git a/src/test/ui/hrtb/complex.rs b/src/test/ui/higher-rank-trait-bounds/complex.rs index 8cdfe247e..8cdfe247e 100644 --- a/src/test/ui/hrtb/complex.rs +++ b/src/test/ui/higher-rank-trait-bounds/complex.rs diff --git a/src/test/ui/hrtb/due-to-where-clause.rs b/src/test/ui/higher-rank-trait-bounds/due-to-where-clause.rs index 1afd15613..1afd15613 100644 --- a/src/test/ui/hrtb/due-to-where-clause.rs +++ b/src/test/ui/higher-rank-trait-bounds/due-to-where-clause.rs diff --git a/src/test/ui/hrtb/due-to-where-clause.stderr b/src/test/ui/higher-rank-trait-bounds/due-to-where-clause.stderr index 520938a63..520938a63 100644 --- a/src/test/ui/hrtb/due-to-where-clause.stderr +++ b/src/test/ui/higher-rank-trait-bounds/due-to-where-clause.stderr diff --git a/src/test/ui/hrtb/hrtb-cache-issue-54302.rs b/src/test/ui/higher-rank-trait-bounds/hrtb-cache-issue-54302.rs index a20d03c77..a20d03c77 100644 --- a/src/test/ui/hrtb/hrtb-cache-issue-54302.rs +++ b/src/test/ui/higher-rank-trait-bounds/hrtb-cache-issue-54302.rs diff --git a/src/test/ui/hrtb/hrtb-cache-issue-54302.stderr b/src/test/ui/higher-rank-trait-bounds/hrtb-cache-issue-54302.stderr index f014eab86..f014eab86 100644 --- a/src/test/ui/hrtb/hrtb-cache-issue-54302.stderr +++ b/src/test/ui/higher-rank-trait-bounds/hrtb-cache-issue-54302.stderr diff --git a/src/test/ui/hrtb/hrtb-conflate-regions.rs b/src/test/ui/higher-rank-trait-bounds/hrtb-conflate-regions.rs index e83686404..e83686404 100644 --- a/src/test/ui/hrtb/hrtb-conflate-regions.rs +++ b/src/test/ui/higher-rank-trait-bounds/hrtb-conflate-regions.rs diff --git a/src/test/ui/hrtb/hrtb-conflate-regions.stderr b/src/test/ui/higher-rank-trait-bounds/hrtb-conflate-regions.stderr index 46f5308dd..46f5308dd 100644 --- a/src/test/ui/hrtb/hrtb-conflate-regions.stderr +++ b/src/test/ui/higher-rank-trait-bounds/hrtb-conflate-regions.stderr diff --git a/src/test/ui/hrtb/hrtb-debruijn-in-receiver.rs b/src/test/ui/higher-rank-trait-bounds/hrtb-debruijn-in-receiver.rs index 05d3e1a43..05d3e1a43 100644 --- a/src/test/ui/hrtb/hrtb-debruijn-in-receiver.rs +++ b/src/test/ui/higher-rank-trait-bounds/hrtb-debruijn-in-receiver.rs diff --git a/src/test/ui/hrtb/hrtb-debruijn-in-receiver.stderr b/src/test/ui/higher-rank-trait-bounds/hrtb-debruijn-in-receiver.stderr index fa391ecba..fa391ecba 100644 --- a/src/test/ui/hrtb/hrtb-debruijn-in-receiver.stderr +++ b/src/test/ui/higher-rank-trait-bounds/hrtb-debruijn-in-receiver.stderr diff --git a/src/test/ui/hrtb/hrtb-exists-forall-fn.rs b/src/test/ui/higher-rank-trait-bounds/hrtb-exists-forall-fn.rs index 567802376..567802376 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-fn.rs +++ b/src/test/ui/higher-rank-trait-bounds/hrtb-exists-forall-fn.rs diff --git a/src/test/ui/hrtb/hrtb-exists-forall-fn.stderr b/src/test/ui/higher-rank-trait-bounds/hrtb-exists-forall-fn.stderr index 9914783d9..9914783d9 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-fn.stderr +++ b/src/test/ui/higher-rank-trait-bounds/hrtb-exists-forall-fn.stderr diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.rs b/src/test/ui/higher-rank-trait-bounds/hrtb-exists-forall-trait-contravariant.rs index 921061916..921061916 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.rs +++ b/src/test/ui/higher-rank-trait-bounds/hrtb-exists-forall-trait-contravariant.rs diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.stderr b/src/test/ui/higher-rank-trait-bounds/hrtb-exists-forall-trait-contravariant.stderr index 364b613fc..364b613fc 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.stderr +++ b/src/test/ui/higher-rank-trait-bounds/hrtb-exists-forall-trait-contravariant.stderr diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-covariant.rs b/src/test/ui/higher-rank-trait-bounds/hrtb-exists-forall-trait-covariant.rs index f95496a6c..f95496a6c 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-trait-covariant.rs +++ b/src/test/ui/higher-rank-trait-bounds/hrtb-exists-forall-trait-covariant.rs diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.rs b/src/test/ui/higher-rank-trait-bounds/hrtb-exists-forall-trait-invariant.rs index 9b9e4496a..9b9e4496a 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.rs +++ b/src/test/ui/higher-rank-trait-bounds/hrtb-exists-forall-trait-invariant.rs diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.stderr b/src/test/ui/higher-rank-trait-bounds/hrtb-exists-forall-trait-invariant.stderr index cb2ce8a41..cb2ce8a41 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.stderr +++ b/src/test/ui/higher-rank-trait-bounds/hrtb-exists-forall-trait-invariant.stderr diff --git a/src/test/ui/hrtb/hrtb-higher-ranker-supertraits-transitive.rs b/src/test/ui/higher-rank-trait-bounds/hrtb-higher-ranker-supertraits-transitive.rs index f9ae1429e..f9ae1429e 100644 --- a/src/test/ui/hrtb/hrtb-higher-ranker-supertraits-transitive.rs +++ b/src/test/ui/higher-rank-trait-bounds/hrtb-higher-ranker-supertraits-transitive.rs diff --git a/src/test/ui/hrtb/hrtb-higher-ranker-supertraits-transitive.stderr b/src/test/ui/higher-rank-trait-bounds/hrtb-higher-ranker-supertraits-transitive.stderr index 8cda76b94..8cda76b94 100644 --- a/src/test/ui/hrtb/hrtb-higher-ranker-supertraits-transitive.stderr +++ b/src/test/ui/higher-rank-trait-bounds/hrtb-higher-ranker-supertraits-transitive.stderr diff --git a/src/test/ui/hrtb/hrtb-higher-ranker-supertraits.rs b/src/test/ui/higher-rank-trait-bounds/hrtb-higher-ranker-supertraits.rs index 48ebe5017..48ebe5017 100644 --- a/src/test/ui/hrtb/hrtb-higher-ranker-supertraits.rs +++ b/src/test/ui/higher-rank-trait-bounds/hrtb-higher-ranker-supertraits.rs diff --git a/src/test/ui/hrtb/hrtb-higher-ranker-supertraits.stderr b/src/test/ui/higher-rank-trait-bounds/hrtb-higher-ranker-supertraits.stderr index 88793a152..88793a152 100644 --- a/src/test/ui/hrtb/hrtb-higher-ranker-supertraits.stderr +++ b/src/test/ui/higher-rank-trait-bounds/hrtb-higher-ranker-supertraits.stderr diff --git a/src/test/ui/hrtb/hrtb-identity-fn-borrows.rs b/src/test/ui/higher-rank-trait-bounds/hrtb-identity-fn-borrows.rs index 89fc4705a..89fc4705a 100644 --- a/src/test/ui/hrtb/hrtb-identity-fn-borrows.rs +++ b/src/test/ui/higher-rank-trait-bounds/hrtb-identity-fn-borrows.rs diff --git a/src/test/ui/hrtb/hrtb-identity-fn-borrows.stderr b/src/test/ui/higher-rank-trait-bounds/hrtb-identity-fn-borrows.stderr index 4886a3c8b..4886a3c8b 100644 --- a/src/test/ui/hrtb/hrtb-identity-fn-borrows.stderr +++ b/src/test/ui/higher-rank-trait-bounds/hrtb-identity-fn-borrows.stderr diff --git a/src/test/ui/hrtb/hrtb-just-for-static.rs b/src/test/ui/higher-rank-trait-bounds/hrtb-just-for-static.rs index 8fb4218f8..8fb4218f8 100644 --- a/src/test/ui/hrtb/hrtb-just-for-static.rs +++ b/src/test/ui/higher-rank-trait-bounds/hrtb-just-for-static.rs diff --git a/src/test/ui/hrtb/hrtb-just-for-static.stderr b/src/test/ui/higher-rank-trait-bounds/hrtb-just-for-static.stderr index b4312091e..31e11e128 100644 --- a/src/test/ui/hrtb/hrtb-just-for-static.stderr +++ b/src/test/ui/higher-rank-trait-bounds/hrtb-just-for-static.stderr @@ -14,6 +14,12 @@ LL | fn give_some<'a>() { | -- lifetime `'a` defined here LL | want_hrtb::<&'a u32>() | ^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` + | +note: due to current limitations in the borrow checker, this implies a `'static` lifetime + --> $DIR/hrtb-just-for-static.rs:9:15 + | +LL | where T : for<'a> Foo<&'a isize> + | ^^^^^^^^^^^^^^^^^^^^^^ error: implementation of `Foo` is not general enough --> $DIR/hrtb-just-for-static.rs:30:5 diff --git a/src/test/ui/hrtb/hrtb-perfect-forwarding.polonius.stderr b/src/test/ui/higher-rank-trait-bounds/hrtb-perfect-forwarding.polonius.stderr index a94c80eb3..a94c80eb3 100644 --- a/src/test/ui/hrtb/hrtb-perfect-forwarding.polonius.stderr +++ b/src/test/ui/higher-rank-trait-bounds/hrtb-perfect-forwarding.polonius.stderr diff --git a/src/test/ui/hrtb/hrtb-perfect-forwarding.rs b/src/test/ui/higher-rank-trait-bounds/hrtb-perfect-forwarding.rs index d45fa183c..d45fa183c 100644 --- a/src/test/ui/hrtb/hrtb-perfect-forwarding.rs +++ b/src/test/ui/higher-rank-trait-bounds/hrtb-perfect-forwarding.rs diff --git a/src/test/ui/hrtb/hrtb-perfect-forwarding.stderr b/src/test/ui/higher-rank-trait-bounds/hrtb-perfect-forwarding.stderr index 1461e7fd2..727b9e6be 100644 --- a/src/test/ui/hrtb/hrtb-perfect-forwarding.stderr +++ b/src/test/ui/higher-rank-trait-bounds/hrtb-perfect-forwarding.stderr @@ -9,8 +9,8 @@ LL | | T: Bar<&'b isize>, LL | no_hrtb(&mut t); | --------------- recursive call site | - = note: `#[warn(unconditional_recursion)]` on by default = help: a `loop` may express intention better if this is on purpose + = note: `#[warn(unconditional_recursion)]` on by default warning: function cannot return without recursing --> $DIR/hrtb-perfect-forwarding.rs:25:1 @@ -46,6 +46,12 @@ LL | fn foo_hrtb_bar_not<'b, T>(mut t: T) ... LL | foo_hrtb_bar_not(&mut t); | ^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'b` must outlive `'static` + | +note: due to current limitations in the borrow checker, this implies a `'static` lifetime + --> $DIR/hrtb-perfect-forwarding.rs:37:8 + | +LL | T: for<'a> Foo<&'a isize> + Bar<&'b isize>, + | ^^^^^^^^^^^^^^^^^^^^^^ error: implementation of `Bar` is not general enough --> $DIR/hrtb-perfect-forwarding.rs:43:5 diff --git a/src/test/ui/higher-rank-trait-bounds/issue-100689.rs b/src/test/ui/higher-rank-trait-bounds/issue-100689.rs new file mode 100644 index 000000000..2db7f8a35 --- /dev/null +++ b/src/test/ui/higher-rank-trait-bounds/issue-100689.rs @@ -0,0 +1,29 @@ +// check-pass + +struct Foo<'a> { + foo: &'a mut usize, +} + +trait Bar<'a> { + type FooRef<'b> + where + 'a: 'b; + fn uwu(foo: Foo<'a>, f: impl for<'b> FnMut(Self::FooRef<'b>)); +} +impl<'a> Bar<'a> for () { + type FooRef<'b> + = + &'b Foo<'a> + where + 'a : 'b, + ; + + fn uwu( + foo: Foo<'a>, + mut f: impl for<'b> FnMut(&'b Foo<'a>), //relevant part + ) { + f(&foo); + } +} + +fn main() {} diff --git a/src/test/ui/higher-rank-trait-bounds/issue-102899.rs b/src/test/ui/higher-rank-trait-bounds/issue-102899.rs new file mode 100644 index 000000000..952b81584 --- /dev/null +++ b/src/test/ui/higher-rank-trait-bounds/issue-102899.rs @@ -0,0 +1,32 @@ +// check-pass + +pub trait BufferTrait<'buffer> { + type Subset<'channel> + where + 'buffer: 'channel; + + fn for_each_subset<F>(&self, f: F) + where + F: for<'channel> Fn(Self::Subset<'channel>); +} + +pub struct SomeBuffer<'buffer> { + samples: &'buffer [()], +} + +impl<'buffer> BufferTrait<'buffer> for SomeBuffer<'buffer> { + type Subset<'subset> = Subset<'subset> where 'buffer: 'subset; + + fn for_each_subset<F>(&self, _f: F) + where + F: for<'subset> Fn(Subset<'subset>), + { + todo!() + } +} + +pub struct Subset<'subset> { + buffer: &'subset [()], +} + +fn main() {} diff --git a/src/test/ui/hrtb/issue-30786.rs b/src/test/ui/higher-rank-trait-bounds/issue-30786.rs index e5f46f711..e5f46f711 100644 --- a/src/test/ui/hrtb/issue-30786.rs +++ b/src/test/ui/higher-rank-trait-bounds/issue-30786.rs diff --git a/src/test/ui/hrtb/issue-30786.stderr b/src/test/ui/higher-rank-trait-bounds/issue-30786.stderr index bc7b5e914..c1e235441 100644 --- a/src/test/ui/hrtb/issue-30786.stderr +++ b/src/test/ui/higher-rank-trait-bounds/issue-30786.stderr @@ -18,12 +18,8 @@ note: the following trait bounds were not satisfied: | LL | impl<T> StreamExt for T where for<'a> &'a mut T: Stream {} | --------- - ^^^^^^ unsatisfied trait bound introduced here -help: one of the expressions' fields has a method of the same name - | -LL | let filter = map.stream.filterx(|x: &_| true); - | +++++++ -error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>`, but its trait bounds were not satisfied +error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>`, but its trait bounds were not satisfied --> $DIR/issue-30786.rs:130:24 | LL | pub struct Filter<S, F> { @@ -33,20 +29,16 @@ LL | pub struct Filter<S, F> { | doesn't satisfy `_: StreamExt` ... LL | let count = filter.countx(); - | ^^^^^^ method cannot be called on `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>` due to unsatisfied trait bounds + | ^^^^^^ method cannot be called on `Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>` due to unsatisfied trait bounds | note: the following trait bounds were not satisfied: - `&'a mut &Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>: Stream` - `&'a mut &mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>: Stream` - `&'a mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>: Stream` + `&'a mut &Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>: Stream` + `&'a mut &mut Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>: Stream` + `&'a mut Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>: Stream` --> $DIR/issue-30786.rs:96:50 | LL | impl<T> StreamExt for T where for<'a> &'a mut T: Stream {} | --------- - ^^^^^^ unsatisfied trait bound introduced here -help: one of the expressions' fields has a method of the same name - | -LL | let count = filter.stream.countx(); - | +++++++ error: aborting due to 2 previous errors diff --git a/src/test/ui/hrtb/issue-46989.rs b/src/test/ui/higher-rank-trait-bounds/issue-46989.rs index 4a09f4be1..4a09f4be1 100644 --- a/src/test/ui/hrtb/issue-46989.rs +++ b/src/test/ui/higher-rank-trait-bounds/issue-46989.rs diff --git a/src/test/ui/hrtb/issue-46989.stderr b/src/test/ui/higher-rank-trait-bounds/issue-46989.stderr index 309e1a676..3f874220a 100644 --- a/src/test/ui/hrtb/issue-46989.stderr +++ b/src/test/ui/higher-rank-trait-bounds/issue-46989.stderr @@ -4,7 +4,7 @@ error: implementation of `Foo` is not general enough LL | assert_foo::<fn(&i32)>(); | ^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough | - = note: `Foo` would have to be implemented for the type `for<'r> fn(&'r i32)` + = note: `Foo` would have to be implemented for the type `for<'a> fn(&'a i32)` = note: ...but `Foo` is actually implemented for the type `fn(&'0 i32)`, for some specific lifetime `'0` error: aborting due to previous error diff --git a/src/test/ui/hrtb/issue-57639.rs b/src/test/ui/higher-rank-trait-bounds/issue-57639.rs index 392e7233b..392e7233b 100644 --- a/src/test/ui/hrtb/issue-57639.rs +++ b/src/test/ui/higher-rank-trait-bounds/issue-57639.rs diff --git a/src/test/ui/hrtb/issue-58451.rs b/src/test/ui/higher-rank-trait-bounds/issue-58451.rs index f36d549e4..f36d549e4 100644 --- a/src/test/ui/hrtb/issue-58451.rs +++ b/src/test/ui/higher-rank-trait-bounds/issue-58451.rs diff --git a/src/test/ui/hrtb/issue-58451.stderr b/src/test/ui/higher-rank-trait-bounds/issue-58451.stderr index 22ba63c3e..09e25f4dc 100644 --- a/src/test/ui/hrtb/issue-58451.stderr +++ b/src/test/ui/higher-rank-trait-bounds/issue-58451.stderr @@ -12,7 +12,7 @@ LL | fn f<I>(i: I) help: provide the argument | LL | f(&[f(/* value */)]); - | ~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~ error: aborting due to previous error diff --git a/src/test/ui/hrtb/issue-62203-hrtb-ice.rs b/src/test/ui/higher-rank-trait-bounds/issue-62203-hrtb-ice.rs index 80f099ce3..e70f6fc34 100644 --- a/src/test/ui/hrtb/issue-62203-hrtb-ice.rs +++ b/src/test/ui/higher-rank-trait-bounds/issue-62203-hrtb-ice.rs @@ -36,11 +36,15 @@ trait Ty<'a> { fn main() { let v = Unit2.m( - //~^ ERROR type mismatch L { - //~^ ERROR type mismatch - f : |x| { drop(x); Unit4 } - }); + //~^ ERROR to be a closure that returns `Unit3`, but it returns `Unit4` + //~| ERROR type mismatch + f: |x| { + drop(x); + Unit4 + }, + }, + ); } impl<'a> Ty<'a> for Unit2 { diff --git a/src/test/ui/higher-rank-trait-bounds/issue-62203-hrtb-ice.stderr b/src/test/ui/higher-rank-trait-bounds/issue-62203-hrtb-ice.stderr new file mode 100644 index 000000000..ab5598e36 --- /dev/null +++ b/src/test/ui/higher-rank-trait-bounds/issue-62203-hrtb-ice.stderr @@ -0,0 +1,63 @@ +error[E0271]: type mismatch resolving `for<'r> <L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:16: 42:19]> as T0<'r, (&'r u8,)>>::O == <_ as Ty<'r>>::V` + --> $DIR/issue-62203-hrtb-ice.rs:39:9 + | +LL | let v = Unit2.m( + | - required by a bound introduced by this call +LL | / L { +LL | | +LL | | +LL | | f: |x| { +... | +LL | | }, +LL | | }, + | |_________^ type mismatch resolving `for<'r> <L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:16: 42:19]> as T0<'r, (&'r u8,)>>::O == <_ as Ty<'r>>::V` + | +note: expected this to be `<_ as Ty<'_>>::V` + --> $DIR/issue-62203-hrtb-ice.rs:21:14 + | +LL | type O = T::Output; + | ^^^^^^^^^ + = note: expected associated type `<_ as Ty<'_>>::V` + found struct `Unit4` + = help: consider constraining the associated type `<_ as Ty<'_>>::V` to `Unit4` or calling a method that returns `<_ as Ty<'_>>::V` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html +note: required by a bound in `T1::m` + --> $DIR/issue-62203-hrtb-ice.rs:27:51 + | +LL | fn m<'a, B: Ty<'a>, F>(&self, f: F) -> Unit1 + | - required by a bound in this +LL | where +LL | F: for<'r> T0<'r, (<Self as Ty<'r>>::V,), O = <B as Ty<'r>>::V>, + | ^^^^^^^^^^^^^^^^^^^^ required by this bound in `T1::m` + +error[E0271]: expected `[closure@$DIR/issue-62203-hrtb-ice.rs:42:16: 42:19]` to be a closure that returns `Unit3`, but it returns `Unit4` + --> $DIR/issue-62203-hrtb-ice.rs:39:9 + | +LL | let v = Unit2.m( + | - required by a bound introduced by this call +LL | / L { +LL | | +LL | | +LL | | f: |x| { +... | +LL | | }, +LL | | }, + | |_________^ expected struct `Unit3`, found struct `Unit4` + | +note: required for `L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:16: 42:19]>` to implement `for<'r> T0<'r, (&'r u8,)>` + --> $DIR/issue-62203-hrtb-ice.rs:17:16 + | +LL | impl<'a, A, T> T0<'a, A> for L<T> + | ^^^^^^^^^ ^^^^ +note: required by a bound in `T1::m` + --> $DIR/issue-62203-hrtb-ice.rs:27:12 + | +LL | fn m<'a, B: Ty<'a>, F>(&self, f: F) -> Unit1 + | - required by a bound in this +LL | where +LL | F: for<'r> T0<'r, (<Self as Ty<'r>>::V,), O = <B as Ty<'r>>::V>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `T1::m` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0271`. diff --git a/src/test/ui/hrtb/issue-88446.rs b/src/test/ui/higher-rank-trait-bounds/issue-88446.rs index 571b85317..571b85317 100644 --- a/src/test/ui/hrtb/issue-88446.rs +++ b/src/test/ui/higher-rank-trait-bounds/issue-88446.rs diff --git a/src/test/ui/hrtb/issue-90177.rs b/src/test/ui/higher-rank-trait-bounds/issue-90177.rs index b151a9d3a..b151a9d3a 100644 --- a/src/test/ui/hrtb/issue-90177.rs +++ b/src/test/ui/higher-rank-trait-bounds/issue-90177.rs diff --git a/src/test/ui/higher-rank-trait-bounds/issue-95034.rs b/src/test/ui/higher-rank-trait-bounds/issue-95034.rs new file mode 100644 index 000000000..af4946a18 --- /dev/null +++ b/src/test/ui/higher-rank-trait-bounds/issue-95034.rs @@ -0,0 +1,80 @@ +// check-pass +// compile-flags: --edition=2021 --crate-type=lib + +use std::{ + future::Future, + marker::PhantomData, + pin::Pin, + task::{Context, Poll}, +}; + +mod object { + use super::*; + + pub trait Object<'a> { + type Error; + type Future: Future<Output = Self>; + fn create() -> Self::Future; + } + + impl<'a> Object<'a> for u8 { + type Error = (); + type Future = Pin<Box<dyn Future<Output = Self>>>; + fn create() -> Self::Future { + unimplemented!() + } + } + + impl<'a, E, A: Object<'a, Error = E>> Object<'a> for (A,) { + type Error = (); + type Future = CustomFut<'a, E, A>; + fn create() -> Self::Future { + unimplemented!() + } + } + + pub struct CustomFut<'f, E, A: Object<'f, Error = E>> { + ph: PhantomData<(A::Future,)>, + } + + impl<'f, E, A: Object<'f, Error = E>> Future for CustomFut<'f, E, A> { + type Output = (A,); + fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Self::Output> { + unimplemented!() + } + } +} + +mod async_fn { + use super::*; + + pub trait AsyncFn { + type Future: Future<Output = ()>; + fn call(&self) -> Self::Future; + } + + impl<F, Fut> AsyncFn for F + where + F: Fn() -> Fut, + Fut: Future<Output = ()>, + { + type Future = Fut; + fn call(&self) -> Self::Future { + (self)() + } + } +} + +pub async fn test() { + use self::{async_fn::AsyncFn, object::Object}; + + async fn create<T: Object<'static>>() { + T::create().await; + } + + async fn call_async_fn(inner: impl AsyncFn) { + inner.call().await; + } + + call_async_fn(create::<(u8,)>).await; +} diff --git a/src/test/ui/hrtb/issue-95230.rs b/src/test/ui/higher-rank-trait-bounds/issue-95230.rs index 92c506eab..92c506eab 100644 --- a/src/test/ui/hrtb/issue-95230.rs +++ b/src/test/ui/higher-rank-trait-bounds/issue-95230.rs 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 index 066bf431a..b30dd36d2 100644 --- 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 @@ -1,8 +1,10 @@ error[E0277]: expected a `Fn<(<_ as ATC<'a>>::Type,)>` closure, found `F` - --> $DIR/issue-62529-3.rs:25:9 + --> $DIR/issue-62529-3.rs:25:14 | LL | call(f, ()); - | ^^^^ expected an `Fn<(<_ as ATC<'a>>::Type,)>` closure, found `F` + | ---- ^ expected an `Fn<(<_ as ATC<'a>>::Type,)>` closure, found `F` + | | + | required by a bound introduced by this call | = note: expected a closure with arguments `((),)` found a closure with arguments `(<_ as ATC<'a>>::Type,)` diff --git a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.stderr b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.stderr index eebce827d..4ef96cd95 100644 --- a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.stderr +++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.stderr @@ -4,8 +4,8 @@ error[E0308]: mismatched types LL | foo(bar, "string", |s| s.len() == 5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other | - = note: expected trait `for<'r, 's> FnOnce<(&'r &'s str,)>` - found trait `for<'r> FnOnce<(&'r &str,)>` + = note: expected trait `for<'a, 'b> FnOnce<(&'a &'b str,)>` + found trait `for<'a> FnOnce<(&'a &str,)>` note: this closure does not fulfill the lifetime requirements --> $DIR/issue-71955.rs:45:24 | @@ -23,8 +23,8 @@ error[E0308]: mismatched types LL | foo(bar, "string", |s| s.len() == 5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other | - = note: expected trait `for<'r, 's> FnOnce<(&'r &'s str,)>` - found trait `for<'r> FnOnce<(&'r &str,)>` + = note: expected trait `for<'a, 'b> FnOnce<(&'a &'b str,)>` + found trait `for<'a> FnOnce<(&'a &str,)>` note: this closure does not fulfill the lifetime requirements --> $DIR/issue-71955.rs:45:24 | @@ -42,8 +42,8 @@ error[E0308]: mismatched types LL | foo(baz, "string", |s| s.0.len() == 5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other | - = note: expected trait `for<'r, 's> FnOnce<(&'r Wrapper<'s>,)>` - found trait `for<'r> FnOnce<(&'r Wrapper<'_>,)>` + = note: expected trait `for<'a, 'b> FnOnce<(&'a Wrapper<'b>,)>` + found trait `for<'a> FnOnce<(&'a Wrapper<'_>,)>` note: this closure does not fulfill the lifetime requirements --> $DIR/issue-71955.rs:48:24 | @@ -61,8 +61,8 @@ error[E0308]: mismatched types LL | foo(baz, "string", |s| s.0.len() == 5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other | - = note: expected trait `for<'r, 's> FnOnce<(&'r Wrapper<'s>,)>` - found trait `for<'r> FnOnce<(&'r Wrapper<'_>,)>` + = note: expected trait `for<'a, 'b> FnOnce<(&'a Wrapper<'b>,)>` + found trait `for<'a> FnOnce<(&'a Wrapper<'_>,)>` note: this closure does not fulfill the lifetime requirements --> $DIR/issue-71955.rs:48:24 | diff --git a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-85455.rs b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-85455.rs index 172bf218c..c10a0888a 100644 --- a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-85455.rs +++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-85455.rs @@ -6,8 +6,7 @@ trait SomeTrait<'a> { fn give_me_ice<T>() { callee::<fn(&()) -> <T as SomeTrait<'_>>::Associated>(); - //~^ ERROR the trait bound `for<'r> T: SomeTrait<'r>` is not satisfied [E0277] - //~| ERROR the trait bound `for<'r> T: SomeTrait<'r>` is not satisfied [E0277] + //~^ ERROR the trait bound `for<'a> T: SomeTrait<'a>` is not satisfied [E0277] } fn callee<T: Fn<(&'static (),)>>() { diff --git a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-85455.stderr b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-85455.stderr index ecca4b999..25a4f6088 100644 --- a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-85455.stderr +++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-85455.stderr @@ -1,25 +1,14 @@ -error[E0277]: the trait bound `for<'r> T: SomeTrait<'r>` is not satisfied +error[E0277]: the trait bound `for<'a> T: SomeTrait<'a>` is not satisfied --> $DIR/issue-85455.rs:8:5 | LL | callee::<fn(&()) -> <T as SomeTrait<'_>>::Associated>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'r> SomeTrait<'r>` is not implemented for `T` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> SomeTrait<'a>` is not implemented for `T` | help: consider restricting type parameter `T` | -LL | fn give_me_ice<T: for<'r> SomeTrait<'r>>() { +LL | fn give_me_ice<T: for<'a> SomeTrait<'a>>() { | +++++++++++++++++++++++ -error[E0277]: the trait bound `for<'r> T: SomeTrait<'r>` is not satisfied - --> $DIR/issue-85455.rs:8:14 - | -LL | callee::<fn(&()) -> <T as SomeTrait<'_>>::Associated>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'r> SomeTrait<'r>` is not implemented for `T` - | -help: consider restricting type parameter `T` - | -LL | fn give_me_ice<T: for<'r> SomeTrait<'r>>() { - | +++++++++++++++++++++++ - -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/higher-rank-trait-bounds/normalize-under-binder/issue-89118.stderr b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-89118.stderr index a6858154d..14fe1803b 100644 --- a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-89118.stderr +++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-89118.stderr @@ -4,7 +4,7 @@ error[E0277]: the trait bound `for<'a> &'a (): BufferMut` is not satisfied LL | C: StackContext, | ^^^^^^^^^^^^ the trait `for<'a> BufferMut` is not implemented for `&'a ()` | -note: required because of the requirements on the impl of `for<'a> BufferUdpStateContext<&'a ()>` for `Ctx<()>` +note: required for `Ctx<()>` to implement `for<'a> BufferUdpStateContext<&'a ()>` --> $DIR/issue-89118.rs:5:23 | LL | impl<B: BufferMut, C> BufferUdpStateContext<B> for C {} @@ -24,7 +24,7 @@ error[E0277]: the trait bound `for<'a> &'a (): BufferMut` is not satisfied LL | impl<C> EthernetWorker<C> {} | ^^^^^^^^^^^^^^^^^ the trait `for<'a> BufferMut` is not implemented for `&'a ()` | -note: required because of the requirements on the impl of `for<'a> BufferUdpStateContext<&'a ()>` for `Ctx<()>` +note: required for `Ctx<()>` to implement `for<'a> BufferUdpStateContext<&'a ()>` --> $DIR/issue-89118.rs:5:23 | LL | impl<B: BufferMut, C> BufferUdpStateContext<B> for C {} @@ -44,7 +44,7 @@ error[E0277]: the trait bound `for<'a> &'a (): BufferMut` is not satisfied LL | type Handler = Ctx<C::Dispatcher>; | ^^^^^^^^^^^^^^^^^^ the trait `for<'a> BufferMut` is not implemented for `&'a ()` | -note: required because of the requirements on the impl of `for<'a> BufferUdpStateContext<&'a ()>` for `Ctx<()>` +note: required for `Ctx<()>` to implement `for<'a> BufferUdpStateContext<&'a ()>` --> $DIR/issue-89118.rs:5:23 | LL | impl<B: BufferMut, C> BufferUdpStateContext<B> for C {} diff --git a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90612.rs b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90612.rs index e150ecfe9..effc32945 100644 --- a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90612.rs +++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90612.rs @@ -1,7 +1,5 @@ // check-pass -#![feature(generic_associated_types)] - use std::marker::PhantomData; trait Family: Sized { diff --git a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90638.rs b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90638.rs index 18b7f3834..628b5cba1 100644 --- a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90638.rs +++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90638.rs @@ -1,7 +1,5 @@ //check-pass -#![feature(generic_associated_types)] - trait Yokeable<'a>: 'static { type Output: 'a; } |