]> git.lizzy.rs Git - rust.git/commitdiff
Update tests
authorMatthew Jasper <mjjasper1@gmail.com>
Wed, 20 May 2020 17:58:41 +0000 (18:58 +0100)
committerMatthew Jasper <mjjasper1@gmail.com>
Fri, 22 May 2020 17:03:08 +0000 (18:03 +0100)
51 files changed:
src/test/ui/borrowck/issue-45983.migrate.stderr [deleted file]
src/test/ui/borrowck/issue-45983.nll.stderr [deleted file]
src/test/ui/borrowck/issue-45983.rs
src/test/ui/borrowck/issue-45983.stderr [new file with mode: 0644]
src/test/ui/borrowck/issue-7573.nll.stderr [deleted file]
src/test/ui/borrowck/issue-7573.rs
src/test/ui/borrowck/issue-7573.stderr
src/test/ui/borrowck/regions-escape-bound-fn-2.nll.stderr [deleted file]
src/test/ui/borrowck/regions-escape-bound-fn-2.rs
src/test/ui/borrowck/regions-escape-bound-fn-2.stderr
src/test/ui/borrowck/regions-escape-bound-fn.nll.stderr [deleted file]
src/test/ui/borrowck/regions-escape-bound-fn.rs
src/test/ui/borrowck/regions-escape-bound-fn.stderr
src/test/ui/borrowck/regions-escape-unboxed-closure.nll.stderr [deleted file]
src/test/ui/borrowck/regions-escape-unboxed-closure.rs
src/test/ui/borrowck/regions-escape-unboxed-closure.stderr
src/test/ui/c-variadic/variadic-ffi-4.nll.stderr [deleted file]
src/test/ui/c-variadic/variadic-ffi-4.rs
src/test/ui/c-variadic/variadic-ffi-4.stderr
src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.nll.stderr [new file with mode: 0644]
src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.rs [new file with mode: 0644]
src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.stderr [new file with mode: 0644]
src/test/ui/closures/closure-expected-type/expect-region-supply-region.nll.stderr [deleted file]
src/test/ui/closures/closure-expected-type/expect-region-supply-region.rs
src/test/ui/closures/closure-expected-type/expect-region-supply-region.stderr
src/test/ui/error-codes/E0490.nll.stderr [new file with mode: 0644]
src/test/ui/error-codes/E0490.rs [new file with mode: 0644]
src/test/ui/error-codes/E0490.stderr [new file with mode: 0644]
src/test/ui/error-codes/E0621-does-not-trigger-for-closures.nll.stderr [deleted file]
src/test/ui/error-codes/E0621-does-not-trigger-for-closures.rs
src/test/ui/error-codes/E0621-does-not-trigger-for-closures.stderr
src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unrelated.stderr
src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unsuited.stderr
src/test/ui/regions/regions-close-object-into-object-5.rs
src/test/ui/regions/regions-close-object-into-object-5.stderr
src/test/ui/regions/regions-close-over-type-parameter-1.nll.stderr
src/test/ui/regions/regions-close-over-type-parameter-1.rs
src/test/ui/regions/regions-close-over-type-parameter-1.stderr
src/test/ui/regions/regions-escape-method.nll.stderr [deleted file]
src/test/ui/regions/regions-escape-method.rs
src/test/ui/regions/regions-escape-method.stderr
src/test/ui/regions/regions-escape-via-trait-or-not.nll.stderr [deleted file]
src/test/ui/regions/regions-escape-via-trait-or-not.rs
src/test/ui/regions/regions-escape-via-trait-or-not.stderr
src/test/ui/regions/regions-infer-call-3.nll.stderr [deleted file]
src/test/ui/regions/regions-infer-call-3.rs
src/test/ui/regions/regions-infer-call-3.stderr
src/test/ui/regions/regions-return-ref-to-upvar-issue-17403.nll.stderr [deleted file]
src/test/ui/regions/regions-return-ref-to-upvar-issue-17403.rs
src/test/ui/regions/regions-return-ref-to-upvar-issue-17403.stderr
src/test/ui/symbol-names/impl1.rs

