about summary refs log tree commit diff
path: root/src/test/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui')
-rw-r--r--src/test/ui/dropck/dropck-union.nll.stderr2
-rw-r--r--src/test/ui/generator/dropck.nll.stderr2
-rw-r--r--src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.migrate.stderr4
-rw-r--r--src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.nll.stderr4
-rw-r--r--src/test/ui/nll/enum-drop-access.rs51
-rw-r--r--src/test/ui/nll/enum-drop-access.stderr45
-rw-r--r--src/test/ui/span/borrowck-ref-into-rvalue.nll.stderr12
-rw-r--r--src/test/ui/span/dropck_arr_cycle_checked.nll.stderr4
-rw-r--r--src/test/ui/span/dropck_direct_cycle_with_drop.nll.stderr2
-rw-r--r--src/test/ui/span/dropck_vec_cycle_checked.nll.stderr4
-rw-r--r--src/test/ui/span/issue-29106.nll.stderr4
-rw-r--r--src/test/ui/span/issue28498-reject-ex1.nll.stderr1
-rw-r--r--src/test/ui/span/vec-must-not-hide-type-from-dropck.nll.stderr2
-rw-r--r--src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.nll.stderr2
14 files changed, 122 insertions, 17 deletions
diff --git a/src/test/ui/dropck/dropck-union.nll.stderr b/src/test/ui/dropck/dropck-union.nll.stderr
index 35d7ffc7879..ffb322b85dc 100644
--- a/src/test/ui/dropck/dropck-union.nll.stderr
+++ b/src/test/ui/dropck/dropck-union.nll.stderr
@@ -8,8 +8,6 @@ LL | }
    | |
    | `v` dropped here while still borrowed
    | borrow later used here, when `v` is dropped
-   |
-   = note: values in a scope are dropped in the opposite order they are defined
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/generator/dropck.nll.stderr b/src/test/ui/generator/dropck.nll.stderr
index b49bf817150..ef7e64ffd97 100644
--- a/src/test/ui/generator/dropck.nll.stderr
+++ b/src/test/ui/generator/dropck.nll.stderr
@@ -9,6 +9,8 @@ LL | }
    | |
    | `*cell` dropped here while still borrowed
    | borrow later used here, when `gen` is dropped
+   |
+   = note: values in a scope are dropped in the opposite order they are defined
 
 error[E0597]: `ref_` does not live long enough
   --> $DIR/dropck.rs:22:11
diff --git a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.migrate.stderr b/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.migrate.stderr
index 70d819f0f46..5c753817e35 100644
--- a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.migrate.stderr
+++ b/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.migrate.stderr
@@ -23,7 +23,7 @@ LL |     &mut *(*s).0 //[nll]~ ERROR borrow may still be in use when destructor
    |     ^^^^^^^^^^^^
 ...
 LL | }
-   | - here, drop of `*s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait
+   | - here, drop of `s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait
    |
 note: borrowed value must be valid for the lifetime 'a as defined on the function body at 72:20...
   --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:72:20
@@ -41,7 +41,7 @@ LL |     &mut *(**s).0 //[nll]~ ERROR borrow may still be in use when destructor
    |     ^^^^^^^^^^^^^
 ...
 LL | }
-   | - here, drop of `**s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait
+   | - here, drop of `s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait
    |
 note: borrowed value must be valid for the lifetime 'a as defined on the function body at 82:26...
   --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:82:26
diff --git a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.nll.stderr b/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.nll.stderr
index 72ec5affb18..79a7c0631f4 100644
--- a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.nll.stderr
+++ b/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.nll.stderr
@@ -20,7 +20,7 @@ LL |     &mut *(*s).0 //[nll]~ ERROR borrow may still be in use when destructor
    |     ^^^^^^^^^^^^
 ...
 LL | }
-   | - here, drop of `*s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait
+   | - here, drop of `s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait
    |
 note: borrowed value must be valid for the lifetime 'a as defined on the function body at 72:20...
   --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:72:20
@@ -35,7 +35,7 @@ LL |     &mut *(**s).0 //[nll]~ ERROR borrow may still be in use when destructor
    |     ^^^^^^^^^^^^^
 ...
 LL | }
-   | - here, drop of `**s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait
+   | - here, drop of `s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait
    |
 note: borrowed value must be valid for the lifetime 'a as defined on the function body at 82:26...
   --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:82:26
