From 8f41de595d2969e383cb681bd65b36c061fc346a Mon Sep 17 00:00:00 2001 From: marmeladema Date: Fri, 23 Apr 2021 17:01:27 +0100 Subject: [PATCH 1/2] Add test for issue #83017 --- .../ui/associated-type-bounds/issue-83017.rs | 39 +++++++++++++++++++ .../associated-type-bounds/issue-83017.stderr | 27 +++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 src/test/ui/associated-type-bounds/issue-83017.rs create mode 100644 src/test/ui/associated-type-bounds/issue-83017.stderr diff --git a/src/test/ui/associated-type-bounds/issue-83017.rs b/src/test/ui/associated-type-bounds/issue-83017.rs new file mode 100644 index 00000000000..8f0a9ea3566 --- /dev/null +++ b/src/test/ui/associated-type-bounds/issue-83017.rs @@ -0,0 +1,39 @@ +#![feature(associated_type_bounds)] + +trait TraitA<'a> { + type AsA; +} + +trait TraitB<'a, 'b> { + type AsB; +} + +trait TraitC<'a, 'b, 'c> {} + +struct X; + +impl<'a, 'b, 'c> TraitC<'a, 'b, 'c> for X {} + +struct Y; + +impl<'a, 'b> TraitB<'a, 'b> for Y { + type AsB = X; +} + +struct Z; + +impl<'a> TraitA<'a> for Z { + type AsA = Y; +} + +fn foo() +where + for<'a> T: TraitA<'a, AsA: for<'b> TraitB<'a, 'b, AsB: for<'c> TraitC<'a, 'b, 'c>>>, +{ +} + +fn main() { + foo::(); + //~^ ERROR: the trait bound `for<'a, 'b> >::AsA: TraitB<'a, 'b>` is not satisfied + //~| ERROR: the trait bound `for<'a, 'b, 'c> <>::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 new file mode 100644 index 00000000000..4eb71fd0287 --- /dev/null +++ b/src/test/ui/associated-type-bounds/issue-83017.stderr @@ -0,0 +1,27 @@ +error[E0277]: the trait bound `for<'a, 'b> >::AsA: TraitB<'a, 'b>` is not satisfied + --> $DIR/issue-83017.rs:36:5 + | +LL | fn foo() + | --- 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` +... +LL | foo::(); + | ^^^^^^^^ the trait `for<'a, 'b> TraitB<'a, 'b>` is not implemented for `>::AsA` + +error[E0277]: the trait bound `for<'a, 'b, 'c> <>::AsA as TraitB<'a, 'b>>::AsB: TraitC<'a, 'b, 'c>` is not satisfied + --> $DIR/issue-83017.rs:36:5 + | +LL | fn foo() + | --- 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` +... +LL | foo::(); + | ^^^^^^^^ the trait `for<'a, 'b, 'c> TraitC<'a, 'b, 'c>` is not implemented for `<>::AsA as TraitB<'a, 'b>>::AsB` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. From 3b96dfe1d4f48b1cd04ebffbf7b24d26650c9974 Mon Sep 17 00:00:00 2001 From: marmeladema Date: Fri, 23 Apr 2021 17:58:43 +0100 Subject: [PATCH 2/2] Add test for issue #81193 --- src/test/ui/associated-type-bounds/issue-81193.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/test/ui/associated-type-bounds/issue-81193.rs diff --git a/src/test/ui/associated-type-bounds/issue-81193.rs b/src/test/ui/associated-type-bounds/issue-81193.rs new file mode 100644 index 00000000000..d2aa54ab951 --- /dev/null +++ b/src/test/ui/associated-type-bounds/issue-81193.rs @@ -0,0 +1,15 @@ +// check-pass + +#![feature(associated_type_bounds)] + +trait A<'a, 'b> {} + +trait B<'a, 'b, 'c> {} + +fn err<'u, 'a, F>() +where + for<'b> F: Iterator B<'a, 'b, 'c> + for<'c> A<'a, 'c>>, +{ +} + +fn main() {}