diff --git a/src/test/ui/borrowck/issue-45983.migrate.stderr b/src/test/ui/borrowck/issue-45983.migrate.stderr
deleted file mode 100644 (file)
index c1564cf..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-error: borrowed data cannot be stored outside of its closure
-  --> $DIR/issue-45983.rs:20:27
-   |
-LL |     let x = None;
-   |         - borrowed data cannot be stored into here...
-LL |     give_any(|y| x = Some(y));
-   |              ---          ^ cannot be stored outside of its closure
-   |              |
-   |              ...because it cannot outlive this closure
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/borrowck/issue-45983.nll.stderr b/src/test/ui/borrowck/issue-45983.nll.stderr
deleted file mode 100644 (file)
index 51bb4de..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-error[E0521]: borrowed data escapes outside of closure
-  --> $DIR/issue-45983.rs:20:18
-   |
-LL |     let x = None;
-   |         - `x` declared here, outside of the closure body
-LL |     give_any(|y| x = Some(y));
-   |               -  ^^^^^^^^^^^ `y` escapes the closure body here
-   |               |
-   |               `y` is a reference that is only valid in the closure body
-
-error[E0594]: cannot assign to `x`, as it is not declared as mutable
-  --> $DIR/issue-45983.rs:20:18
-   |
-LL |     let x = None;
-   |         - help: consider changing this to be mutable: `mut x`
-LL |     give_any(|y| x = Some(y));
-   |                  ^^^^^^^^^^^ cannot assign
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0594`.
index 3cd282077424b711c18bac66a3c96ecce90f836b..6784f6f86a010a31eb7590be12834b58624b9117 100644 (file)
@@ -1,24 +1,12 @@
 // As documented in Issue #45983, this test is evaluating the quality
 // of our diagnostics on erroneous code using higher-ranked closures.
 
-// revisions: migrate nll
-
-// Since we are testing nll (and migration) explicitly as a separate
-// revisions, don't worry about the --compare-mode=nll on this test.
-
-// ignore-compare-mode-nll
-// ignore-compare-mode-polonius
-
-//[nll]compile-flags: -Z borrowck=mir
-
 fn give_any<F: for<'r> FnOnce(&'r ())>(f: F) {
     f(&());
 }
 
 fn main() {
-    let x = None;
+    let mut x = None;
     give_any(|y| x = Some(y));
-    //[migrate]~^ ERROR borrowed data cannot be stored outside of its closure
-    //[nll]~^^ ERROR borrowed data escapes outside of closure
-    //[nll]~| ERROR cannot assign to `x`, as it is not declared as mutable
+    //~^ ERROR borrowed data escapes outside of closure
 }
diff --git a/src/test/ui/borrowck/issue-45983.stderr b/src/test/ui/borrowck/issue-45983.stderr
new file mode 100644 (file)
index 0000000..efd414a
--- /dev/null
@@ -0,0 +1,12 @@
+error[E0521]: borrowed data escapes outside of closure
+  --> $DIR/issue-45983.rs:10:18
+   |
+LL |     let mut x = None;
+   |         ----- `x` declared here, outside of the closure body
+LL |     give_any(|y| x = Some(y));
+   |               -  ^^^^^^^^^^^ `y` escapes the closure body here
+   |               |
+   |               `y` is a reference that is only valid in the closure body
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/borrowck/issue-7573.nll.stderr b/src/test/ui/borrowck/issue-7573.nll.stderr
deleted file mode 100644 (file)
index 20afecf..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-error[E0521]: borrowed data escapes outside of closure
-  --> $DIR/issue-7573.rs:21:9
-   |
-LL |     let mut lines_to_use: Vec<&CrateId> = Vec::new();
-   |         ---------------- `lines_to_use` declared here, outside of the closure body
-LL |
-LL |     let push_id = |installed_id: &CrateId| {
-   |                    ------------ `installed_id` is a reference that is only valid in the closure body
-...
-LL |         lines_to_use.push(installed_id);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `installed_id` escapes the closure body here
-
-error: aborting due to previous error
-
index 20a6a5c92f149b0419b144d8a3b8a3101f03692b..7c07411533ff072b63e3743b284c85941039a1e1 100644 (file)
@@ -1,36 +1,34 @@
 pub struct CrateId {
     local_path: String,
-    junk: String
+    junk: String,
 }
 
 impl CrateId {
     fn new(s: &str) -> CrateId {
-        CrateId {
-            local_path: s.to_string(),
-            junk: "wutevs".to_string()
-        }
+        CrateId { local_path: s.to_string(), junk: "wutevs".to_string() }
     }
 }
 
 pub fn remove_package_from_database() {
     let mut lines_to_use: Vec<&CrateId> = Vec::new();
-        //~^ NOTE cannot infer an appropriate lifetime
+    //~^ NOTE `lines_to_use` declared here, outside of the closure body
     let push_id = |installed_id: &CrateId| {
-        //~^ NOTE borrowed data cannot outlive this closure
-        //~| NOTE ...so that variable is valid at time of its declaration
+        //~^ NOTE `installed_id` is a reference that is only valid in the closure body
         lines_to_use.push(installed_id);
-        //~^ ERROR borrowed data cannot be stored outside of its closure
-        //~| NOTE cannot be stored outside of its closure
+        //~^ ERROR borrowed data escapes outside of closure
+        //~| NOTE `installed_id` escapes the closure body here
     };
     list_database(push_id);
 
     for l in &lines_to_use {
         println!("{}", l.local_path);
     }
-
 }
 
-pub fn list_database<F>(mut f: F) where F: FnMut(&CrateId) {
+pub fn list_database<F>(mut f: F)
+where
+    F: FnMut(&CrateId),
+{
     let stuff = ["foo", "bar"];
 
     for l in &stuff {
index 32b3ef72d8bda611f94bed13e278400efc920a91..815419db833e55362d82b5b739086e7d384a24f3 100644 (file)
@@ -1,16 +1,14 @@
-error: borrowed data cannot be stored outside of its closure
-  --> $DIR/issue-7573.rs:21:27
+error[E0521]: borrowed data escapes outside of closure
+  --> $DIR/issue-7573.rs:17:9
    |
 LL |     let mut lines_to_use: Vec<&CrateId> = Vec::new();
-   |                               - cannot infer an appropriate lifetime...
+   |         ---------------- `lines_to_use` declared here, outside of the closure body
 LL |
 LL |     let push_id = |installed_id: &CrateId| {
-   |         -------   ------------------------ borrowed data cannot outlive this closure
-   |         |
-   |         ...so that variable is valid at time of its declaration
-...
+   |                    ------------ `installed_id` is a reference that is only valid in the closure body
+LL |
 LL |         lines_to_use.push(installed_id);
-   |                           ^^^^^^^^^^^^ cannot be stored outside of its closure
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `installed_id` escapes the closure body here
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/borrowck/regions-escape-bound-fn-2.nll.stderr b/src/test/ui/borrowck/regions-escape-bound-fn-2.nll.stderr
deleted file mode 100644 (file)
index 68a0fe0..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0521]: borrowed data escapes outside of closure
-  --> $DIR/regions-escape-bound-fn-2.rs:8:18
-   |
-LL |     let mut x = None;
-   |         ----- `x` declared here, outside of the closure body
-LL |     with_int(|y| x = Some(y));
-   |               -  ^^^^^^^^^^^ `y` escapes the closure body here
-   |               |
-   |               `y` is a reference that is only valid in the closure body
-
-error: aborting due to previous error
-
index cb423032b46106736774935175811a175e6455b9..0e98d98cf87b3f1c36bb297ae8683d2059fca4ed 100644 (file)
@@ -1,4 +1,7 @@
-fn with_int<F>(f: F) where F: FnOnce(&isize) {
+fn with_int<F>(f: F)
+where
+    F: FnOnce(&isize),
+{
     let x = 3;
     f(&x);
 }
@@ -6,5 +9,5 @@ fn with_int<F>(f: F) where F: FnOnce(&isize) {
 fn main() {
     let mut x = None;
     with_int(|y| x = Some(y));
-    //~^ ERROR borrowed data cannot be stored outside of its closure
+    //~^ ERROR borrowed data escapes outside of closure
 }
index 4b37edafa1273694dfd96679ecc6c2f738a5764d..1dc60bb15545223e37ca33a8d3991c976f5679eb 100644 (file)
@@ -1,12 +1,12 @@
-error: borrowed data cannot be stored outside of its closure
-  --> $DIR/regions-escape-bound-fn-2.rs:8:27
+error[E0521]: borrowed data escapes outside of closure
+  --> $DIR/regions-escape-bound-fn-2.rs:11:18
    |
 LL |     let mut x = None;
-   |         ----- borrowed data cannot be stored into here...
+   |         ----- `x` declared here, outside of the closure body
 LL |     with_int(|y| x = Some(y));
-   |              ---          ^ cannot be stored outside of its closure
-   |              |
-   |              ...because it cannot outlive this closure
+   |               -  ^^^^^^^^^^^ `y` escapes the closure body here
+   |               |
+   |               `y` is a reference that is only valid in the closure body
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/borrowck/regions-escape-bound-fn.nll.stderr b/src/test/ui/borrowck/regions-escape-bound-fn.nll.stderr
deleted file mode 100644 (file)
index d304de9..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0521]: borrowed data escapes outside of closure
-  --> $DIR/regions-escape-bound-fn.rs:8:18
-   |
-LL |     let mut x: Option<&isize> = None;
-   |         ----- `x` declared here, outside of the closure body
-LL |     with_int(|y| x = Some(y));
-   |               -  ^^^^^^^^^^^ `y` escapes the closure body here
-   |               |
-   |               `y` is a reference that is only valid in the closure body
-
-error: aborting due to previous error
-
index 772df3e6c58229e1c6b95383d508f1cee0649625..f896ae7bdada25cf22c3b6b8cc387b5b135c5188 100644 (file)
@@ -1,4 +1,7 @@
-fn with_int<F>(f: F) where F: FnOnce(&isize) {
+fn with_int<F>(f: F)
+where
+    F: FnOnce(&isize),
+{
     let x = 3;
     f(&x);
 }
@@ -6,5 +9,5 @@ fn with_int<F>(f: F) where F: FnOnce(&isize) {
 fn main() {
     let mut x: Option<&isize> = None;
     with_int(|y| x = Some(y));
-    //~^ ERROR borrowed data cannot be stored outside of its closure
+    //~^ ERROR borrowed data escapes outside of closure
 }
index 4973d5306f9593d4158b3f4617f241a199182e9d..5c548ec2876a33cd760d3094b0db063593a9c305 100644 (file)
@@ -1,12 +1,12 @@
-error: borrowed data cannot be stored outside of its closure
-  --> $DIR/regions-escape-bound-fn.rs:8:27
+error[E0521]: borrowed data escapes outside of closure
+  --> $DIR/regions-escape-bound-fn.rs:11:18
    |
 LL |     let mut x: Option<&isize> = None;
-   |         ----- borrowed data cannot be stored into here...
+   |         ----- `x` declared here, outside of the closure body
 LL |     with_int(|y| x = Some(y));
-   |              ---          ^ cannot be stored outside of its closure
-   |              |
-   |              ...because it cannot outlive this closure
+   |               -  ^^^^^^^^^^^ `y` escapes the closure body here
+   |               |
+   |               `y` is a reference that is only valid in the closure body
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/borrowck/regions-escape-unboxed-closure.nll.stderr b/src/test/ui/borrowck/regions-escape-unboxed-closure.nll.stderr
deleted file mode 100644 (file)
index d993130..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0521]: borrowed data escapes outside of closure
-  --> $DIR/regions-escape-unboxed-closure.rs:6:23
-   |
-LL |     let mut x: Option<&isize> = None;
-   |         ----- `x` declared here, outside of the closure body
-LL |     with_int(&mut |y| x = Some(y));
-   |                    -  ^^^^^^^^^^^ `y` escapes the closure body here
-   |                    |
-   |                    `y` is a reference that is only valid in the closure body
-
-error: aborting due to previous error
-
index d8bef927fd722f4a853cdcb73c182cdaabeb5159..f01e47122d1e1cf6678b1d58d266f718b8085961 100644 (file)
@@ -1,8 +1,7 @@
-fn with_int(f: &mut dyn FnMut(&isize)) {
-}
+fn with_int(f: &mut dyn FnMut(&isize)) {}
 
 fn main() {
     let mut x: Option<&isize> = None;
     with_int(&mut |y| x = Some(y));
-    //~^ ERROR borrowed data cannot be stored outside of its closure
+    //~^ ERROR borrowed data escapes outside of closure
 }
index 047e290acae14c41d3439546e8b6c44c244459a1..f2a49e70d27164bfa61740c803eeebed4cd02e45 100644 (file)
@@ -1,12 +1,12 @@
-error: borrowed data cannot be stored outside of its closure
-  --> $DIR/regions-escape-unboxed-closure.rs:6:32
+error[E0521]: borrowed data escapes outside of closure
+  --> $DIR/regions-escape-unboxed-closure.rs:5:23
    |
 LL |     let mut x: Option<&isize> = None;
-   |         ----- borrowed data cannot be stored into here...
+   |         ----- `x` declared here, outside of the closure body
 LL |     with_int(&mut |y| x = Some(y));
-   |                   ---          ^ cannot be stored outside of its closure
-   |                   |
-   |                   ...because it cannot outlive this closure
+   |                    -  ^^^^^^^^^^^ `y` escapes the closure body here
+   |                    |
+   |                    `y` is a reference that is only valid in the closure body
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/c-variadic/variadic-ffi-4.nll.stderr b/src/test/ui/c-variadic/variadic-ffi-4.nll.stderr
deleted file mode 100644 (file)
index 89107e7..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-error: lifetime may not live long enough
-  --> $DIR/variadic-ffi-4.rs:8:5
-   |
-LL | pub unsafe extern "C" fn no_escape0<'f>(_: usize, ap: ...) -> VaListImpl<'f> {
-   |                                     --            -- has type `core::ffi::VaListImpl<'1>`
-   |                                     |
-   |                                     lifetime `'f` defined here
-LL |     ap
-   |     ^^ function was supposed to return data with lifetime `'1` but it is returning data with lifetime `'f`
-
-error: lifetime may not live long enough
-  --> $DIR/variadic-ffi-4.rs:8:5
-   |
-LL | pub unsafe extern "C" fn no_escape0<'f>(_: usize, ap: ...) -> VaListImpl<'f> {
-   |                                     --            -- has type `core::ffi::VaListImpl<'1>`
-   |                                     |
-   |                                     lifetime `'f` defined here
-LL |     ap
-   |     ^^ returning this value requires that `'1` must outlive `'f`
-
-error: lifetime may not live long enough
-  --> $DIR/variadic-ffi-4.rs:12:5
-   |
-LL | pub unsafe extern "C" fn no_escape1(_: usize, ap: ...) -> VaListImpl<'static> {
-   |                                               -- has type `core::ffi::VaListImpl<'1>`
-LL |     ap
-   |     ^^ returning this value requires that `'1` must outlive `'static`
-
-error: lifetime may not live long enough
-  --> $DIR/variadic-ffi-4.rs:16:33
-   |
-LL |     let _ = ap.with_copy(|ap| { ap });
-   |                           ---   ^^ returning this value requires that `'1` must outlive `'2`
-   |                           | |
-   |                           | return type of closure is core::ffi::VaList<'2, '_>
-   |                           has type `core::ffi::VaList<'1, '_>`
-
-error: lifetime may not live long enough
-  --> $DIR/variadic-ffi-4.rs:20:5
-   |
-LL | pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
-   |                                               -------                   ------- has type `core::ffi::VaListImpl<'2>`
-   |                                               |
-   |                                               has type `&mut core::ffi::VaListImpl<'1>`
-LL |     *ap0 = ap1;
-   |     ^^^^ assignment requires that `'1` must outlive `'2`
-
-error: lifetime may not live long enough
-  --> $DIR/variadic-ffi-4.rs:20:5
-   |
-LL | pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
-   |                                               -------                   ------- has type `core::ffi::VaListImpl<'2>`
-   |                                               |
-   |                                               has type `&mut core::ffi::VaListImpl<'1>`
-LL |     *ap0 = ap1;
-   |     ^^^^ assignment requires that `'2` must outlive `'1`
-
-error: lifetime may not live long enough
-  --> $DIR/variadic-ffi-4.rs:24:5
-   |
-LL | pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ...) {
-   |                                               ---                   ------- has type `core::ffi::VaListImpl<'2>`
-   |                                               |
-   |                                               has type `&mut core::ffi::VaListImpl<'1>`
-LL |     ap0 = &mut ap1;
-   |     ^^^^^^^^^^^^^^ assignment requires that `'1` must outlive `'2`
-
-error: lifetime may not live long enough
-  --> $DIR/variadic-ffi-4.rs:24:5
-   |
-LL | pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ...) {
-   |                                               ---                   ------- has type `core::ffi::VaListImpl<'2>`
-   |                                               |
-   |                                               has type `&mut core::ffi::VaListImpl<'1>`
-LL |     ap0 = &mut ap1;
-   |     ^^^^^^^^^^^^^^ assignment requires that `'2` must outlive `'1`
-
-error[E0384]: cannot assign to immutable argument `ap0`
-  --> $DIR/variadic-ffi-4.rs:24:5
-   |
-LL | pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ...) {
-   |                                               --- help: make this binding mutable: `mut ap0`
-LL |     ap0 = &mut ap1;
-   |     ^^^^^^^^^^^^^^ cannot assign to immutable argument
-
-error[E0597]: `ap1` does not live long enough
-  --> $DIR/variadic-ffi-4.rs:24:11
-   |
-LL | pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ...) {
-   |                                                    - let's call the lifetime of this reference `'3`
-LL |     ap0 = &mut ap1;
-   |     ------^^^^^^^^
-   |     |     |
-   |     |     borrowed value does not live long enough
-   |     assignment requires that `ap1` is borrowed for `'3`
-...
-LL | }
-   | - `ap1` dropped here while still borrowed
-
-error: lifetime may not live long enough
-  --> $DIR/variadic-ffi-4.rs:31:12
-   |
-LL | pub unsafe extern "C" fn no_escape5(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
-   |                                               -------                   ------- has type `core::ffi::VaListImpl<'2>`
-   |                                               |
-   |                                               has type `&mut core::ffi::VaListImpl<'1>`
-LL |     *ap0 = ap1.clone();
-   |            ^^^^^^^^^^^ argument requires that `'1` must outlive `'2`
-
-error: lifetime may not live long enough
-  --> $DIR/variadic-ffi-4.rs:31:12
-   |
-LL | pub unsafe extern "C" fn no_escape5(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
-   |                                               -------                   ------- has type `core::ffi::VaListImpl<'2>`
-   |                                               |
-   |                                               has type `&mut core::ffi::VaListImpl<'1>`
-LL |     *ap0 = ap1.clone();
-   |            ^^^^^^^^^^^ argument requires that `'2` must outlive `'1`
-
-error: aborting due to 12 previous errors
-
-Some errors have detailed explanations: E0384, E0597.
-For more information about an error, try `rustc --explain E0384`.
index a4d658cef16303141a16d677c864d0cad5354827..80640379422590b8e6391c1406d048c6b87326d1 100644 (file)
@@ -1,32 +1,38 @@
-#![crate_type="lib"]
+#![crate_type = "lib"]
 #![no_std]
 #![feature(c_variadic)]
 
 use core::ffi::{VaList, VaListImpl};
 
 pub unsafe extern "C" fn no_escape0<'f>(_: usize, ap: ...) -> VaListImpl<'f> {
-    ap //~ ERROR: mismatched types
+    ap
+    //~^ ERROR: lifetime may not live long enough
+    //~| ERROR: lifetime may not live long enough
 }
 
 pub unsafe extern "C" fn no_escape1(_: usize, ap: ...) -> VaListImpl<'static> {
-    ap //~ ERROR: mismatched types
+    ap //~ ERROR: lifetime may not live long enough
 }
 
 pub unsafe extern "C" fn no_escape2(_: usize, ap: ...) {
-    let _ = ap.with_copy(|ap| { ap }); //~ ERROR: cannot infer an appropriate lifetime
+    let _ = ap.with_copy(|ap| ap); //~ ERROR: lifetime may not live long enough
 }
 
 pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
-    *ap0 = ap1; //~ ERROR: mismatched types
+    *ap0 = ap1;
+    //~^ ERROR: lifetime may not live long enough
+    //~| ERROR: lifetime may not live long enough
 }
 
-pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ...) {
+pub unsafe extern "C" fn no_escape4(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
     ap0 = &mut ap1;
-    //~^ ERROR: a value of type `core::ffi::VaListImpl<'_>` is borrowed for too long
-    //~| ERROR: mismatched types
-    //~| ERROR: cannot infer an appropriate lifetime
+    //~^ ERROR: `ap1` does not live long enough
+    //~| ERROR: lifetime may not live long enough
+    //~| ERROR: lifetime may not live long enough
 }
 
 pub unsafe extern "C" fn no_escape5(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
-    *ap0 = ap1.clone(); //~ ERROR: mismatched types
+    *ap0 = ap1.clone();
+    //~^ ERROR: lifetime may not live long enough
+    //~| ERROR: lifetime may not live long enough
 }
index cd4cd8b198de8b4ee3ad4d8dc4864397589260d6..65623501569e1099957f6ab89dece3c21b925b39 100644 (file)
-error[E0308]: mismatched types
+error: lifetime may not live long enough
   --> $DIR/variadic-ffi-4.rs:8:5
    |
+LL | pub unsafe extern "C" fn no_escape0<'f>(_: usize, ap: ...) -> VaListImpl<'f> {
+   |                                     --            -- has type `core::ffi::VaListImpl<'1>`
+   |                                     |
+   |                                     lifetime `'f` defined here
 LL |     ap
-   |     ^^ lifetime mismatch
-   |
-   = note: expected struct `core::ffi::VaListImpl<'f>`
-              found struct `core::ffi::VaListImpl<'_>`
-note: the scope of call-site for function at 7:78...
-  --> $DIR/variadic-ffi-4.rs:7:78
-   |
-LL |   pub unsafe extern "C" fn no_escape0<'f>(_: usize, ap: ...) -> VaListImpl<'f> {
-   |  ______________________________________________________________________________^
-LL | |     ap
-LL | | }
-   | |_^
-note: ...does not necessarily outlive the lifetime `'f` as defined on the function body at 7:37
-  --> $DIR/variadic-ffi-4.rs:7:37
+   |     ^^ function was supposed to return data with lifetime `'1` but it is returning data with lifetime `'f`
+
+error: lifetime may not live long enough
+  --> $DIR/variadic-ffi-4.rs:8:5
    |
 LL | pub unsafe extern "C" fn no_escape0<'f>(_: usize, ap: ...) -> VaListImpl<'f> {
-   |                                     ^^
+   |                                     --            -- has type `core::ffi::VaListImpl<'1>`
+   |                                     |
+   |                                     lifetime `'f` defined here
+LL |     ap
+   |     ^^ returning this value requires that `'1` must outlive `'f`
 
-error[E0308]: mismatched types
-  --> $DIR/variadic-ffi-4.rs:12:5
+error: lifetime may not live long enough
+  --> $DIR/variadic-ffi-4.rs:14:5
    |
+LL | pub unsafe extern "C" fn no_escape1(_: usize, ap: ...) -> VaListImpl<'static> {
+   |                                               -- has type `core::ffi::VaListImpl<'1>`
 LL |     ap
-   |     ^^ lifetime mismatch
-   |
-   = note: expected struct `core::ffi::VaListImpl<'static>`
-              found struct `core::ffi::VaListImpl<'_>`
-note: the scope of call-site for function at 11:79...
-  --> $DIR/variadic-ffi-4.rs:11:79
-   |
-LL |   pub unsafe extern "C" fn no_escape1(_: usize, ap: ...) -> VaListImpl<'static> {
-   |  _______________________________________________________________________________^
-LL | |     ap
-LL | | }
-   | |_^
-   = note: ...does not necessarily outlive the static lifetime
+   |     ^^ returning this value requires that `'1` must outlive `'static`
 
-error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
-  --> $DIR/variadic-ffi-4.rs:16:33
-   |
-LL |     let _ = ap.with_copy(|ap| { ap });
-   |                                 ^^
-   |
-note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 16:26...
-  --> $DIR/variadic-ffi-4.rs:16:26
-   |
-LL |     let _ = ap.with_copy(|ap| { ap });
-   |                          ^^^^^^^^^^^
-note: ...so that the expression is assignable
-  --> $DIR/variadic-ffi-4.rs:16:33
-   |
-LL |     let _ = ap.with_copy(|ap| { ap });
-   |                                 ^^
-   = note: expected  `core::ffi::VaList<'_, '_>`
-              found  `core::ffi::VaList<'_, '_>`
-note: but, the lifetime must be valid for the method call at 16:13...
-  --> $DIR/variadic-ffi-4.rs:16:13
-   |
-LL |     let _ = ap.with_copy(|ap| { ap });
-   |             ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...so type `core::ffi::VaList<'_, '_>` of expression is valid during the expression
-  --> $DIR/variadic-ffi-4.rs:16:13
-   |
-LL |     let _ = ap.with_copy(|ap| { ap });
-   |             ^^^^^^^^^^^^^^^^^^^^^^^^^
+error: lifetime may not live long enough
+  --> $DIR/variadic-ffi-4.rs:18:31
+   |
+LL |     let _ = ap.with_copy(|ap| ap);
+   |                           --- ^^ returning this value requires that `'1` must outlive `'2`
+   |                           | |
+   |                           | return type of closure is core::ffi::VaList<'2, '_>
+   |                           has type `core::ffi::VaList<'1, '_>`
 
-error[E0308]: mismatched types
-  --> $DIR/variadic-ffi-4.rs:20:12
+error: lifetime may not live long enough
+  --> $DIR/variadic-ffi-4.rs:22:5
    |
+LL | pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
+   |                                               -------                   ------- has type `core::ffi::VaListImpl<'2>`
+   |                                               |
+   |                                               has type `&mut core::ffi::VaListImpl<'1>`
 LL |     *ap0 = ap1;
-   |            ^^^ lifetime mismatch
-   |
-   = note: expected struct `core::ffi::VaListImpl<'_>`
-              found struct `core::ffi::VaListImpl<'_>`
-note: the scope of call-site for function at 19:87...
-  --> $DIR/variadic-ffi-4.rs:19:87
-   |
-LL |   pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
-   |  _______________________________________________________________________________________^
-LL | |     *ap0 = ap1;
-LL | | }
-   | |_^
-note: ...does not necessarily outlive the anonymous lifetime #2 defined on the function body at 19:1
-  --> $DIR/variadic-ffi-4.rs:19:1
-   |
-LL | / pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
-LL | |     *ap0 = ap1;
-LL | | }
-   | |_^
+   |     ^^^^ assignment requires that `'1` must outlive `'2`
 
-error[E0490]: a value of type `core::ffi::VaListImpl<'_>` is borrowed for too long
-  --> $DIR/variadic-ffi-4.rs:24:11
+error: lifetime may not live long enough
+  --> $DIR/variadic-ffi-4.rs:22:5
    |
