about summary refs log tree commit diff
path: root/src/test/ui/hrtb
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2020-05-19 01:09:40 +0000
committerNiko Matsakis <niko@alum.mit.edu>2020-06-22 14:33:44 +0000
commitf2cf9944831f15b1940da85c8fb1b419dec9f074 (patch)
treed7f255b1b039ca14ef42a048ede6fc83da60275a /src/test/ui/hrtb
parent4199b3ae26007eb9c871b57f56057da586bbd1db (diff)
downloadrust-f2cf9944831f15b1940da85c8fb1b419dec9f074.tar.gz
rust-f2cf9944831f15b1940da85c8fb1b419dec9f074.zip
rewrite leak check to be based on universes
In the new leak check, instead of getting a list of placeholders to
track, we look for any placeholder that is part of a universe which
was created during the snapshot.

We are looking for the following error patterns:

* P1: P2, where P1 != P2
* P1: R, where R is in some universe that cannot name P1

This new leak check is more precise than before, in that it accepts
this patterns:

* R: P1, even if R cannot name P1, because R = 'static is a valid
sol'n
* R: P1, R: P2, as above

Note that this leak check, when running during subtyping, is less
efficient than before in some sense because it is going to check and
re-check all the universes created since the snapshot. We're going to
move when the leak check runs to try and correct that.
Diffstat (limited to 'src/test/ui/hrtb')
-rw-r--r--src/test/ui/hrtb/hrtb-exists-forall-trait-covariant.rs5
-rw-r--r--src/test/ui/hrtb/hrtb-exists-forall-trait-covariant.stderr18
2 files changed, 2 insertions, 21 deletions
diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-covariant.rs b/src/test/ui/hrtb/hrtb-exists-forall-trait-covariant.rs
index 95b57d6c5bb..f95496a6c3c 100644
--- a/src/test/ui/hrtb/hrtb-exists-forall-trait-covariant.rs
+++ b/src/test/ui/hrtb/hrtb-exists-forall-trait-covariant.rs
@@ -2,6 +2,8 @@
 //
 // In particular, we test this pattern in trait solving, where it is not connected
 // to any part of the source code.
+//
+// check-pass
 
 trait Trait<T> {}
 
@@ -30,9 +32,6 @@ fn main() {
     //         - `?b: ?a` -- solveable if `?b` is inferred to `'static`
     // - So the subtyping check succeeds, somewhat surprisingly.
     //   This is because we can use `'static`.
-    //
-    // NB. *However*, the reinstated leak-check gives an error here.
 
     foo::<()>();
-    //~^ ERROR not satisfied
 }
diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-covariant.stderr b/src/test/ui/hrtb/hrtb-exists-forall-trait-covariant.stderr
deleted file mode 100644
index 1e335f9ee96..00000000000
--- a/src/test/ui/hrtb/hrtb-exists-forall-trait-covariant.stderr
+++ /dev/null
@@ -1,18 +0,0 @@
-error[E0277]: the trait bound `(): Trait<for<'b> fn(fn(&'b u32))>` is not satisfied
-  --> $DIR/hrtb-exists-forall-trait-covariant.rs:36:11
-   |
-LL | fn foo<T>()
-   |    --- required by a bound in this
-LL | where
-LL |     T: Trait<for<'b> fn(fn(&'b u32))>,
-   |        ------------------------------ required by this bound in `foo`
-...
-LL |     foo::<()>();
-   |           ^^ the trait `Trait<for<'b> fn(fn(&'b u32))>` is not implemented for `()`
-   |
-   = help: the following implementations were found:
-             <() as Trait<fn(fn(&'a u32))>>
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0277`.