From 3da9dea49136929532a9dfb778d29991eef22af2 Mon Sep 17 00:00:00 2001 From: Hameer Abbasi Date: Sun, 3 Oct 2021 04:08:11 +0200 Subject: [PATCH 1/2] Add test for issue 89118. --- src/test/ui/traits/issue-89118.rs | 32 ++++++++++++++ src/test/ui/traits/issue-89118.stderr | 63 +++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 src/test/ui/traits/issue-89118.rs create mode 100644 src/test/ui/traits/issue-89118.stderr diff --git a/src/test/ui/traits/issue-89118.rs b/src/test/ui/traits/issue-89118.rs new file mode 100644 index 0000000000000..02b6bceae50e3 --- /dev/null +++ b/src/test/ui/traits/issue-89118.rs @@ -0,0 +1,32 @@ +trait BufferMut {} +struct Ctx(D); + +trait BufferUdpStateContext {} +impl BufferUdpStateContext for C {} + +trait StackContext +where + Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>, +{ + type Dispatcher; +} + +trait TimerContext { + type Handler; +} +impl TimerContext for C +where + C: StackContext, + //~^ ERROR: is not satisfied [E0277] +{ + type Handler = Ctx; + //~^ ERROR: is not satisfied [E0277] +} + +struct EthernetWorker(C) +where + Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>; +impl EthernetWorker {} +//~^ ERROR: is not satisfied [E0277] + +fn main() {} diff --git a/src/test/ui/traits/issue-89118.stderr b/src/test/ui/traits/issue-89118.stderr new file mode 100644 index 0000000000000..7f45fb83cef08 --- /dev/null +++ b/src/test/ui/traits/issue-89118.stderr @@ -0,0 +1,63 @@ +error[E0277]: the trait bound `for<'a> &'a (): BufferMut` is not satisfied + --> $DIR/issue-89118.rs:19:8 + | +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<()>` + --> $DIR/issue-89118.rs:5:23 + | +LL | impl BufferUdpStateContext for C {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ +note: required by a bound in `StackContext` + --> $DIR/issue-89118.rs:9:14 + | +LL | trait StackContext + | ------------ required by a bound in this +LL | where +LL | Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `StackContext` + +error[E0277]: the trait bound `for<'a> &'a (): BufferMut` is not satisfied + --> $DIR/issue-89118.rs:22:20 + | +LL | type Handler = Ctx; + | ^^^^^^^^^^^^^^^^^^ 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<()>` + --> $DIR/issue-89118.rs:5:23 + | +LL | impl BufferUdpStateContext for C {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ +note: required by a bound in `StackContext` + --> $DIR/issue-89118.rs:9:14 + | +LL | trait StackContext + | ------------ required by a bound in this +LL | where +LL | Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `StackContext` + +error[E0277]: the trait bound `for<'a> &'a (): BufferMut` is not satisfied + --> $DIR/issue-89118.rs:29:9 + | +LL | impl EthernetWorker {} + | ^^^^^^^^^^^^^^^^^ 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<()>` + --> $DIR/issue-89118.rs:5:23 + | +LL | impl BufferUdpStateContext for C {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ +note: required by a bound in `EthernetWorker` + --> $DIR/issue-89118.rs:28:14 + | +LL | struct EthernetWorker(C) + | -------------- required by a bound in this +LL | where +LL | Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `EthernetWorker` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`. From dc4043075e3a6c879218615933e88358abc2e01b Mon Sep 17 00:00:00 2001 From: Hameer Abbasi Date: Sun, 3 Oct 2021 05:24:45 +0200 Subject: [PATCH 2/2] Move test to correct path. --- .../normalize-under-binder}/issue-89118.rs | 6 +++--- .../normalize-under-binder}/issue-89118.stderr | 0 2 files changed, 3 insertions(+), 3 deletions(-) rename src/test/ui/{traits => higher-rank-trait-bounds/normalize-under-binder}/issue-89118.rs (80%) rename src/test/ui/{traits => higher-rank-trait-bounds/normalize-under-binder}/issue-89118.stderr (100%) diff --git a/src/test/ui/traits/issue-89118.rs b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-89118.rs similarity index 80% rename from src/test/ui/traits/issue-89118.rs rename to src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-89118.rs index 02b6bceae50e3..fffb54f86ca03 100644 --- a/src/test/ui/traits/issue-89118.rs +++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-89118.rs @@ -17,16 +17,16 @@ trait TimerContext { impl TimerContext for C where C: StackContext, - //~^ ERROR: is not satisfied [E0277] + //~^ ERROR: is not satisfied [E0277] { type Handler = Ctx; - //~^ ERROR: is not satisfied [E0277] + //~^ ERROR: is not satisfied [E0277] } struct EthernetWorker(C) where Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>; impl EthernetWorker {} -//~^ ERROR: is not satisfied [E0277] +//~^ ERROR: is not satisfied [E0277] fn main() {} diff --git a/src/test/ui/traits/issue-89118.stderr b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-89118.stderr similarity index 100% rename from src/test/ui/traits/issue-89118.stderr rename to src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-89118.stderr