about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJack Huey <31162821+jackh726@users.noreply.github.com>2022-05-22 00:26:21 -0400
committerJack Huey <31162821+jackh726@users.noreply.github.com>2022-05-22 15:21:27 -0400
commitb16bd7c3e27c655d9aeb645743dbe7ce25d567f4 (patch)
tree5cb74027a873c03df06974521728538e5c0cc433
parent34a3154bd9ba92360966fd942df17eb11c7baca7 (diff)
downloadrust-b16bd7c3e27c655d9aeb645743dbe7ce25d567f4.tar.gz
rust-b16bd7c3e27c655d9aeb645743dbe7ce25d567f4.zip
Use revisions for NLL in traits
-rw-r--r--src/test/ui/traits/trait-upcasting/type-checking-test-3.base.stderr (renamed from src/test/ui/traits/trait-upcasting/type-checking-test-3.stderr)8
-rw-r--r--src/test/ui/traits/trait-upcasting/type-checking-test-3.nll.stderr18
-rw-r--r--src/test/ui/traits/trait-upcasting/type-checking-test-3.rs9
-rw-r--r--src/test/ui/traits/trait-upcasting/type-checking-test-4.base.stderr (renamed from src/test/ui/traits/trait-upcasting/type-checking-test-4.stderr)28
-rw-r--r--src/test/ui/traits/trait-upcasting/type-checking-test-4.nll.stderr52
-rw-r--r--src/test/ui/traits/trait-upcasting/type-checking-test-4.rs21
6 files changed, 110 insertions, 26 deletions
diff --git a/src/test/ui/traits/trait-upcasting/type-checking-test-3.stderr b/src/test/ui/traits/trait-upcasting/type-checking-test-3.base.stderr
index 641e5c97c10..e1831c5617f 100644
--- a/src/test/ui/traits/trait-upcasting/type-checking-test-3.stderr
+++ b/src/test/ui/traits/trait-upcasting/type-checking-test-3.base.stderr
@@ -1,5 +1,5 @@
 error[E0308]: mismatched types
-  --> $DIR/type-checking-test-3.rs:13:13
+  --> $DIR/type-checking-test-3.rs:16:13
    |
 LL |     let _ = x as &dyn Bar<'a>; // Error
    |             ^ lifetime mismatch
@@ -7,14 +7,14 @@ LL |     let _ = x as &dyn Bar<'a>; // Error
    = note: expected trait object `dyn Bar<'a>`
               found trait object `dyn Bar<'static>`
 note: the lifetime `'a` as defined here...
