about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/test/ui/nll/user-annotations/patterns.rs17
-rw-r--r--src/test/ui/nll/user-annotations/patterns.stderr47
2 files changed, 50 insertions, 14 deletions
diff --git a/src/test/ui/nll/user-annotations/patterns.rs b/src/test/ui/nll/user-annotations/patterns.rs
index 643231b39b4..8c8e61cd6fb 100644
--- a/src/test/ui/nll/user-annotations/patterns.rs
+++ b/src/test/ui/nll/user-annotations/patterns.rs
@@ -41,6 +41,18 @@ fn struct_no_initializer() {
     y = &x; //~ ERROR
 }
 
+
+fn struct_no_initializer_must_normalize() {
+    trait Indirect { type Assoc; }
+    struct StaticU32;
+    impl Indirect for StaticU32 { type Assoc = &'static u32; }
+    struct Single2<T: Indirect> { value: <T as Indirect>::Assoc }
+
+    let x = 22;
+    let Single2 { value: mut _y }: Single2<StaticU32>;
+    _y = &x; //~ ERROR
+}
+
 fn variable_with_initializer() {
     let x = 22;
     let y: &'static u32 = &x; //~ ERROR
@@ -113,6 +125,11 @@ fn static_to_a_to_static_through_tuple<'a>(x: &'a u32) -> &'static u32 {
     y //~ ERROR
 }
 
+fn static_to_a_to_static_through_struct<'a>(_x: &'a u32) -> &'static u32 {
+    let Single { value: y }: Single<&'a u32> = Single { value: &22 };
+    y //~ ERROR
+}
+
 fn a_to_static_then_static<'a>(x: &'a u32) -> &'static u32 {
     let (y, _z): (&'static u32, u32) = (x, 44); //~ ERROR
     y
diff --git a/src/test/ui/nll/user-annotations/patterns.stderr b/src/test/ui/nll/user-annotations/patterns.stderr
index 58b708fcb1b..b0c554e6ca1 100644
--- a/src/test/ui/nll/user-annotations/patterns.stderr
+++ b/src/test/ui/nll/user-annotations/patterns.stderr
@@ -40,7 +40,17 @@ LL | }
    | - `x` dropped here while still borrowed
 
 error[E0597]: `x` does not live long enough
-  --> $DIR/patterns.rs:46:27
+  --> $DIR/patterns.rs:53:10
+   |
+LL |     let Single2 { value: mut _y }: Single2<StaticU32>;
+   |                                    ------------------ type annotation requires that `x` is borrowed for `'static`
+LL |     _y = &x; //~ ERROR
+   |          ^^ borrowed value does not live long enough
+LL | }
+   | - `x` dropped here while still borrowed
+
+error[E0597]: `x` does not live long enough
+  --> $DIR/patterns.rs:58:27
    |
 LL |     let y: &'static u32 = &x; //~ ERROR
    |            ------------   ^^ borrowed value does not live long enough
@@ -50,7 +60,7 @@ LL | }
    | - `x` dropped here while still borrowed
 
 error[E0597]: `x` does not live long enough
-  --> $DIR/patterns.rs:51:27
+  --> $DIR/patterns.rs:63:27
    |
 LL |     let _: &'static u32 = &x; //~ ERROR
    |            ------------   ^^ borrowed value does not live long enough
@@ -61,7 +71,7 @@ LL | }
    | - `x` dropped here while still borrowed
 
 error[E0716]: temporary value dropped while borrowed
-  --> $DIR/patterns.rs:53:41
+  --> $DIR/patterns.rs:65:41
    |
 LL |     let _: Vec<&'static String> = vec![&String::new()];
    |            --------------------         ^^^^^^^^^^^^^ - temporary value is freed at the end of this statement
@@ -70,7 +80,7 @@ LL |     let _: Vec<&'static String> = vec![&String::new()];
    |            type annotation requires that borrow lasts for `'static`
 
 error[E0716]: temporary value dropped while borrowed