-LL |     ap0 = &mut ap1;
-   |           ^^^^^^^^
-   |
-note: the type is valid for the anonymous lifetime #1 defined on the function body at 23:1
-  --> $DIR/variadic-ffi-4.rs:23:1
-   |
-LL | / pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ...) {
-LL | |     ap0 = &mut ap1;
-LL | |
-LL | |
-LL | |
-LL | | }
-   | |_^
-note: but the borrow lasts for the scope of call-site for function at 23:83
-  --> $DIR/variadic-ffi-4.rs:23:83
-   |
-LL |   pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ...) {
-   |  ___________________________________________________________________________________^
-LL | |     ap0 = &mut ap1;
-LL | |
-LL | |
-LL | |
-LL | | }
-   | |_^
+LL | pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
+   |                                               -------                   ------- has type `core::ffi::VaListImpl<'2>`
+   |                                               |
+   |                                               has type `&mut core::ffi::VaListImpl<'1>`
+LL |     *ap0 = ap1;
+   |     ^^^^ assignment requires that `'2` must outlive `'1`
 
-error[E0308]: mismatched types
-  --> $DIR/variadic-ffi-4.rs:24:11
+error: lifetime may not live long enough
+  --> $DIR/variadic-ffi-4.rs:28:5
    |
+LL | pub unsafe extern "C" fn no_escape4(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
+   |                                               -------                   ------- has type `core::ffi::VaListImpl<'2>`
+   |                                               |
+   |                                               has type `&mut core::ffi::VaListImpl<'1>`
 LL |     ap0 = &mut ap1;
-   |           ^^^^^^^^ lifetime mismatch
-   |
-   = note: expected mutable reference `&mut core::ffi::VaListImpl<'_>`
-              found mutable reference `&mut core::ffi::VaListImpl<'_>`
-note: the scope of call-site for function at 23:83...
-  --> $DIR/variadic-ffi-4.rs:23:83
-   |
-LL |   pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ...) {
-   |  ___________________________________________________________________________________^
-LL | |     ap0 = &mut ap1;
-LL | |
-LL | |
-LL | |
-LL | | }
-   | |_^
-note: ...does not necessarily outlive the anonymous lifetime #2 defined on the function body at 23:1
-  --> $DIR/variadic-ffi-4.rs:23:1
-   |
-LL | / pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ...) {
-LL | |     ap0 = &mut ap1;
-LL | |
-LL | |
-LL | |
-LL | | }
-   | |_^
+   |     ^^^^^^^^^^^^^^ assignment requires that `'1` must outlive `'2`
 
-error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements
-  --> $DIR/variadic-ffi-4.rs:24:11
+error: lifetime may not live long enough
+  --> $DIR/variadic-ffi-4.rs:28:5
    |
+LL | pub unsafe extern "C" fn no_escape4(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
+   |                                               -------                   ------- has type `core::ffi::VaListImpl<'2>`
+   |                                               |
+   |                                               has type `&mut core::ffi::VaListImpl<'1>`
 LL |     ap0 = &mut ap1;
-   |           ^^^^^^^^
-   |
-note: first, the lifetime cannot outlive the scope of call-site for function at 23:83...
-  --> $DIR/variadic-ffi-4.rs:23:83
-   |
-LL |   pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ...) {
-   |  ___________________________________________________________________________________^
-LL | |     ap0 = &mut ap1;
-LL | |
-LL | |
-LL | |
-LL | | }
-   | |_^
-note: ...so that the type `core::ffi::VaListImpl<'_>` is not borrowed for too long
-  --> $DIR/variadic-ffi-4.rs:24:11
-   |
-LL |     ap0 = &mut ap1;
-   |           ^^^^^^^^
-note: but, the lifetime must be valid for the anonymous lifetime #1 defined on the function body at 23:1...
-  --> $DIR/variadic-ffi-4.rs:23:1
-   |
-LL | / pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ...) {
-LL | |     ap0 = &mut ap1;
-LL | |
-LL | |
-LL | |
-LL | | }
-   | |_^
-note: ...so that reference does not outlive borrowed content
-  --> $DIR/variadic-ffi-4.rs:24:11
+   |     ^^^^^^^^^^^^^^ assignment requires that `'2` must outlive `'1`
+
+error[E0597]: `ap1` does not live long enough
+  --> $DIR/variadic-ffi-4.rs:28:11
    |
+LL | pub unsafe extern "C" fn no_escape4(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
+   |                                                        - let's call the lifetime of this reference `'3`
 LL |     ap0 = &mut ap1;
-   |           ^^^^^^^^
+   |     ------^^^^^^^^
+   |     |     |
+   |     |     borrowed value does not live long enough
+   |     assignment requires that `ap1` is borrowed for `'3`
+...
+LL | }
+   | - `ap1` dropped here while still borrowed
 
-error[E0308]: mismatched types
-  --> $DIR/variadic-ffi-4.rs:31:12
+error: lifetime may not live long enough
+  --> $DIR/variadic-ffi-4.rs:35:12
    |