-  --> $DIR/type-checking-test-3.rs:12:16
+  --> $DIR/type-checking-test-3.rs:15:16
    |
 LL | fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) {
    |                ^^
    = note: ...does not necessarily outlive the static lifetime
 
 error[E0308]: mismatched types
-  --> $DIR/type-checking-test-3.rs:18:13
+  --> $DIR/type-checking-test-3.rs:22:13
    |
 LL |     let _ = x as &dyn Bar<'static>; // Error
    |             ^ lifetime mismatch
@@ -22,7 +22,7 @@ LL |     let _ = x as &dyn Bar<'static>; // Error
    = note: expected trait object `dyn Bar<'static>`
               found trait object `dyn Bar<'a>`
 note: the lifetime `'a` as defined here...
-  --> $DIR/type-checking-test-3.rs:17:16
+  --> $DIR/type-checking-test-3.rs:21:16
    |
 LL | fn test_wrong2<'a>(x: &dyn Foo<'a>) {
    |                ^^
diff --git a/src/test/ui/traits/trait-upcasting/type-checking-test-3.nll.stderr b/src/test/ui/traits/trait-upcasting/type-checking-test-3.nll.stderr
new file mode 100644
index 00000000000..983027d9b16
--- /dev/null
+++ b/src/test/ui/traits/trait-upcasting/type-checking-test-3.nll.stderr
@@ -0,0 +1,18 @@
+error: lifetime may not live long enough
+  --> $DIR/type-checking-test-3.rs:16:13
+   |
+LL | fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) {
+   |                -- lifetime `'a` defined here
+LL |     let _ = x as &dyn Bar<'a>; // Error
+   |             ^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
+
+error: lifetime may not live long enough
+  --> $DIR/type-checking-test-3.rs:22:13
+   |
+LL | fn test_wrong2<'a>(x: &dyn Foo<'a>) {
+   |                -- lifetime `'a` defined here
+LL |     let _ = x as &dyn Bar<'static>; // Error
+   |             ^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
+
+error: aborting due to 2 previous errors
+
diff --git a/src/test/ui/traits/trait-upcasting/type-checking-test-3.rs b/src/test/ui/traits/trait-upcasting/type-checking-test-3.rs
index 49c24e404dc..89e8821d34e 100644
--- a/src/test/ui/traits/trait-upcasting/type-checking-test-3.rs
+++ b/src/test/ui/traits/trait-upcasting/type-checking-test-3.rs
@@ -1,4 +1,7 @@
+// revisions: base nll
 // ignore-compare-mode-nll
+//[nll] compile-flags: -Z borrowck=mir
+
 #![feature(trait_upcasting)]
 #![allow(incomplete_features)]
 
@@ -11,12 +14,14 @@ fn test_correct(x: &dyn Foo<'static>) {
 
 fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) {
     let _ = x as &dyn Bar<'a>; // Error
-                               //~^ ERROR mismatched types
+    //[base]~^ ERROR mismatched types
+    //[nll]~^^ ERROR lifetime may not live long enough
 }
 
 fn test_wrong2<'a>(x: &dyn Foo<'a>) {
     let _ = x as &dyn Bar<'static>; // Error
-                                    //~^ ERROR mismatched types
+    //[base]~^ ERROR mismatched types
+    //[nll]~^^ ERROR lifetime may not live long enough
 }
 
 fn main() {}
diff --git a/src/test/ui/traits/trait-upcasting/type-checking-test-4.stderr b/src/test/ui/traits/trait-upcasting/type-checking-test-4.base.stderr
index d4bb9350b0b..c343698f27f 100644
--- a/src/test/ui/traits/trait-upcasting/type-checking-test-4.stderr
+++ b/src/test/ui/traits/trait-upcasting/type-checking-test-4.base.stderr
@@ -1,5 +1,5 @@
 error[E0308]: mismatched types
-  --> $DIR/type-checking-test-4.rs:17:13
+  --> $DIR/type-checking-test-4.rs:20:13
    |
 LL |     let _ = x as &dyn Bar<'static, 'a>; // Error
    |             ^ lifetime mismatch
@@ -7,14 +7,14 @@ LL |     let _ = x as &dyn Bar<'static, 'a>; // Error
    = note: expected trait object `dyn Bar<'static, 'a>`
               found trait object `dyn Bar<'static, 'static>`
 note: the lifetime `'a` as defined here...