-  --> $DIR/patterns.rs:56:52
+  --> $DIR/patterns.rs:68:52
    |
 LL |     let (_, a): (Vec<&'static String>, _) = (vec![&String::new()], 44);
    |                 -------------------------          ^^^^^^^^^^^^^      - temporary value is freed at the end of this statement
@@ -79,7 +89,7 @@ LL |     let (_, a): (Vec<&'static String>, _) = (vec![&String::new()], 44);
    |                 type annotation requires that borrow lasts for `'static`
 
 error[E0716]: temporary value dropped while borrowed
-  --> $DIR/patterns.rs:59:53
+  --> $DIR/patterns.rs:71:53
    |
 LL |     let (_a, b): (Vec<&'static String>, _) = (vec![&String::new()], 44);
    |                  -------------------------          ^^^^^^^^^^^^^      - temporary value is freed at the end of this statement
@@ -88,7 +98,7 @@ LL |     let (_a, b): (Vec<&'static String>, _) = (vec![&String::new()], 44);
    |                  type annotation requires that borrow lasts for `'static`
 
 error[E0597]: `x` does not live long enough
-  --> $DIR/patterns.rs:65:40
+  --> $DIR/patterns.rs:77:40
    |
 LL |     let (_, _): (&'static u32, u32) = (&x, 44); //~ ERROR
    |                 -------------------    ^^ borrowed value does not live long enough
@@ -98,7 +108,7 @@ LL | }
    | - `x` dropped here while still borrowed
 
 error[E0597]: `x` does not live long enough
-  --> $DIR/patterns.rs:70:40
+  --> $DIR/patterns.rs:82:40
    |
 LL |     let (y, _): (&'static u32, u32) = (&x, 44); //~ ERROR
    |                 -------------------    ^^ borrowed value does not live long enough
@@ -108,7 +118,7 @@ LL | }
    | - `x` dropped here while still borrowed
 
 error[E0597]: `x` does not live long enough
-  --> $DIR/patterns.rs:75:69
+  --> $DIR/patterns.rs:87:69
    |
 LL |     let Single { value: y }: Single<&'static u32> = Single { value: &x }; //~ ERROR
    |                              --------------------                   ^^ borrowed value does not live long enough
@@ -118,7 +128,7 @@ LL | }
    | - `x` dropped here while still borrowed
 
 error[E0597]: `x` does not live long enough
-  --> $DIR/patterns.rs:80:69
+  --> $DIR/patterns.rs:92:69
    |
 LL |     let Single { value: _ }: Single<&'static u32> = Single { value: &x }; //~ ERROR
    |                              --------------------                   ^^ borrowed value does not live long enough
@@ -128,7 +138,7 @@ LL | }
    | - `x` dropped here while still borrowed
 
 error[E0597]: `x` does not live long enough
-  --> $DIR/patterns.rs:88:17
+  --> $DIR/patterns.rs:100:17
    |
 LL |     let Double { value1: _, value2: _ }: Double<&'static u32> = Double {
    |                                          -------------------- type annotation requires that `x` is borrowed for `'static`
@@ -139,7 +149,7 @@ LL | }
    | - `x` dropped here while still borrowed
 
 error: unsatisfied lifetime constraints
-  --> $DIR/patterns.rs:101:5
+  --> $DIR/patterns.rs:113:5
    |
 LL | fn static_to_a_to_static_through_variable<'a>(x: &'a u32) -> &'static u32 {
    |                                           -- lifetime `'a` defined here
@@ -148,7 +158,7 @@ LL |     y //~ ERROR
    |     ^ returning this value requires that `'a` must outlive `'static`
 
 error: unsatisfied lifetime constraints
-  --> $DIR/patterns.rs:113:5
+  --> $DIR/patterns.rs:125:5
    |
 LL | fn static_to_a_to_static_through_tuple<'a>(x: &'a u32) -> &'static u32 {
    |                                        -- lifetime `'a` defined here
@@ -157,14 +167,23 @@ LL |     y //~ ERROR
    |     ^ returning this value requires that `'a` must outlive `'static`
 
 error: unsatisfied lifetime constraints
-  --> $DIR/patterns.rs:117:18
+  --> $DIR/patterns.rs:130:5
+   |
+LL | fn static_to_a_to_static_through_struct<'a>(_x: &'a u32) -> &'static u32 {
+   |                                         -- lifetime `'a` defined here
+LL |     let Single { value: y }: Single<&'a u32> = Single { value: &22 };
+LL |     y //~ ERROR
+   |     ^ returning this value requires that `'a` must outlive `'static`
+
+error: unsatisfied lifetime constraints
+  --> $DIR/patterns.rs:134:18
    |
 LL | fn a_to_static_then_static<'a>(x: &'a u32) -> &'static u32 {
    |                            -- lifetime `'a` defined here
 LL |     let (y, _z): (&'static u32, u32) = (x, 44); //~ ERROR
    |                  ^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
 
-error: aborting due to 17 previous errors
+error: aborting due to 19 previous errors
 
 Some errors occurred: E0597, E0716.
 For more information about an error, try `rustc --explain E0597`.