diff --git a/src/test/ui/nll/enum-drop-access.rs b/src/test/ui/nll/enum-drop-access.rs
new file mode 100644
index 00000000000..dc436d20fd8
--- /dev/null
+++ b/src/test/ui/nll/enum-drop-access.rs
@@ -0,0 +1,51 @@
+#![feature(nll)]
+
+enum DropOption<T> {
+    Some(T),
+    None,
+}
+
+impl<T> Drop for DropOption<T> {
+    fn drop(&mut self) {}
+}
+
+// Dropping opt could access the value behind the reference,
+fn drop_enum(opt: DropOption<&mut i32>) -> Option<&mut i32> {
+    match opt {
+        DropOption::Some(&mut ref mut r) => { //~ ERROR
+            Some(r)
+        },
+        DropOption::None => None,
+    }
+}
+
+fn optional_drop_enum(opt: Option<DropOption<&mut i32>>) -> Option<&mut i32> {
+    match opt {
+        Some(DropOption::Some(&mut ref mut r)) => { //~ ERROR
+            Some(r)
+        },
+        Some(DropOption::None) | None => None,
+    }
+}
+
+// Ok, dropping opt doesn't access the reference
+fn optional_tuple(opt: Option<(&mut i32, String)>) -> Option<&mut i32> {
+    match opt {
+        Some((&mut ref mut r, _)) => {
+            Some(r)
+        },
+        None => None,
+    }
+}
+
+// Ok, dropping res doesn't access the Ok case.
+fn different_variants(res: Result<&mut i32, String>) -> Option<&mut i32> {
+    match res {
+        Ok(&mut ref mut r) => {
+            Some(r)
+        },
+        Err(_) => None,
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/nll/enum-drop-access.stderr b/src/test/ui/nll/enum-drop-access.stderr
new file mode 100644
index 00000000000..57daf26596d
--- /dev/null
+++ b/src/test/ui/nll/enum-drop-access.stderr
@@ -0,0 +1,45 @@
+error[E0713]: borrow may still be in use when destructor runs
+  --> $DIR/enum-drop-access.rs:15:31
+   |
+LL |         DropOption::Some(&mut ref mut r) => { //~ ERROR
+   |                               ^^^^^^^^^
+...
+LL | }
+   | - here, drop of `opt` needs exclusive access to `*opt.0`, because the type `DropOption<&mut i32>` implements the `Drop` trait
+   |
+note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 13:1...
+  --> $DIR/enum-drop-access.rs:13:1
+   |
+LL | / fn drop_enum(opt: DropOption<&mut i32>) -> Option<&mut i32> {
+LL | |     match opt {
+LL | |         DropOption::Some(&mut ref mut r) => { //~ ERROR
+LL | |             Some(r)
+...  |
+LL | |     }
+LL | | }
+   | |_^
+
+error[E0713]: borrow may still be in use when destructor runs
+  --> $DIR/enum-drop-access.rs:24:36
+   |
+LL |         Some(DropOption::Some(&mut ref mut r)) => { //~ ERROR
+   |                                    ^^^^^^^^^
+...
+LL | }
+   | - here, drop of `opt` needs exclusive access to `*opt.0.0`, because the type `DropOption<&mut i32>` implements the `Drop` trait
+   |
+note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 22:1...
+  --> $DIR/enum-drop-access.rs:22:1
+   |
+LL | / fn optional_drop_enum(opt: Option<DropOption<&mut i32>>) -> Option<&mut i32> {
+LL | |     match opt {
+LL | |         Some(DropOption::Some(&mut ref mut r)) => { //~ ERROR
+LL | |             Some(r)
+...  |
+LL | |     }
+LL | | }
+   | |_^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0713`.
diff --git a/src/test/ui/span/borrowck-ref-into-rvalue.nll.stderr b/src/test/ui/span/borrowck-ref-into-rvalue.nll.stderr
index c94558f12bb..c565842c2c0 100644
--- a/src/test/ui/span/borrowck-ref-into-rvalue.nll.stderr
+++ b/src/test/ui/span/borrowck-ref-into-rvalue.nll.stderr
@@ -1,11 +1,11 @@
-error[E0713]: borrow may still be in use when destructor runs
-  --> $DIR/borrowck-ref-into-rvalue.rs:14:14
+error[E0597]: borrowed value does not live long enough
+  --> $DIR/borrowck-ref-into-rvalue.rs:13:11
    |
-LL |         Some(ref m) => {
-   |              ^^^^^
+LL |     match Some("Hello".to_string()) {
+   |           ^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
 ...
 LL |     }
-   |     - drop of temporary value occurs here
+   |     - temporary value only lives until here
 LL |     println!("{}", *msg);
    |                    ---- borrow later used here
    |
@@ -13,4 +13,4 @@ LL |     println!("{}", *msg);
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0713`.
+For more information about this error, try `rustc --explain E0597`.
diff --git a/src/test/ui/span/dropck_arr_cycle_checked.nll.stderr b/src/test/ui/span/dropck_arr_cycle_checked.nll.stderr
index 76a25fa661e..74db695e7e5 100644
--- a/src/test/ui/span/dropck_arr_cycle_checked.nll.stderr
+++ b/src/test/ui/span/dropck_arr_cycle_checked.nll.stderr
@@ -9,6 +9,8 @@ LL | }
    | |
    | `b2` dropped here while still borrowed
    | borrow later used here, when `b1` is dropped
+   |
+   = note: values in a scope are dropped in the opposite order they are defined
 
 error[E0597]: `b3` does not live long enough
   --> $DIR/dropck_arr_cycle_checked.rs:105:24
@@ -21,6 +23,8 @@ LL | }
    | |
    | `b3` dropped here while still borrowed
    | borrow later used here, when `b1` is dropped
+   |
+   = note: values in a scope are dropped in the opposite order they are defined
 
 error[E0597]: `b1` does not live long enough
   --> $DIR/dropck_arr_cycle_checked.rs:111:24
diff --git a/src/test/ui/span/dropck_direct_cycle_with_drop.nll.stderr b/src/test/ui/span/dropck_direct_cycle_with_drop.nll.stderr
index 2884b1818ba..baf3cef2ae8 100644
--- a/src/test/ui/span/dropck_direct_cycle_with_drop.nll.stderr
+++ b/src/test/ui/span/dropck_direct_cycle_with_drop.nll.stderr
@@ -23,8 +23,6 @@ LL | }
    | |
    | `d1` dropped here while still borrowed
    | borrow later used here, when `d1` is dropped
-   |
-   = note: values in a scope are dropped in the opposite order they are defined
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/span/dropck_vec_cycle_checked.nll.stderr b/src/test/ui/span/dropck_vec_cycle_checked.nll.stderr
index e6f43e0a71b..f7ff4e5169f 100644
--- a/src/test/ui/span/dropck_vec_cycle_checked.nll.stderr
+++ b/src/test/ui/span/dropck_vec_cycle_checked.nll.stderr
@@ -9,6 +9,8 @@ LL | }
    | |
    | `c2` dropped here while still borrowed
    | borrow later used here, when `c1` is dropped