-  --> $DIR/type-checking-test-4.rs:16:16
+  --> $DIR/type-checking-test-4.rs:19:16
    |
 LL | fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) {
    |                ^^
    = note: ...does not necessarily outlive the static lifetime
 
 error[E0308]: mismatched types
-  --> $DIR/type-checking-test-4.rs:22:13
+  --> $DIR/type-checking-test-4.rs:26:13
    |
 LL |     let _ = x as &dyn Bar<'a, 'static>; // Error
    |             ^ lifetime mismatch
@@ -22,14 +22,14 @@ LL |     let _ = x as &dyn Bar<'a, 'static>; // Error
    = note: expected trait object `dyn Bar<'a, 'static>`
               found trait object `dyn Bar<'static, 'static>`
 note: the lifetime `'a` as defined here...
-  --> $DIR/type-checking-test-4.rs:21:16
+  --> $DIR/type-checking-test-4.rs:25:16
    |
 LL | fn test_wrong2<'a>(x: &dyn Foo<'static>, y: &'a u32) {
    |                ^^
    = note: ...does not necessarily outlive the static lifetime
 
 error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
-  --> $DIR/type-checking-test-4.rs:27:27
+  --> $DIR/type-checking-test-4.rs:32:27
    |
 LL | fn test_wrong3<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
    |                       ------------ this data with lifetime `'a`...
@@ -42,12 +42,12 @@ LL |     y.get_b() // ERROR
    |     - ...is used here...
    |
 note: ...and is required to live as long as `'static` here
-  --> $DIR/type-checking-test-4.rs:29:5
+  --> $DIR/type-checking-test-4.rs:34:5
    |
 LL |     y.get_b() // ERROR
    |     ^^^^^^^^^
 note: `'static` lifetime requirement introduced by the return type
-  --> $DIR/type-checking-test-4.rs:26:48
+  --> $DIR/type-checking-test-4.rs:31:48
    |
 LL | fn test_wrong3<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
    |                                                ^^^^^^^ `'static` requirement introduced here
@@ -56,7 +56,7 @@ LL |     y.get_b() // ERROR
    |     --------- because of this returned expression
 
 error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
-  --> $DIR/type-checking-test-4.rs:33:5
+  --> $DIR/type-checking-test-4.rs:39:5
    |
 LL | fn test_wrong4<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
    |                       ------------ this data with lifetime `'a`...
@@ -64,7 +64,7 @@ LL |     <_ as Bar>::get_b(x) // ERROR
    |     ^^^^^^^^^^^^^^^^^ ...is used and required to live as long as `'static` here
    |
 note: `'static` lifetime requirement introduced by the return type
-  --> $DIR/type-checking-test-4.rs:32:48
+  --> $DIR/type-checking-test-4.rs:38:48
    |
 LL | fn test_wrong4<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
    |                                                ^^^^^^^ `'static` requirement introduced here
@@ -72,7 +72,7 @@ LL |     <_ as Bar>::get_b(x) // ERROR
    |     -------------------- because of this returned expression
 
 error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
-  --> $DIR/type-checking-test-4.rs:38:15
+  --> $DIR/type-checking-test-4.rs:45:15
    |
 LL | fn test_wrong5<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
    |                       ------------ this data with lifetime `'a`...
@@ -80,7 +80,7 @@ LL |     <_ as Bar<'_, '_>>::get_b(x) // ERROR
    |     ----------^^------------- ...is used and required to live as long as `'static` here
    |
 note: `'static` lifetime requirement introduced by the return type
-  --> $DIR/type-checking-test-4.rs:37:48
+  --> $DIR/type-checking-test-4.rs:44:48
    |
 LL | fn test_wrong5<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
    |                                                ^^^^^^^ `'static` requirement introduced here
@@ -88,7 +88,7 @@ LL |     <_ as Bar<'_, '_>>::get_b(x) // ERROR
    |     ---------------------------- because of this returned expression
 
 error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
-  --> $DIR/type-checking-test-4.rs:43:27
+  --> $DIR/type-checking-test-4.rs:51:27
    |
 LL | fn test_wrong6<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
    |                       ------------ this data with lifetime `'a`...
@@ -104,12 +104,12 @@ LL |     z.get_b() // ERROR
    |     - ...is used here...
    |
 note: ...and is required to live as long as `'static` here
-  --> $DIR/type-checking-test-4.rs:47:5
+  --> $DIR/type-checking-test-4.rs:55:5
    |
 LL |     z.get_b() // ERROR
    |     ^^^^^^^^^
 note: `'static` lifetime requirement introduced by the return type
-  --> $DIR/type-checking-test-4.rs:42:48
+  --> $DIR/type-checking-test-4.rs:50:48
    |
 LL | fn test_wrong6<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
    |                                                ^^^^^^^ `'static` requirement introduced here
diff --git a/src/test/ui/traits/trait-upcasting/type-checking-test-4.nll.stderr b/src/test/ui/traits/trait-upcasting/type-checking-test-4.nll.stderr
new file mode 100644
index 00000000000..9b69bab56ae
--- /dev/null
+++ b/src/test/ui/traits/trait-upcasting/type-checking-test-4.nll.stderr
@@ -0,0 +1,52 @@
+error: lifetime may not live long enough
+  --> $DIR/type-checking-test-4.rs:20:13
+   |
+LL | fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) {
+   |                -- lifetime `'a` defined here
+LL |     let _ = x as &dyn Bar<'static, 'a>; // Error
+   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
+
+error: lifetime may not live long enough
+  --> $DIR/type-checking-test-4.rs:26:13
+   |
+LL | fn test_wrong2<'a>(x: &dyn Foo<'static>, y: &'a u32) {
+   |                -- lifetime `'a` defined here
+LL |     let _ = x as &dyn Bar<'a, 'static>; // Error
+   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
+
+error: lifetime may not live long enough
+  --> $DIR/type-checking-test-4.rs:34:5
+   |
+LL | fn test_wrong3<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
+   |                -- lifetime `'a` defined here
+...
+LL |     y.get_b() // ERROR
+   |     ^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
+
+error: lifetime may not live long enough
+  --> $DIR/type-checking-test-4.rs:39:5
+   |
+LL | fn test_wrong4<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
+   |                -- lifetime `'a` defined here
+LL |     <_ as Bar>::get_b(x) // ERROR
+   |     ^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
+
+error: lifetime may not live long enough
+  --> $DIR/type-checking-test-4.rs:45:5
+   |
+LL | fn test_wrong5<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
+   |                -- lifetime `'a` defined here
+LL |     <_ as Bar<'_, '_>>::get_b(x) // ERROR
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
+
+error: lifetime may not live long enough
+  --> $DIR/type-checking-test-4.rs:55:5
+   |
+LL | fn test_wrong6<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
+   |                -- lifetime `'a` defined here
+...
+LL |     z.get_b() // ERROR
+   |     ^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
+
+error: aborting due to 6 previous errors
+
diff --git a/src/test/ui/traits/trait-upcasting/type-checking-test-4.rs b/src/test/ui/traits/trait-upcasting/type-checking-test-4.rs
index 95698fd1e1a..575d60a5e56 100644
--- a/src/test/ui/traits/trait-upcasting/type-checking-test-4.rs
+++ b/src/test/ui/traits/trait-upcasting/type-checking-test-4.rs
@@ -1,4 +1,7 @@
+// revisions: base nll
 // ignore-compare-mode-nll
+//[nll] compile-flags: -Z borrowck=mir
+
 #![feature(trait_upcasting)]
 #![allow(incomplete_features)]
 
@@ -15,36 +18,42 @@ fn test_correct(x: &dyn Foo<'static>) {
 
 fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) {
     let _ = x as &dyn Bar<'static, 'a>; // Error
-                                        //~^ ERROR mismatched types
+    //[base]~^ ERROR mismatched types
+    //[nll]~^^ ERROR lifetime may not live long enough
 }
 
 fn test_wrong2<'a>(x: &dyn Foo<'static>, y: &'a u32) {
     let _ = x as &dyn Bar<'a, 'static>; // Error
-                                        //~^ ERROR mismatched types
+    //[base]~^ ERROR mismatched types
+    //[nll]~^^ ERROR lifetime may not live long enough
 }
 
 fn test_wrong3<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
     let y = x as &dyn Bar<'_, '_>;
-    //~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
+    //[base]~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
     y.get_b() // ERROR
+    //[nll]~^ ERROR lifetime may not live long enough
 }
 
 fn test_wrong4<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
     <_ as Bar>::get_b(x) // ERROR
-    //~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
+    //[base]~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
+    //[nll]~^^ ERROR lifetime may not live long enough
 }
 
 fn test_wrong5<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
     <_ as Bar<'_, '_>>::get_b(x) // ERROR
-    //~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
+    //[base]~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
+    //[nll]~^^ ERROR lifetime may not live long enough
 }
 
 fn test_wrong6<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
     let y = x as &dyn Bar<'_, '_>;
-    //~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
+    //[base]~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
     y.get_b(); // ERROR
     let z = y;
     z.get_b() // ERROR
+    //[nll]~^ ERROR lifetime may not live long enough
 }
 
 fn main() {}