+LL | pub unsafe extern "C" fn no_escape5(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
+   |                                               -------                   ------- has type `core::ffi::VaListImpl<'2>`
+   |                                               |
+   |                                               has type `&mut core::ffi::VaListImpl<'1>`
 LL |     *ap0 = ap1.clone();
-   |            ^^^^^^^^^^^ lifetime mismatch
-   |
-   = note: expected struct `core::ffi::VaListImpl<'_>`
-              found struct `core::ffi::VaListImpl<'_>`
-note: the scope of call-site for function at 30:87...
-  --> $DIR/variadic-ffi-4.rs:30:87
-   |
-LL |   pub unsafe extern "C" fn no_escape5(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
-   |  _______________________________________________________________________________________^
-LL | |     *ap0 = ap1.clone();
-LL | | }
-   | |_^
-note: ...does not necessarily outlive the anonymous lifetime #2 defined on the function body at 30:1
-  --> $DIR/variadic-ffi-4.rs:30:1
+   |            ^^^^^^^^^^^ argument requires that `'1` must outlive `'2`
+
+error: lifetime may not live long enough
+  --> $DIR/variadic-ffi-4.rs:35:12
    |
-LL | / pub unsafe extern "C" fn no_escape5(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
-LL | |     *ap0 = ap1.clone();
-LL | | }
-   | |_^
+LL | pub unsafe extern "C" fn no_escape5(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
+   |                                               -------                   ------- has type `core::ffi::VaListImpl<'2>`
+   |                                               |
+   |                                               has type `&mut core::ffi::VaListImpl<'1>`
+LL |     *ap0 = ap1.clone();
+   |            ^^^^^^^^^^^ argument requires that `'2` must outlive `'1`
 
-error: aborting due to 8 previous errors
+error: aborting due to 11 previous errors
 
-Some errors have detailed explanations: E0308, E0495.
-For more information about an error, try `rustc --explain E0308`.
+For more information about this error, try `rustc --explain E0597`.
diff --git a/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.nll.stderr b/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.nll.stderr
new file mode 100644 (file)
index 0000000..52bca8d
--- /dev/null
@@ -0,0 +1,24 @@
+error: lifetime may not live long enough
+  --> $DIR/expect-region-supply-region-2.rs:14:30
+   |
+LL | fn expect_bound_supply_named<'x>() {
+   |                              -- lifetime `'x` defined here
+...
+LL |     closure_expecting_bound(|x: &'x u32| {
+   |                              ^  - let's call the lifetime of this reference `'1`
+   |                              |
+   |                              requires that `'1` must outlive `'x`
+
+error: lifetime may not live long enough
+  --> $DIR/expect-region-supply-region-2.rs:14:30
+   |
+LL | fn expect_bound_supply_named<'x>() {
+   |                              -- lifetime `'x` defined here
+...
+LL |     closure_expecting_bound(|x: &'x u32| {
+   |                              ^ requires that `'x` must outlive `'static`
+   |
+   = help: consider replacing `'x` with `'static`
+
+error: aborting due to 2 previous errors
+
diff --git a/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.rs b/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.rs
new file mode 100644 (file)
index 0000000..7405b1a
--- /dev/null
@@ -0,0 +1,24 @@
+#![allow(warnings)]
+
+fn closure_expecting_bound<F>(_: F)
+where
+    F: FnOnce(&u32),
+{
+}
+
+fn expect_bound_supply_named<'x>() {
+    let mut f: Option<&u32> = None;
+
+    // Here we give a type annotation that `x` should be free. We get
+    // an error because of that.
+    closure_expecting_bound(|x: &'x u32| {
+        //~^ ERROR mismatched types
+        //~| ERROR mismatched types
+
+        // Borrowck doesn't get a chance to run, but if it did it should error
+        // here.
+        f = Some(x);
+    });
+}
+
+fn main() {}
diff --git a/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.stderr b/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.stderr
new file mode 100644 (file)
index 0000000..7f52790
--- /dev/null
@@ -0,0 +1,55 @@
+error[E0308]: mismatched types
+  --> $DIR/expect-region-supply-region-2.rs:14:33
+   |
+LL |     closure_expecting_bound(|x: &'x u32| {
+   |                                 ^^^^^^^ lifetime mismatch
+   |
+   = note: expected reference `&u32`
+              found reference `&'x u32`
+note: the anonymous lifetime #2 defined on the body at 14:29...
+  --> $DIR/expect-region-supply-region-2.rs:14:29
+   |
+LL |       closure_expecting_bound(|x: &'x u32| {
+   |  _____________________________^
+LL | |
+LL | |
+LL | |
+...  |
+LL | |         f = Some(x);
+LL | |     });
+   | |_____^
+note: ...does not necessarily outlive the lifetime `'x` as defined on the function body at 9:30
+  --> $DIR/expect-region-supply-region-2.rs:9:30
+   |
+LL | fn expect_bound_supply_named<'x>() {
+   |                              ^^
+
+error[E0308]: mismatched types
+  --> $DIR/expect-region-supply-region-2.rs:14:33
+   |
+LL |     closure_expecting_bound(|x: &'x u32| {
+   |                                 ^^^^^^^ lifetime mismatch
+   |
+   = note: expected reference `&u32`
+              found reference `&'x u32`
+note: the lifetime `'x` as defined on the function body at 9:30...
+  --> $DIR/expect-region-supply-region-2.rs:9:30
+   |
+LL | fn expect_bound_supply_named<'x>() {
+   |                              ^^
+note: ...does not necessarily outlive the anonymous lifetime #2 defined on the body at 14:29
+  --> $DIR/expect-region-supply-region-2.rs:14:29
+   |
+LL |       closure_expecting_bound(|x: &'x u32| {
+   |  _____________________________^
+LL | |
+LL | |
+LL | |
+...  |
+LL | |         f = Some(x);
+LL | |     });
+   | |_____^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/closures/closure-expected-type/expect-region-supply-region.nll.stderr b/src/test/ui/closures/closure-expected-type/expect-region-supply-region.nll.stderr
deleted file mode 100644 (file)
index d7d716e..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-error[E0521]: borrowed data escapes outside of closure
-  --> $DIR/expect-region-supply-region.rs:18:9
-   |
-LL |     let mut f: Option<&u32> = None;
-   |         ----- `f` declared here, outside of the closure body
-LL |     closure_expecting_bound(|x| {
-   |                              - `x` is a reference that is only valid in the closure body
-LL |         f = Some(x);
-   |         ^^^^^^^^^^^ `x` escapes the closure body here
-
-error[E0521]: borrowed data escapes outside of closure
-  --> $DIR/expect-region-supply-region.rs:28:9
-   |
-LL |     let mut f: Option<&u32> = None;
-   |         ----- `f` declared here, outside of the closure body
-LL |     closure_expecting_bound(|x: &u32| {
-   |                              - `x` is a reference that is only valid in the closure body
-LL |         f = Some(x);
-   |         ^^^^^^^^^^^ `x` escapes the closure body here
-
-error: lifetime may not live long enough
-  --> $DIR/expect-region-supply-region.rs:37:30
-   |
-LL | fn expect_bound_supply_named<'x>() {
-   |                              -- lifetime `'x` defined here
-...
-LL |     closure_expecting_bound(|x: &'x u32| {
-   |                              ^  - let's call the lifetime of this reference `'1`
-   |                              |
-   |                              requires that `'1` must outlive `'x`
-
-error: lifetime may not live long enough
-  --> $DIR/expect-region-supply-region.rs:37:30
-   |
-LL | fn expect_bound_supply_named<'x>() {
-   |                              -- lifetime `'x` defined here
-...
-LL |     closure_expecting_bound(|x: &'x u32| {
-   |                              ^ requires that `'x` must outlive `'static`
-   |
-   = help: consider replacing `'x` with `'static`
-
-error: aborting due to 4 previous errors
-
index 28a6ab77a915ee489481ad2461b01b989e2e4f19..55c6aa795c26a8ad0d9e99c466b1d6fc5e4323ff 100644 (file)
@@ -1,12 +1,14 @@
 #![allow(warnings)]
 
 fn closure_expecting_bound<F>(_: F)
-    where F: FnOnce(&u32)
+where
+    F: FnOnce(&u32),
 {
 }
 
 fn closure_expecting_free<'a, F>(_: F)
-    where F: FnOnce(&'a u32)
+where
+    F: FnOnce(&'a u32),
 {
 }
 
@@ -15,7 +17,7 @@ fn expect_bound_supply_nothing() {
     // it to escape into `f`:
     let mut f: Option<&u32> = None;
     closure_expecting_bound(|x| {
-        f = Some(x); //~ ERROR borrowed data cannot be stored outside of its closure
+        f = Some(x); //~ ERROR borrowed data escapes outside of closure
     });
 }
 
@@ -25,22 +27,7 @@ fn expect_bound_supply_bound() {
     // closure:
     let mut f: Option<&u32> = None;
     closure_expecting_bound(|x: &u32| {
-        f = Some(x); //~ ERROR borrowed data cannot be stored outside of its closure
-    });
-}
-
-fn expect_bound_supply_named<'x>() {
-    let mut f: Option<&u32> = None;
-
-    // Here we give a type annotation that `x` should be free. We get
-    // an error because of that.
-    closure_expecting_bound(|x: &'x u32| {
-        //~^ ERROR mismatched types
-        //~| ERROR mismatched types
-
-        // And we still cannot let `x` escape into `f`.
-        f = Some(x);
-        //~^ ERROR borrowed data cannot be stored outside of its closure
+        f = Some(x); //~ ERROR borrowed data escapes outside of closure
     });
 }
 
@@ -67,4 +54,4 @@ fn expect_free_supply_named<'x>() {
     closure_expecting_free(|x: &'x u32| f = Some(x)); // OK
 }
 
-fn main() { }
+fn main() {}
index eb860f9aef243d1d7e5ecf8382e8b027a4ebbab0..213071abfffc3252ea1009728c72078c59cb68ea 100644 (file)
@@ -1,87 +1,22 @@
-error: borrowed data cannot be stored outside of its closure
-  --> $DIR/expect-region-supply-region.rs:18:18
+error[E0521]: borrowed data escapes outside of closure
+  --> $DIR/expect-region-supply-region.rs:20:9
    |
 LL |     let mut f: Option<&u32> = None;
-   |         ----- borrowed data cannot be stored into here...
+   |         ----- `f` declared here, outside of the closure body
 LL |     closure_expecting_bound(|x| {
-   |                             --- ...because it cannot outlive this closure
+   |                              - `x` is a reference that is only valid in the closure body
 LL |         f = Some(x);
-   |                  ^ cannot be stored outside of its closure
+   |         ^^^^^^^^^^^ `x` escapes the closure body here
 
-error: borrowed data cannot be stored outside of its closure
-  --> $DIR/expect-region-supply-region.rs:28:18
+error[E0521]: borrowed data escapes outside of closure
+  --> $DIR/expect-region-supply-region.rs:30:9
    |
 LL |     let mut f: Option<&u32> = None;
-   |         ----- borrowed data cannot be stored into here...
+   |         ----- `f` declared here, outside of the closure body
 LL |     closure_expecting_bound(|x: &u32| {
-   |                             --------- ...because it cannot outlive this closure
+   |                              - `x` is a reference that is only valid in the closure body
 LL |         f = Some(x);
-   |                  ^ cannot be stored outside of its closure
+   |         ^^^^^^^^^^^ `x` escapes the closure body here
 
-error[E0308]: mismatched types
-  --> $DIR/expect-region-supply-region.rs:37:33
-   |
-LL |     closure_expecting_bound(|x: &'x u32| {
-   |                                 ^^^^^^^ lifetime mismatch
-   |
-   = note: expected reference `&u32`
-              found reference `&'x u32`
-note: the anonymous lifetime #2 defined on the body at 37:29...
-  --> $DIR/expect-region-supply-region.rs:37:29
-   |
-LL |       closure_expecting_bound(|x: &'x u32| {
-   |  _____________________________^
-LL | |
-LL | |
-LL | |
-...  |
-LL | |
-LL | |     });
-   | |_____^
-note: ...does not necessarily outlive the lifetime `'x` as defined on the function body at 32:30
-  --> $DIR/expect-region-supply-region.rs:32:30
-   |
-LL | fn expect_bound_supply_named<'x>() {
-   |                              ^^
-
-error[E0308]: mismatched types
-  --> $DIR/expect-region-supply-region.rs:37:33
-   |
-LL |     closure_expecting_bound(|x: &'x u32| {
-   |                                 ^^^^^^^ lifetime mismatch
-   |
-   = note: expected reference `&u32`
-              found reference `&'x u32`
-note: the lifetime `'x` as defined on the function body at 32:30...
-  --> $DIR/expect-region-supply-region.rs:32:30
-   |
-LL | fn expect_bound_supply_named<'x>() {
-   |                              ^^
-note: ...does not necessarily outlive the anonymous lifetime #2 defined on the body at 37:29
-  --> $DIR/expect-region-supply-region.rs:37:29
-   |
-LL |       closure_expecting_bound(|x: &'x u32| {
-   |  _____________________________^
-LL | |
-LL | |
-LL | |
-...  |
-LL | |
-LL | |     });
-   | |_____^
-
-error: borrowed data cannot be stored outside of its closure
-  --> $DIR/expect-region-supply-region.rs:42:18
-   |
-LL |     let mut f: Option<&u32> = None;
-   |         ----- borrowed data cannot be stored into here...
-...
-LL |     closure_expecting_bound(|x: &'x u32| {
-   |                             ------------ ...because it cannot outlive this closure
-...
-LL |         f = Some(x);
-   |                  ^ cannot be stored outside of its closure
-
-error: aborting due to 5 previous errors
+error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/error-codes/E0490.nll.stderr b/src/test/ui/error-codes/E0490.nll.stderr
new file mode 100644 (file)
index 0000000..a1c33bb
--- /dev/null
@@ -0,0 +1,28 @@
+error: lifetime may not live long enough
+  --> $DIR/E0490.rs:2:12
+   |
+LL | fn f<'a, 'b>(y: &'b ()) {
+   |      --  -- lifetime `'b` defined here
+   |      |
+   |      lifetime `'a` defined here
+LL |     let x: &'a _ = &y;
+   |            ^^^^^ type annotation requires that `'b` must outlive `'a`
+   |
+   = help: consider adding the following bound: `'b: 'a`
+
+error[E0597]: `y` does not live long enough
+  --> $DIR/E0490.rs:2:20
+   |
+LL | fn f<'a, 'b>(y: &'b ()) {
+   |      -- lifetime `'a` defined here
+LL |     let x: &'a _ = &y;
+   |            -----   ^^ borrowed value does not live long enough
+   |            |
+   |            type annotation requires that `y` is borrowed for `'a`
+...
+LL | }
+   |  - `y` dropped here while still borrowed
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0597`.
diff --git a/src/test/ui/error-codes/E0490.rs b/src/test/ui/error-codes/E0490.rs
new file mode 100644 (file)
index 0000000..36bafa2
--- /dev/null
@@ -0,0 +1,8 @@
+fn f<'a, 'b>(y: &'b ()) {
+    let x: &'a _ = &y;
+    //~^ E0490
+    //~| E0495
+    //~| E0495
+}
+
+fn main() {}
diff --git a/src/test/ui/error-codes/E0490.stderr b/src/test/ui/error-codes/E0490.stderr
new file mode 100644 (file)
index 0000000..03fce21
--- /dev/null
@@ -0,0 +1,76 @@
+error[E0490]: a value of type `&'b ()` is borrowed for too long
+  --> $DIR/E0490.rs:2:20
+   |
+LL |     let x: &'a _ = &y;
+   |                    ^^
+   |
+note: the type is valid for the lifetime `'a` as defined on the function body at 1:6
+  --> $DIR/E0490.rs:1:6
+   |
+LL | fn f<'a, 'b>(y: &'b ()) {
+   |      ^^
+note: but the borrow lasts for the lifetime `'b` as defined on the function body at 1:10
+  --> $DIR/E0490.rs:1:10
+   |
+LL | fn f<'a, 'b>(y: &'b ()) {
+   |          ^^
+
+error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements
+  --> $DIR/E0490.rs:2:20
+   |
+LL |     let x: &'a _ = &y;
+   |                    ^^
+   |
+note: first, the lifetime cannot outlive the lifetime `'b` as defined on the function body at 1:10...
+  --> $DIR/E0490.rs:1:10
+   |
+LL | fn f<'a, 'b>(y: &'b ()) {
+   |          ^^
+note: ...so that the type `&'b ()` is not borrowed for too long
+  --> $DIR/E0490.rs:2:20
+   |
+LL |     let x: &'a _ = &y;
+   |                    ^^
+note: but, the lifetime must be valid for the lifetime `'a` as defined on the function body at 1:6...
+  --> $DIR/E0490.rs:1:6
+   |
+LL | fn f<'a, 'b>(y: &'b ()) {
+   |      ^^
+note: ...so that reference does not outlive borrowed content
+  --> $DIR/E0490.rs:2:20
+   |
+LL |     let x: &'a _ = &y;
+   |                    ^^
+
+error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
+  --> $DIR/E0490.rs:2:20
+   |
+LL |     let x: &'a _ = &y;
+   |                    ^^
+   |
+note: first, the lifetime cannot outlive the lifetime `'b` as defined on the function body at 1:10...
+  --> $DIR/E0490.rs:1:10
+   |
+LL | fn f<'a, 'b>(y: &'b ()) {
+   |          ^^
+note: ...so that the expression is assignable
+  --> $DIR/E0490.rs:2:20
+   |
+LL |     let x: &'a _ = &y;
+   |                    ^^
+   = note: expected  `&'a &()`
+              found  `&'a &'b ()`
+note: but, the lifetime must be valid for the lifetime `'a` as defined on the function body at 1:6...
+  --> $DIR/E0490.rs:1:6
+   |
+LL | fn f<'a, 'b>(y: &'b ()) {
+   |      ^^
+note: ...so that the reference type `&'a &()` does not outlive the data it points at
+  --> $DIR/E0490.rs:2:12
+   |
+LL |     let x: &'a _ = &y;
+   |            ^^^^^
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0495`.
diff --git a/src/test/ui/error-codes/E0621-does-not-trigger-for-closures.nll.stderr b/src/test/ui/error-codes/E0621-does-not-trigger-for-closures.nll.stderr
deleted file mode 100644 (file)
index 5140d1a..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-error: lifetime may not live long enough
-  --> $DIR/E0621-does-not-trigger-for-closures.rs:15:45
-   |
-LL |     invoke(&x, |a, b| if a > b { a } else { b });
-   |                    --                       ^ returning this value requires that `'1` must outlive `'2`
-   |                    ||
-   |                    |return type of closure is &'2 i32
-   |                    has type `&'1 i32`
-
-error: aborting due to previous error
-
index c58744d386ca5b0edf0a4fe270a454f6c9713cdc..44f174c0fb76f3692993567ec98a62ab3e18606c 100644 (file)
@@ -1,9 +1,7 @@
-// Test that we give the generic E0495 when one of the free regions is
+// Test that we give the generic error when one of the free regions is
 // bound in a closure (rather than suggesting a change to the signature
 // of the closure, which is not specified in `foo` but rather in `invoke`).
 
-// FIXME - This might be better as a UI test, but the finer details
-// of the error seem to vary on different machines.
 fn invoke<'a, F>(x: &'a i32, f: F) -> &'a i32
 where F: FnOnce(&'a i32, &i32) -> &'a i32
 {
@@ -12,7 +10,7 @@ fn invoke<'a, F>(x: &'a i32, f: F) -> &'a i32
 }
 
 fn foo<'a>(x: &'a i32) {
-    invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR E0495
+    invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR lifetime may not live long enough
 }
 
 fn main() {}
index feca7f10b706b22890178427631abd62ee72cbff..b9edeb8346bdc9973cd712f3a3ffad0f91317ffb 100644 (file)
@@ -1,30 +1,11 @@
-error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
-  --> $DIR/E0621-does-not-trigger-for-closures.rs:15:5
+error: lifetime may not live long enough
+  --> $DIR/E0621-does-not-trigger-for-closures.rs:13:45
    |
 LL |     invoke(&x, |a, b| if a > b { a } else { b });
-   |     ^^^^^^
-   |
-note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 15:16...
-  --> $DIR/E0621-does-not-trigger-for-closures.rs:15:16
-   |
-LL |     invoke(&x, |a, b| if a > b { a } else { b });
-   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...so that reference does not outlive borrowed content
-  --> $DIR/E0621-does-not-trigger-for-closures.rs:15:45
-   |
-LL |     invoke(&x, |a, b| if a > b { a } else { b });
-   |                                             ^
-note: but, the lifetime must be valid for the call at 15:5...
-  --> $DIR/E0621-does-not-trigger-for-closures.rs:15:5
-   |
-LL |     invoke(&x, |a, b| if a > b { a } else { b });
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...so type `&i32` of expression is valid during the expression
-  --> $DIR/E0621-does-not-trigger-for-closures.rs:15:5
-   |
-LL |     invoke(&x, |a, b| if a > b { a } else { b });
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |                    --                       ^ returning this value requires that `'1` must outlive `'2`
+   |                    ||
+   |                    |return type of closure is &'2 i32
+   |                    has type `&'1 i32`
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0495`.
index cd2d46ac182180e4a05021595d36dd0164ef603c..b42ff1486f0a85b3cee9b368831e4bd26a0c5809 100644 (file)
@@ -4,17 +4,11 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea
 LL | fn upper_bounds<'a, 'b, 'c, 'd, 'e>(a: Ordinary<'a>, b: Ordinary<'b>) -> impl Trait<'d, 'e>
    |                                                                          ^^^^^^^^^^^^^^^^^^
    |
-note: hidden type `Ordinary<'_>` captures the scope of call-site for function at 23:1
-  --> $DIR/ordinary-bounds-unrelated.rs:23:1
+note: hidden type `Ordinary<'_>` captures lifetime smaller than the function body
+  --> $DIR/ordinary-bounds-unrelated.rs:18:74
    |
-LL | / {
-LL | |     // Hidden type `Ordinary<'0>` with constraints:
-LL | |     //
-LL | |     // ```
-...  |
-LL | |     if condition() { a } else { b }
-LL | | }
-   | |_^
+LL | fn upper_bounds<'a, 'b, 'c, 'd, 'e>(a: Ordinary<'a>, b: Ordinary<'b>) -> impl Trait<'d, 'e>
+   |                                                                          ^^^^^^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
index 59ce93fa78b6b3754c151c15dc393c84fe9fe16e..254643c406caefe00f7b071da26d1d720c8c1cff 100644 (file)
@@ -4,17 +4,11 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea
 LL | fn upper_bounds<'a, 'b>(a: Ordinary<'a>, b: Ordinary<'b>) -> impl Trait<'a, 'b>
    |                                                              ^^^^^^^^^^^^^^^^^^
    |
-note: hidden type `Ordinary<'_>` captures the scope of call-site for function at 22:1
-  --> $DIR/ordinary-bounds-unsuited.rs:22:1
+note: hidden type `Ordinary<'_>` captures lifetime smaller than the function body
+  --> $DIR/ordinary-bounds-unsuited.rs:20:62
    |
-LL | / {
-LL | |     // We return a value:
-LL | |     //
-LL | |     // ```
-...  |
-LL | |     if condition() { a } else { b }
-LL | | }
-   | |_^
+LL | fn upper_bounds<'a, 'b>(a: Ordinary<'a>, b: Ordinary<'b>) -> impl Trait<'a, 'b>
+   |                                                              ^^^^^^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
index 2921a2bb398c39ea189173b7b07e9ee0a4e944d3..ff35b9ada45cd379dd66bc40e5e806ce62f5e22d 100644 (file)
@@ -6,22 +6,21 @@ trait A<T>
     fn get(&self) -> T { panic!() }
 }
 
-struct B<'a, T:'a>(&'a (A<T>+'a));
+struct B<'a, T: 'a>(&'a (A<T> + 'a));
 
 trait X { fn foo(&self) {} }
 
 impl<'a, T> X for B<'a, T> {}
 
-fn f<'a, T, U>(v: Box<A<T>+'static>) -> Box<X+'static> {
+fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> {
     // oh dear!
     box B(&*v) as Box<X>
-        //~^ ERROR the parameter type `T` may not live long enough
-        //~| ERROR the parameter type `T` may not live long enough
-        //~| ERROR the parameter type `T` may not live long enough
-        //~| ERROR the parameter type `T` may not live long enough
-        //~| ERROR the parameter type `T` may not live long enough
-        //~| ERROR the parameter type `T` may not live long enough
-        //~| ERROR the parameter type `T` may not live long enough
+    //~^ ERROR the parameter type `T` may not live long enough
+    //~| ERROR the parameter type `T` may not live long enough
+    //~| ERROR the parameter type `T` may not live long enough
+    //~| ERROR the parameter type `T` may not live long enough
+    //~| ERROR the parameter type `T` may not live long enough
+    //~| ERROR the parameter type `T` may not live long enough
 }
 
 fn main() {}
index 14727000b2c2404992dec9d9662744695508cdce..2bcdcd1864e2f1772a6e0f6294d66cfceb620223 100644 (file)
@@ -1,7 +1,7 @@
 error[E0310]: the parameter type `T` may not live long enough
   --> $DIR/regions-close-object-into-object-5.rs:17:5
    |
-LL | fn f<'a, T, U>(v: Box<A<T>+'static>) -> Box<X+'static> {
+LL | fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> {
    |          - help: consider adding an explicit lifetime bound...: `T: 'static`
 LL |     // oh dear!
 LL |     box B(&*v) as Box<X>
@@ -13,25 +13,10 @@ note: ...so that the type `B<'_, T>` will meet its required lifetime bounds
 LL |     box B(&*v) as Box<X>
    |     ^^^^^^^^^^
 
-error[E0310]: the parameter type `T` may not live long enough
-  --> $DIR/regions-close-object-into-object-5.rs:17:5
-   |
-LL | fn f<'a, T, U>(v: Box<A<T>+'static>) -> Box<X+'static> {
-   |          - help: consider adding an explicit lifetime bound...: `T: 'static`
-LL |     // oh dear!
-LL |     box B(&*v) as Box<X>
-   |     ^^^^^^^^^^^^^^^^^^^^
-   |
-note: ...so that it can be closed over into an object
-  --> $DIR/regions-close-object-into-object-5.rs:17:5
-   |
-LL |     box B(&*v) as Box<X>
-   |     ^^^^^^^^^^^^^^^^^^^^
-
 error[E0310]: the parameter type `T` may not live long enough
   --> $DIR/regions-close-object-into-object-5.rs:17:9
    |
-LL | fn f<'a, T, U>(v: Box<A<T>+'static>) -> Box<X+'static> {
+LL | fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> {
    |          - help: consider adding an explicit lifetime bound...: `T: 'static`
 LL |     // oh dear!
 LL |     box B(&*v) as Box<X>
@@ -46,7 +31,7 @@ LL |     box B(&*v) as Box<X>
 error[E0310]: the parameter type `T` may not live long enough
   --> $DIR/regions-close-object-into-object-5.rs:17:9
    |
-LL | fn f<'a, T, U>(v: Box<A<T>+'static>) -> Box<X+'static> {
+LL | fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> {
    |          - help: consider adding an explicit lifetime bound...: `T: 'static`
 LL |     // oh dear!
 LL |     box B(&*v) as Box<X>
@@ -61,7 +46,7 @@ LL |     box B(&*v) as Box<X>
 error[E0310]: the parameter type `T` may not live long enough
   --> $DIR/regions-close-object-into-object-5.rs:17:11
    |
-LL | fn f<'a, T, U>(v: Box<A<T>+'static>) -> Box<X+'static> {
+LL | fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> {
    |          - help: consider adding an explicit lifetime bound...: `T: 'static`
 LL |     // oh dear!
 LL |     box B(&*v) as Box<X>
@@ -76,7 +61,7 @@ LL |     box B(&*v) as Box<X>
 error[E0310]: the parameter type `T` may not live long enough
   --> $DIR/regions-close-object-into-object-5.rs:17:11
    |
-LL | fn f<'a, T, U>(v: Box<A<T>+'static>) -> Box<X+'static> {
+LL | fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> {
    |          - help: consider adding an explicit lifetime bound...: `T: 'static`
 LL |     // oh dear!
 LL |     box B(&*v) as Box<X>
@@ -91,7 +76,7 @@ LL |     box B(&*v) as Box<X>
 error[E0310]: the parameter type `T` may not live long enough
   --> $DIR/regions-close-object-into-object-5.rs:17:11
    |
-LL | fn f<'a, T, U>(v: Box<A<T>+'static>) -> Box<X+'static> {
+LL | fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> {
    |          - help: consider adding an explicit lifetime bound...: `T: 'static`
 LL |     // oh dear!
 LL |     box B(&*v) as Box<X>
@@ -103,6 +88,6 @@ note: ...so that the type `(dyn A<T> + 'static)` is not borrowed for too long
 LL |     box B(&*v) as Box<X>
    |           ^^^
 
-error: aborting due to 7 previous errors
+error: aborting due to 6 previous errors
 
 For more information about this error, try `rustc --explain E0310`.
index 7d3d51bdb437ebe8caa02ad430935beec947d00a..3101d815881b17fcd6442581dcefd58cd99acd00 100644 (file)
@@ -1,5 +1,5 @@
 error[E0310]: the parameter type `A` may not live long enough
-  --> $DIR/regions-close-over-type-parameter-1.rs:10:5
+  --> $DIR/regions-close-over-type-parameter-1.rs:12:5
    |
 LL |     box v as Box<dyn SomeTrait + 'static>
    |     ^^^^^
@@ -7,7 +7,7 @@ LL |     box v as Box<dyn SomeTrait + 'static>
    = help: consider adding an explicit lifetime bound `A: 'static`...
 
 error[E0309]: the parameter type `A` may not live long enough
-  --> $DIR/regions-close-over-type-parameter-1.rs:20:5
+  --> $DIR/regions-close-over-type-parameter-1.rs:21:5
    |
 LL |     box v as Box<dyn SomeTrait + 'b>
    |     ^^^^^
index 6a9aa66a446c378cbd54a19b34327139b7ea122c..6e708a5f70fbd828edd106b96fed18ea85042e00 100644 (file)
@@ -4,22 +4,22 @@
 // an object. This should yield errors unless `A` (and the object)
 // both have suitable bounds.
 
-trait SomeTrait { fn get(&self) -> isize; }
+trait SomeTrait {
+    fn get(&self) -> isize;
+}
 
-fn make_object1<A:SomeTrait>(v: A) -> Box<dyn SomeTrait + 'static> {
+fn make_object1<A: SomeTrait>(v: A) -> Box<dyn SomeTrait + 'static> {
     box v as Box<dyn SomeTrait + 'static>
-        //~^ ERROR the parameter type `A` may not live long enough
-        //~| ERROR the parameter type `A` may not live long enough
+    //~^ ERROR the parameter type `A` may not live long enough
 }
 
-fn make_object2<'a,A:SomeTrait+'a>(v: A) -> Box<dyn SomeTrait + 'a> {
+fn make_object2<'a, A: SomeTrait + 'a>(v: A) -> Box<dyn SomeTrait + 'a> {
     box v as Box<dyn SomeTrait + 'a>
 }
 
-fn make_object3<'a,'b,A:SomeTrait+'a>(v: A) -> Box<dyn SomeTrait + 'b> {
+fn make_object3<'a, 'b, A: SomeTrait + 'a>(v: A) -> Box<dyn SomeTrait + 'b> {
     box v as Box<dyn SomeTrait + 'b>
-        //~^ ERROR the parameter type `A` may not live long enough
-        //~| ERROR the parameter type `A` may not live long enough
+    //~^ ERROR the parameter type `A` may not live long enough
 }
 
-fn main() { }
+fn main() {}
index ed9a604e717dd617199cc127bef35345bab87833..a7509cb608c6b71aa19e3991a054b36242795efc 100644 (file)
@@ -1,60 +1,32 @@
 error[E0310]: the parameter type `A` may not live long enough
-  --> $DIR/regions-close-over-type-parameter-1.rs:10:5
+  --> $DIR/regions-close-over-type-parameter-1.rs:12:5
    |
-LL | fn make_object1<A:SomeTrait>(v: A) -> Box<dyn SomeTrait + 'static> {
+LL | fn make_object1<A: SomeTrait>(v: A) -> Box<dyn SomeTrait + 'static> {
    |                 -- help: consider adding an explicit lifetime bound...: `A: 'static +`
 LL |     box v as Box<dyn SomeTrait + 'static>
    |     ^^^^^
    |
 note: ...so that the type `A` will meet its required lifetime bounds
-  --> $DIR/regions-close-over-type-parameter-1.rs:10:5
+  --> $DIR/regions-close-over-type-parameter-1.rs:12:5
    |
 LL |     box v as Box<dyn SomeTrait + 'static>
    |     ^^^^^
 
-error[E0310]: the parameter type `A` may not live long enough
-  --> $DIR/regions-close-over-type-parameter-1.rs:10:5
-   |
-LL | fn make_object1<A:SomeTrait>(v: A) -> Box<dyn SomeTrait + 'static> {
-   |                 -- help: consider adding an explicit lifetime bound...: `A: 'static +`
-LL |     box v as Box<dyn SomeTrait + 'static>
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-note: ...so that it can be closed over into an object
-  --> $DIR/regions-close-over-type-parameter-1.rs:10:5
-   |
-LL |     box v as Box<dyn SomeTrait + 'static>
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
 error[E0309]: the parameter type `A` may not live long enough
-  --> $DIR/regions-close-over-type-parameter-1.rs:20:5
+  --> $DIR/regions-close-over-type-parameter-1.rs:21:5
    |
-LL | fn make_object3<'a,'b,A:SomeTrait+'a>(v: A) -> Box<dyn SomeTrait + 'b> {
-   |                       -- help: consider adding an explicit lifetime bound...: `A: 'b +`
+LL | fn make_object3<'a, 'b, A: SomeTrait + 'a>(v: A) -> Box<dyn SomeTrait + 'b> {
+   |                         -- help: consider adding an explicit lifetime bound...: `A: 'b +`
 LL |     box v as Box<dyn SomeTrait + 'b>
    |     ^^^^^
    |
 note: ...so that the type `A` will meet its required lifetime bounds
-  --> $DIR/regions-close-over-type-parameter-1.rs:20:5
+  --> $DIR/regions-close-over-type-parameter-1.rs:21:5
    |
 LL |     box v as Box<dyn SomeTrait + 'b>
    |     ^^^^^
 
-error[E0309]: the parameter type `A` may not live long enough
-  --> $DIR/regions-close-over-type-parameter-1.rs:20:5
-   |
-LL | fn make_object3<'a,'b,A:SomeTrait+'a>(v: A) -> Box<dyn SomeTrait + 'b> {
-   |                       -- help: consider adding an explicit lifetime bound...: `A: 'b +`
-LL |     box v as Box<dyn SomeTrait + 'b>
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-note: ...so that it can be closed over into an object
-  --> $DIR/regions-close-over-type-parameter-1.rs:20:5
-   |
-LL |     box v as Box<dyn SomeTrait + 'b>
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: aborting due to 4 previous errors
+error: aborting due to 2 previous errors
 
 Some errors have detailed explanations: E0309, E0310.
 For more information about an error, try `rustc --explain E0309`.
diff --git a/src/test/ui/regions/regions-escape-method.nll.stderr b/src/test/ui/regions/regions-escape-method.nll.stderr
deleted file mode 100644 (file)
index 9f42512..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-error: lifetime may not live long enough
-  --> $DIR/regions-escape-method.rs:15:13
-   |
-LL |     s.f(|p| p)
-   |          -- ^ returning this value requires that `'1` must outlive `'2`
-   |          ||
-   |          |return type of closure is &'2 i32
-   |          has type `&'1 i32`
-
-error: aborting due to previous error
-
index 5127d4d1ceb0ff606d9559a0bcd5db45b461b622..69c01ae6906cb86c20df592de359a87a68a82cf1 100644 (file)
@@ -12,5 +12,5 @@ fn f<B, F>(&self, _: F) where F: FnOnce(&i32) -> B {
 
 fn main() {
     let s = S;
-    s.f(|p| p) //~ ERROR cannot infer
+    s.f(|p| p) //~ ERROR lifetime may not live long enough
 }
index ffc2a259485aa77afb467fbc07a36520a7836553..9f425125b9896eca564b1efc5b232e9c0e3a2564 100644 (file)
@@ -1,32 +1,11 @@
-error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
+error: lifetime may not live long enough
   --> $DIR/regions-escape-method.rs:15:13
    |
 LL |     s.f(|p| p)
-   |             ^
-   |
-note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 15:9...
-  --> $DIR/regions-escape-method.rs:15:9
-   |
-LL |     s.f(|p| p)
-   |         ^^^^^
-note: ...so that the expression is assignable
-  --> $DIR/regions-escape-method.rs:15:13
-   |
-LL |     s.f(|p| p)
-   |             ^
-   = note: expected  `&i32`
-              found  `&i32`
-note: but, the lifetime must be valid for the method call at 15:5...
-  --> $DIR/regions-escape-method.rs:15:5
-   |
-LL |     s.f(|p| p)
-   |     ^^^^^^^^^^
-note: ...so that a type/lifetime parameter is in scope here
-  --> $DIR/regions-escape-method.rs:15:5
-   |
-LL |     s.f(|p| p)
-   |     ^^^^^^^^^^
+   |          -- ^ returning this value requires that `'1` must outlive `'2`
+   |          ||
+   |          |return type of closure is &'2 i32
+   |          has type `&'1 i32`
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0495`.
diff --git a/src/test/ui/regions/regions-escape-via-trait-or-not.nll.stderr b/src/test/ui/regions/regions-escape-via-trait-or-not.nll.stderr
deleted file mode 100644 (file)
index cae6c33..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-error: lifetime may not live long enough
-  --> $DIR/regions-escape-via-trait-or-not.rs:18:14
-   |
-LL |     with(|o| o)
-   |           -- ^ returning this value requires that `'1` must outlive `'2`
-   |           ||
-   |           |return type of closure is &'2 isize
-   |           has type `&'1 isize`
-
-error: aborting due to previous error
-
index 1e089616f59978bd9f74704d357799d8a12a59c1..ac0e56de4a0300eb73839fae3503dd2250bd64a2 100644 (file)
@@ -15,7 +15,7 @@ fn with<R:Deref, F>(f: F) -> isize where F: FnOnce(&isize) -> R {
 }
 
 fn return_it() -> isize {
-    with(|o| o) //~ ERROR cannot infer
+    with(|o| o) //~ ERROR lifetime may not live long enough
 }
 
 fn main() {
index 90823464c56d26ee8fef1219cda652aa071a9c33..cae6c33ac6e1759b00ff891f06aaf16cfa6f338a 100644 (file)
@@ -1,32 +1,11 @@
-error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
+error: lifetime may not live long enough
   --> $DIR/regions-escape-via-trait-or-not.rs:18:14
    |
 LL |     with(|o| o)
-   |              ^
-   |
-note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 18:10...
-  --> $DIR/regions-escape-via-trait-or-not.rs:18:10
-   |
-LL |     with(|o| o)
-   |          ^^^^^
-note: ...so that the expression is assignable
-  --> $DIR/regions-escape-via-trait-or-not.rs:18:14
-   |
-LL |     with(|o| o)
-   |              ^
-   = note: expected  `&isize`
-              found  `&isize`
-note: but, the lifetime must be valid for the expression at 18:5...
-  --> $DIR/regions-escape-via-trait-or-not.rs:18:5
-   |
-LL |     with(|o| o)
-   |     ^^^^
-note: ...so type `fn([closure@$DIR/regions-escape-via-trait-or-not.rs:18:10: 18:15]) -> isize {with::<&isize, [closure@$DIR/regions-escape-via-trait-or-not.rs:18:10: 18:15]>}` of expression is valid during the expression
-  --> $DIR/regions-escape-via-trait-or-not.rs:18:5
-   |
-LL |     with(|o| o)
-   |     ^^^^
+   |           -- ^ returning this value requires that `'1` must outlive `'2`
+   |           ||
+   |           |return type of closure is &'2 isize
+   |           has type `&'1 isize`
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0495`.
diff --git a/src/test/ui/regions/regions-infer-call-3.nll.stderr b/src/test/ui/regions/regions-infer-call-3.nll.stderr
deleted file mode 100644 (file)
index ca51555..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-error: lifetime may not live long enough
-  --> $DIR/regions-infer-call-3.rs:8:24
-   |
-LL |     let z = with(|y| { select(x, y) });
-   |                   --   ^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'2`
-   |                   ||
-   |                   |return type of closure is &'2 isize
-   |                   has type `&'1 isize`
-
-error: aborting due to previous error
-
index a76fccbdc52185da4ec7e0dd9a1d674a5fab6606..063ec84288d1f79a57dde81a7362d86392b6fb3d 100644 (file)
@@ -6,7 +6,7 @@ fn with<T, F>(f: F) -> T where F: FnOnce(&isize) -> T {
 
 fn manip<'a>(x: &'a isize) -> isize {
     let z = with(|y| { select(x, y) });
-    //~^ ERROR cannot infer
+    //~^ ERROR lifetime may not live long enough
     *z
 }
 
index 1d6dbdb2c7b57f3de79825376cb789249ffde81f..ca51555a07749355b46a7d02bdd995d97022a486 100644 (file)
@@ -1,30 +1,11 @@
-error[E0495]: cannot infer an appropriate lifetime for lifetime parameter 'r in function call due to conflicting requirements
+error: lifetime may not live long enough
   --> $DIR/regions-infer-call-3.rs:8:24
    |
 LL |     let z = with(|y| { select(x, y) });
-   |                        ^^^^^^^^^^^^
-   |
-note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 8:18...
-  --> $DIR/regions-infer-call-3.rs:8:18
-   |
-LL |     let z = with(|y| { select(x, y) });
-   |                  ^^^^^^^^^^^^^^^^^^^^
-note: ...so that reference does not outlive borrowed content
-  --> $DIR/regions-infer-call-3.rs:8:34
-   |
-LL |     let z = with(|y| { select(x, y) });
-   |                                  ^
-note: but, the lifetime must be valid for the call at 8:13...
-  --> $DIR/regions-infer-call-3.rs:8:13
-   |
-LL |     let z = with(|y| { select(x, y) });
-   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...so type `&isize` of expression is valid during the expression
-  --> $DIR/regions-infer-call-3.rs:8:13
-   |
-LL |     let z = with(|y| { select(x, y) });
-   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |                   --   ^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'2`
+   |                   ||
+   |                   |return type of closure is &'2 isize
+   |                   has type `&'1 isize`
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0495`.
diff --git a/src/test/ui/regions/regions-return-ref-to-upvar-issue-17403.nll.stderr b/src/test/ui/regions/regions-return-ref-to-upvar-issue-17403.nll.stderr
deleted file mode 100644 (file)
index 4c275b1..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-error: captured variable cannot escape `FnMut` closure body
-  --> $DIR/regions-return-ref-to-upvar-issue-17403.rs:7:24
-   |
-LL |         let mut f = || &mut x;
-   |                      - ^^^^^^ returns a reference to a captured variable which escapes the closure body
-   |                      |
-   |                      inferred to be a `FnMut` closure
-   |
-   = note: `FnMut` closures only have access to their captured variables while they are executing...
-   = note: ...therefore, they cannot allow references to captured variables to escape
-
-error: aborting due to previous error
-
index afe87f47eadbee6076a1c16a690f24e1a991c913..86e759f088a549e7d4aa8f87577810e28b8bb1c7 100644 (file)
@@ -4,7 +4,7 @@ fn main() {
     // Unboxed closure case
     {
         let mut x = 0;
-        let mut f = || &mut x; //~ ERROR cannot infer
+        let mut f = || &mut x; //~ ERROR captured variable cannot escape `FnMut` closure body
         let x = f();
         let y = f();
     }
index 946465bcb5f261a4437b307d33c4e954907d5187..4c275b19492c69a0d6088f0721969a2badfee555 100644 (file)
@@ -1,30 +1,13 @@
-error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements
+error: captured variable cannot escape `FnMut` closure body
   --> $DIR/regions-return-ref-to-upvar-issue-17403.rs:7:24
    |
 LL |         let mut f = || &mut x;
-   |                        ^^^^^^
+   |                      - ^^^^^^ returns a reference to a captured variable which escapes the closure body
+   |                      |
+   |                      inferred to be a `FnMut` closure
    |
-note: first, the lifetime cannot outlive the lifetime `'_` as defined on the body at 7:21...
-  --> $DIR/regions-return-ref-to-upvar-issue-17403.rs:7:21
-   |
-LL |         let mut f = || &mut x;
-   |                     ^^^^^^^^^
-note: ...so that closure can access `x`
-  --> $DIR/regions-return-ref-to-upvar-issue-17403.rs:7:24
-   |
-LL |         let mut f = || &mut x;
-   |                        ^^^^^^
-note: but, the lifetime must be valid for the call at 9:17...
-  --> $DIR/regions-return-ref-to-upvar-issue-17403.rs:9:17
-   |
-LL |         let y = f();
-   |                 ^^^
-note: ...so type `&mut i32` of expression is valid during the expression
-  --> $DIR/regions-return-ref-to-upvar-issue-17403.rs:9:17
-   |
-LL |         let y = f();
-   |                 ^^^
+   = note: `FnMut` closures only have access to their captured variables while they are executing...
+   = note: ...therefore, they cannot allow references to captured variables to escape
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0495`.
index 1f689a5bd25419cdf85881880d75a5d9e76993f4..cdcf89e4e614e31263fc0b327eceafb6fe410f24 100644 (file)
@@ -3,8 +3,8 @@
 // revisions: legacy v0
 //[legacy]compile-flags: -Z symbol-mangling-version=legacy
     //[v0]compile-flags: -Z symbol-mangling-version=v0
-//[legacy]normalize-stderr-32bit: "hdb62078998ce7ea8" -> "SYMBOL_HASH"
-//[legacy]normalize-stderr-64bit: "h62e540f14f879d56" -> "SYMBOL_HASH"
+//[legacy]normalize-stderr-32bit: "h5ef5dfc14aeecbfc" -> "SYMBOL_HASH"
+//[legacy]normalize-stderr-64bit: "h9e54d216f70fcbc5" -> "SYMBOL_HASH"
 
 #![feature(optin_builtin_traits, rustc_attrs)]
 #![allow(dead_code)]