+   |
+   = note: values in a scope are dropped in the opposite order they are defined
 
 error[E0597]: `c3` does not live long enough
   --> $DIR/dropck_vec_cycle_checked.rs:115:24
@@ -21,6 +23,8 @@ LL | }
    | |
    | `c3` dropped here while still borrowed
    | borrow later used here, when `c1` is dropped
+   |
+   = note: values in a scope are dropped in the opposite order they are defined
 
 error[E0597]: `c1` does not live long enough
   --> $DIR/dropck_vec_cycle_checked.rs:121:24
diff --git a/src/test/ui/span/issue-29106.nll.stderr b/src/test/ui/span/issue-29106.nll.stderr
index 2cf408d097b..a1451866e67 100644
--- a/src/test/ui/span/issue-29106.nll.stderr
+++ b/src/test/ui/span/issue-29106.nll.stderr
@@ -8,6 +8,8 @@ LL |     }
    |     |
    |     `x` dropped here while still borrowed
    |     borrow later used here, when `y` is dropped
+   |
+   = note: values in a scope are dropped in the opposite order they are defined
 
 error[E0597]: `x` does not live long enough
   --> $DIR/issue-29106.rs:33:25
@@ -19,6 +21,8 @@ LL |     }
    |     |
    |     `x` dropped here while still borrowed
    |     borrow later used here, when `y` is dropped
+   |
+   = note: values in a scope are dropped in the opposite order they are defined
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/span/issue28498-reject-ex1.nll.stderr b/src/test/ui/span/issue28498-reject-ex1.nll.stderr
index 1f72b78ebc7..0f6f6e381d8 100644
--- a/src/test/ui/span/issue28498-reject-ex1.nll.stderr
+++ b/src/test/ui/span/issue28498-reject-ex1.nll.stderr
@@ -11,7 +11,6 @@ LL | }
    | borrow later used here, when `foo` is dropped
    |
    = note: consider using a `let` binding to create a longer lived value
-   = note: values in a scope are dropped in the opposite order they are defined
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/span/vec-must-not-hide-type-from-dropck.nll.stderr b/src/test/ui/span/vec-must-not-hide-type-from-dropck.nll.stderr
index ee51304800d..292c007f512 100644
--- a/src/test/ui/span/vec-must-not-hide-type-from-dropck.nll.stderr
+++ b/src/test/ui/span/vec-must-not-hide-type-from-dropck.nll.stderr
@@ -9,6 +9,8 @@ LL | }
    | |
    | `c2` dropped here while still borrowed
    | borrow later used here, when `c1` is dropped
+   |
+   = note: values in a scope are dropped in the opposite order they are defined
 
 error[E0597]: `c1` does not live long enough
   --> $DIR/vec-must-not-hide-type-from-dropck.rs:129:24
diff --git a/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.nll.stderr b/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.nll.stderr
index 8cda1e60ba9..afd90237d16 100644
--- a/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.nll.stderr
+++ b/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.nll.stderr
@@ -11,8 +11,6 @@ LL | }
    | |
    | `factorial` dropped here while still borrowed
    | borrow later used here, when `factorial` is dropped
-   |
-   = note: values in a scope are dropped in the opposite order they are defined
 
 error[E0506]: cannot assign to `factorial` because it is borrowed
   --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:30:5