From bc08b791bce1c5b31052da5dfda74302b6f61a99 Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Wed, 22 Jul 2020 22:43:18 +0100 Subject: Fix bugs in evaluating WellFormed predicates - List the nestsed obligations in an order that works with the single pass used by evaluation - Propagate recursion depth correctly --- src/test/ui/impl-trait/wf-eval-order.rs | 39 +++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/test/ui/impl-trait/wf-eval-order.rs (limited to 'src') diff --git a/src/test/ui/impl-trait/wf-eval-order.rs b/src/test/ui/impl-trait/wf-eval-order.rs new file mode 100644 index 00000000000..c7d6bb87096 --- /dev/null +++ b/src/test/ui/impl-trait/wf-eval-order.rs @@ -0,0 +1,39 @@ +// Check that we handle evaluating `wf` predicates correctly. + +// check-pass + +struct X(T) +where + T::V: Clone; + +fn hide(t: T) -> impl Sized { + t +} + +trait A { + type U; +} + +impl A for T { + type U = T; +} + +trait B { + type V; +} + +impl, T> B for S { + type V = T; +} + +fn main() { + // Evaluating `typeof(x): Sized` requires + // + // - `wf(typeof(x))` because we use a projection candidate. + // - `::V: Clone` because that's a bound on the trait. + // - `::V` normalizes to `_#1` where `::U == _#1` + // + // This all works if we evaluate `::U == _#1` before + // `::V`, but we previously had the opposite order. + let x = hide(X(0)); +} -- cgit 1.4.1-3-g733a5