about summary refs log tree commit diff
path: root/src/test/ui/regions
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/regions
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/regions')
-rw-r--r--src/test/ui/regions/regions-fn-subtyping-return-static.rs13
-rw-r--r--src/test/ui/regions/regions-fn-subtyping-return-static.stderr12
2 files changed, 7 insertions, 18 deletions
diff --git a/src/test/ui/regions/regions-fn-subtyping-return-static.rs b/src/test/ui/regions/regions-fn-subtyping-return-static.rs
index fa2cc37d05b..de14d5ba82a 100644
--- a/src/test/ui/regions/regions-fn-subtyping-return-static.rs
+++ b/src/test/ui/regions/regions-fn-subtyping-return-static.rs
@@ -5,6 +5,8 @@
 // *ANY* lifetime and returns a reference with the 'static lifetime.
 // This can safely be considered to be an instance of `F` because all
 // lifetimes are sublifetimes of 'static.
+//
+// check-pass
 
 #![allow(dead_code)]
 #![allow(unused_variables)]
@@ -14,11 +16,11 @@ struct S;
 
 // Given 'cx, return 'cx
 type F = for<'cx> fn(&'cx S) -> &'cx S;
-fn want_F(f: F) { }
+fn want_F(f: F) {}
 
 // Given anything, return 'static
 type G = for<'cx> fn(&'cx S) -> &'static S;
-fn want_G(f: G) { }
+fn want_G(f: G) {}
 
 // Should meet both.
 fn foo(x: &S) -> &'static S {
@@ -26,7 +28,7 @@ fn foo(x: &S) -> &'static S {
 }
 
 // Should meet both.
-fn bar<'a,'b>(x: &'a S) -> &'b S {
+fn bar<'a, 'b>(x: &'a S) -> &'b S {
     panic!()
 }
 
@@ -38,10 +40,9 @@ fn baz(x: &S) -> &S {
 fn supply_F() {
     want_F(foo);
 
-    want_F(bar); //~ ERROR mismatched types
+    want_F(bar);
 
     want_F(baz);
 }
 
-pub fn main() {
-}
+pub fn main() {}
diff --git a/src/test/ui/regions/regions-fn-subtyping-return-static.stderr b/src/test/ui/regions/regions-fn-subtyping-return-static.stderr
deleted file mode 100644
index a8a7e97e6ac..00000000000
--- a/src/test/ui/regions/regions-fn-subtyping-return-static.stderr
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0308]: mismatched types
-  --> $DIR/regions-fn-subtyping-return-static.rs:41:12
-   |
-LL |     want_F(bar);
-   |            ^^^ expected concrete lifetime, found bound lifetime parameter 'cx
-   |
-   = note: expected fn pointer `for<'cx> fn(&'cx S) -> &'cx S`
-                 found fn item `for<'a> fn(&'a S) -> &S {bar::<'_>}`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.