]> git.lizzy.rs Git - rust.git/commitdiff
Same change to point at borrow for mir errors
authorEsteban Küber <esteban@kuber.com.ar>
Thu, 14 Dec 2017 17:57:34 +0000 (09:57 -0800)
committerEsteban Küber <esteban@kuber.com.ar>
Fri, 15 Dec 2017 21:52:05 +0000 (13:52 -0800)
25 files changed:
src/librustc_mir/borrow_check/error_reporting.rs
src/test/compile-fail-fulldeps/dropck_tarena_cycle_checked.rs
src/test/compile-fail-fulldeps/dropck_tarena_unsound_drop.rs
src/test/compile-fail/E0597.rs
src/test/compile-fail/catch-bad-lifetime.rs
src/test/compile-fail/issue-36082.rs
src/test/compile-fail/region-borrow-params-issue-29793-big.rs
src/test/ui/issue-46471-1.rs
src/test/ui/issue-46471-1.stderr
src/test/ui/issue-46471.stderr
src/test/ui/issue-46472.stderr
src/test/ui/nll/capture-ref-in-struct.stderr
src/test/ui/nll/closure-requirements/escape-argument.stderr
src/test/ui/nll/closure-requirements/escape-upvar-nested.stderr
src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr
src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr
src/test/ui/region-borrow-params-issue-29793-small.stderr
src/test/ui/span/borrowck-let-suggestion-suffixes.rs
src/test/ui/span/borrowck-let-suggestion-suffixes.stderr
src/test/ui/span/dropck-object-cycle.rs
src/test/ui/span/dropck-object-cycle.stderr
src/test/ui/span/issue-36537.rs
src/test/ui/span/issue-36537.stderr
src/test/ui/span/regions-escape-loop-via-vec.rs
src/test/ui/span/regions-escape-loop-via-vec.stderr

index 186598001da6a67f1cbd1dec4c6496a83078799c..679e9059c4eba7051f2099527ddaff3b9bc571ff 100644 (file)
@@ -394,10 +394,10 @@ fn report_scoped_local_value_does_not_live_long_enough(
         &mut self, name: &String, _scope_tree: &Rc<ScopeTree>, _borrow: &BorrowData<'tcx>,
         drop_span: Span, borrow_span: Span, _proper_span: Span, end_span: Option<Span>
     ) {
-        let mut err = self.tcx.path_does_not_live_long_enough(drop_span,
+        let mut err = self.tcx.path_does_not_live_long_enough(borrow_span,
                                                               &format!("`{}`", name),
                                                               Origin::Mir);
-        err.span_label(borrow_span, "borrow occurs here");
+        err.span_label(borrow_span, "borrowed value does not live long enough");
         err.span_label(drop_span, format!("`{}` dropped here while still borrowed", name));
         if let Some(end) = end_span {
             err.span_label(end, "borrowed value needs to live until here");
@@ -407,12 +407,12 @@ fn report_scoped_local_value_does_not_live_long_enough(
 
     fn report_scoped_temporary_value_does_not_live_long_enough(
         &mut self, _scope_tree: &Rc<ScopeTree>, _borrow: &BorrowData<'tcx>,
-        drop_span: Span, borrow_span: Span, proper_span: Span, end_span: Option<Span>
+        drop_span: Span, _borrow_span: Span, proper_span: Span, end_span: Option<Span>
     ) {
-        let mut err = self.tcx.path_does_not_live_long_enough(borrow_span,
+        let mut err = self.tcx.path_does_not_live_long_enough(proper_span,
                                                               "borrowed value",
                                                               Origin::Mir);
-        err.span_label(proper_span, "temporary value created here");
+        err.span_label(proper_span, "temporary value does not live long enough");
         err.span_label(drop_span, "temporary value dropped here while still borrowed");
         err.note("consider using a `let` binding to increase its lifetime");
         if let Some(end) = end_span {
@@ -428,7 +428,7 @@ fn report_unscoped_local_value_does_not_live_long_enough(
         let mut err = self.tcx.path_does_not_live_long_enough(borrow_span,
                                                               &format!("`{}`", name),
                                                               Origin::Mir);
-        err.span_label(borrow_span, "does not live long enough");
+        err.span_label(borrow_span, "borrowed value does not live long enough");
         err.span_label(drop_span, "borrowed value only lives until here");
         self.tcx.note_and_explain_region(scope_tree, &mut err,
                                          "borrowed value must be valid for ",
@@ -443,7 +443,7 @@ fn report_unscoped_temporary_value_does_not_live_long_enough(
         let mut err = self.tcx.path_does_not_live_long_enough(proper_span,
                                                               "borrowed value",
                                                               Origin::Mir);
-        err.span_label(proper_span, "does not live long enough");
+        err.span_label(proper_span, "temporary value does not live long enough");
         err.span_label(drop_span, "temporary value only lives until here");
         self.tcx.note_and_explain_region(scope_tree, &mut err,
                                          "borrowed value must be valid for ",
index bc88ff9244c99bc39ca393f622654537b02d137d..f368788af55de50cb2f4830b18fb050f1420c6bd 100644 (file)
@@ -124,4 +124,4 @@ fn f<'a>(arena: &'a TypedArena<C<'a>>) {
 fn main() {
     let arena = TypedArena::new();
     f(&arena);
-} //~ ERROR `arena` does not live long enough
+} //~^ ERROR `arena` does not live long enough
index 30829847a3a229ce1e16858a71e78311b68e498c..531e1ada44b3fd3f076d05f1d4726af9f78f9ba0 100644 (file)
@@ -49,5 +49,5 @@ fn f<'a>(_arena: &'a TypedArena<C<'a>>) {}
 fn main() {
     let arena: TypedArena<C> = TypedArena::new();
     f(&arena);
-} //~ ERROR `arena` does not live long enough
+} //~^ ERROR `arena` does not live long enough
 
index 00ef14a8e2af036c535eec68f05908e4ad9a2509..2f4a1da91d88f77a16d80bf3c8491f109ec4c511 100644 (file)
@@ -16,4 +16,5 @@ fn main() {
     let mut x = Foo { x: None };
     let y = 0;
     x.x = Some(&y);
-} //~ `y` does not live long enough [E0597]
+    //~^ `y` does not live long enough [E0597]
+}
index 57242dad6e31ee9501d2b850d7a487c9e4c61663..f24561b8887b98022c7d5b040ab2748a44508401 100644 (file)
@@ -18,10 +18,11 @@ pub fn main() {
         let _result: Result<(), &str> = do catch {
             let my_string = String::from("");
             let my_str: & str = & my_string;
+            //~^ ERROR `my_string` does not live long enough
             Err(my_str) ?;
             Err("") ?;
             Ok(())
-        }; //~ ERROR `my_string` does not live long enough
+        };
     }
 
     {
index 33a9b1e926cf5dd6cfdead7fbb8317c55886cf0c..fc3e0633750d8c29ddd7c86092fca49fccbed399 100644 (file)
@@ -21,11 +21,11 @@ fn main() {
     let val: &_ = x.borrow().0;
     //[ast]~^ ERROR borrowed value does not live long enough [E0597]
     //[ast]~| NOTE temporary value dropped here while still borrowed
-    //[ast]~| NOTE temporary value created here
+    //[ast]~| NOTE temporary value does not live long enough
     //[ast]~| NOTE consider using a `let` binding to increase its lifetime
     //[mir]~^^^^^ ERROR borrowed value does not live long enough [E0597]
     //[mir]~| NOTE temporary value dropped here while still borrowed
-    //[mir]~| NOTE temporary value created here
+    //[mir]~| NOTE temporary value does not live long enough
     //[mir]~| NOTE consider using a `let` binding to increase its lifetime
     println!("{}", val);
 }
index 2e2dfdb03d990796a9fa91b7d370d95156af3448..642e90f6de8e622f92f3e1df039bfdb2d0980a31 100644 (file)
@@ -81,9 +81,9 @@ fn main() {
         WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`)
             //[ast]~^ ERROR `x` does not live long enough
             //[ast]~| ERROR `y` does not live long enough
+            //[mir]~^^^ ERROR `x` does not live long enough
+            //[mir]~| ERROR `y` does not live long enough
     });
-    //[mir]~^ ERROR `x` does not live long enough
-    //[mir]~| ERROR `y` does not live long enough
 
     w.handle(); // This works
     // w.handle_ref(); // This doesn't
index 977ea785fe6d33c5be337107bb027c0bcb3033dd..0dbcdea89f94091b27340b9331b9afbc9f736990 100644 (file)
@@ -15,7 +15,7 @@ fn main() {
         let mut z = 0;
         &mut z
     };
-    //~^ ERROR `z` does not live long enough (Ast) [E0597]
+    //~^^ ERROR `z` does not live long enough (Ast) [E0597]
     //~| ERROR `z` does not live long enough (Mir) [E0597]
     println!("{}", y);
 }
index 466ae501a320a5f268568b08eef0962f9bd1e889..9f12092f99cc04bef8a999a43ca2bf24d42bbdb5 100644 (file)
@@ -10,12 +10,12 @@ error[E0597]: `z` does not live long enough (Ast)
    | - borrowed value needs to live until here
 
 error[E0597]: `z` does not live long enough (Mir)
-  --> $DIR/issue-46471-1.rs:17:6
+  --> $DIR/issue-46471-1.rs:16:9
    |
 16 |         &mut z
-   |         ------ borrow occurs here
+   |         ^^^^^^ borrowed value does not live long enough
 17 |     };
-   |      ^ `z` dropped here while still borrowed
+   |      - `z` dropped here while still borrowed
 ...
 21 | }
    | - borrowed value needs to live until here
index bddd1a9f232bba9f9935d46b4dc8bb196e1984d1..19fc579d198ff6d3be172c1c3b47d50c5eaa3ece 100644 (file)
@@ -13,7 +13,7 @@ error[E0597]: `x` does not live long enough (Mir)
   --> $DIR/issue-46471.rs:15:5
    |
 15 |     &x
-   |     ^^ does not live long enough
+   |     ^^ borrowed value does not live long enough
 ...
 18 | }
    |  - borrowed value only lives until here
index a6bde956fca62beaf932f02833185c46c162122a..50df72fc2a0201326b2b674109c1563c2a39ba8e 100644 (file)
@@ -21,7 +21,7 @@ error[E0597]: borrowed value does not live long enough (Mir)
   --> $DIR/issue-46472.rs:14:10
    |
 14 |     &mut 4
-   |          ^ does not live long enough
+   |          ^ temporary value does not live long enough
 ...
 17 | }
    |  - temporary value only lives until here
index 6b57f91987be5e810da3b556ebf025991107e8d0..ed57d89802cd131194e5375a033a3368c4b34de9 100644 (file)
@@ -2,7 +2,7 @@ error[E0597]: `y` does not live long enough
   --> $DIR/capture-ref-in-struct.rs:32:16
    |
 32 |             y: &y,
-   |                ^^ does not live long enough
+   |                ^^ borrowed value does not live long enough
 ...
 37 |     }
    |      - borrowed value only lives until here
index 0ec671997e7afcf57e124607d5f0b8550327ff29..4e9a25e28927383e74a3557e521c3b94be9164a4 100644 (file)
@@ -28,7 +28,7 @@ error[E0597]: `y` does not live long enough
   --> $DIR/escape-argument.rs:37:25
    |
 37 |         closure(&mut p, &y);
-   |                         ^^ does not live long enough
+   |                         ^^ borrowed value does not live long enough
 38 |         //~^ ERROR `y` does not live long enough [E0597]
 39 |     }
    |      - borrowed value only lives until here
index 6c70afa0c9c8ab53987db0d196b5a21ea5247dda..60bd7a569a0c7b3db45f0b84135aac96dbf467ab 100644 (file)
@@ -54,7 +54,7 @@ error[E0597]: `y` does not live long enough
 31 | |             let mut closure1 = || p = &y;
 32 | |             closure1();
 33 | |         };
-   | |_________^ does not live long enough
+   | |_________^ borrowed value does not live long enough
 ...
 36 |       }
    |        - borrowed value only lives until here
index 0b982dd812b59a6a9f09ca42fc22a7c4008eedc2..dc86f4cff08d3830da985277176970c9a591d45e 100644 (file)
@@ -31,7 +31,7 @@ error[E0597]: `y` does not live long enough
   --> $DIR/escape-upvar-ref.rs:33:27
    |
 33 |         let mut closure = || p = &y;
-   |                           ^^^^^^^^^ does not live long enough
+   |                           ^^^^^^^^^ borrowed value does not live long enough
 ...
 36 |     }
    |      - borrowed value only lives until here
index b93c69dc13f46ba691b79412cd196884879be704..9b23c48e249401661fd3ced4f7986c4625f362c0 100644 (file)
@@ -75,7 +75,7 @@ error[E0597]: `a` does not live long enough
   --> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:41:26
    |
 41 |     let cell = Cell::new(&a);
-   |                          ^^ does not live long enough
+   |                          ^^ borrowed value does not live long enough
 ...
 49 | }
    | - borrowed value only lives until here
index d640d5c8bd97b2bff52c3edab9fb68209c0cd7d7..7cdea5b0bd2645d9e9a2b30ec2517f49f4319425 100644 (file)
@@ -2,7 +2,7 @@ error[E0597]: `x` does not live long enough
   --> $DIR/region-borrow-params-issue-29793-small.rs:19:34
    |
 19 |         let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
-   |                 ---------        ^ does not live long enough
+   |                 ---------        ^ borrowed value does not live long enough
    |                 |
    |                 capture occurs here
 ...
@@ -15,7 +15,7 @@ error[E0597]: `y` does not live long enough
   --> $DIR/region-borrow-params-issue-29793-small.rs:19:45
    |
 19 |         let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
-   |                 ---------                   ^ does not live long enough
+   |                 ---------                   ^ borrowed value does not live long enough
    |                 |
    |                 capture occurs here
 ...
@@ -28,7 +28,7 @@ error[E0597]: `x` does not live long enough
   --> $DIR/region-borrow-params-issue-29793-small.rs:34:34
    |
 34 |         let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
-   |                 ---------        ^ does not live long enough
+   |                 ---------        ^ borrowed value does not live long enough
    |                 |
    |                 capture occurs here
 ...
@@ -41,7 +41,7 @@ error[E0597]: `y` does not live long enough
   --> $DIR/region-borrow-params-issue-29793-small.rs:34:45
    |
 34 |         let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
-   |                 ---------                   ^ does not live long enough
+   |                 ---------                   ^ borrowed value does not live long enough
    |                 |
    |                 capture occurs here
 ...
index 5d7d1cd30c0cd8349f9e553f11e25577fea8fd93..8a27af0119aaaa54fe775ad465839c4748ea3eec 100644 (file)
@@ -42,6 +42,7 @@ fn f() {
         //~| NOTE consider using a `let` binding to increase its lifetime
 
     }                       // (statement 7)
+    //~^ NOTE temporary value needs to live until here
 
     let mut v5 = Vec::new(); // statement 8
 
index 3daeb71d346e17ea331031c23afc45ba63f50e1b..e65fd723e5f585019bf59d92db2b702ee16714d4 100644 (file)
@@ -1,49 +1,49 @@
 error[E0597]: `young[..]` does not live long enough
-  --> $DIR/borrowck-let-suggestion-suffixes.rs:43:1
+  --> $DIR/borrowck-let-suggestion-suffixes.rs:21:14
    |
 21 |     v2.push(&young[0]);      // statement 4
-   |              -------- borrow occurs here
+   |              ^^^^^^^^ borrowed value does not live long enough
 ...
-43 | }
-   | ^ `young[..]` dropped here while still borrowed
+56 | }
+   | - `young[..]` dropped here while still borrowed
    |
    = note: values in a scope are dropped in the opposite order they are created
 
 error[E0597]: borrowed value does not live long enough
-  --> $DIR/borrowck-let-suggestion-suffixes.rs:25:22
+  --> $DIR/borrowck-let-suggestion-suffixes.rs:28:14
    |
-25 |     v3.push(&id('x'));           // statement 6
-   |              ------- ^ temporary value dropped here while still borrowed
+28 |     v3.push(&id('x'));           // statement 6
+   |              ^^^^^^^ - temporary value dropped here while still borrowed
    |              |
-   |              temporary value created here
+   |              temporary value does not live long enough
 ...
-43 | }
+56 | }
    | - temporary value needs to live until here
    |
    = note: consider using a `let` binding to increase its lifetime
 
 error[E0597]: borrowed value does not live long enough
-  --> $DIR/borrowck-let-suggestion-suffixes.rs:32:26
+  --> $DIR/borrowck-let-suggestion-suffixes.rs:38:18
    |
-32 |         v4.push(&id('y'));
-   |                  ------- ^ temporary value dropped here while still borrowed
+38 |         v4.push(&id('y'));
+   |                  ^^^^^^^ - temporary value dropped here while still borrowed
    |                  |
-   |                  temporary value created here
+   |                  temporary value does not live long enough
 ...
-35 |     }                       // (statement 7)
+44 |     }                       // (statement 7)
    |     - temporary value needs to live until here
    |
    = note: consider using a `let` binding to increase its lifetime
 
 error[E0597]: borrowed value does not live long enough
-  --> $DIR/borrowck-let-suggestion-suffixes.rs:39:22
+  --> $DIR/borrowck-let-suggestion-suffixes.rs:49:14
    |
-39 |     v5.push(&id('z'));
-   |              ------- ^ temporary value dropped here while still borrowed
+49 |     v5.push(&id('z'));
+   |              ^^^^^^^ - temporary value dropped here while still borrowed
    |              |
-   |              temporary value created here
+   |              temporary value does not live long enough
 ...
-43 | }
+56 | }
    | - temporary value needs to live until here
    |
    = note: consider using a `let` binding to increase its lifetime
index aaa5cd415bb0156d0d0fe6a8b168ff6a716eaab2..b2871342e887c60c846b31b122b19a45d4164de0 100644 (file)
@@ -35,6 +35,7 @@ fn mk() -> Box<Trait<'t>+'static> { loop { } }
 pub fn main() {
     let m : Box<Trait+'static> = make_val();
     assert_eq!(object_invoke1(&*m), (4,5));
+    //~^ ERROR `*m` does not live long enough
 
     // the problem here is that the full type of `m` is
     //
@@ -54,5 +55,4 @@ pub fn main() {
     // the type of `m` *strictly outlives* `'m`. Hence we get an
     // error.
 }
-//~^ ERROR `*m` does not live long enough
 
index 5e87534c3911e12b17dc305c46e47919f89536c0..2b760415a1aa2e5e6c23e6ca66444e41668f0c27 100644 (file)
@@ -1,11 +1,11 @@
 error[E0597]: `*m` does not live long enough
-  --> $DIR/dropck-object-cycle.rs:56:1
+  --> $DIR/dropck-object-cycle.rs:37:32
    |
 37 |     assert_eq!(object_invoke1(&*m), (4,5));
-   |                                -- borrow occurs here
+   |                                ^^ borrowed value does not live long enough
 ...
-56 | }
-   | ^ `*m` dropped here while still borrowed
+57 | }
+   | - `*m` dropped here while still borrowed
    |
    = note: values in a scope are dropped in the opposite order they are created
 
index d016e8fdbc086b6e424c885acb012859a9adde73..3eac0106b18c25c3e912dd7654185db71fd1d95e 100644 (file)
@@ -12,5 +12,5 @@ fn main() {
     let p;
     let a = 42;
     p = &a;
+    //~^ ERROR `a` does not live long enough
 }
-//~^ ERROR `a` does not live long enough
index fed240a850d61d67fb88b5c93b6680df988806b3..255700a55f33540fa73090b76dc497cac8cd4508 100644 (file)
@@ -1,10 +1,11 @@
 error[E0597]: `a` does not live long enough
-  --> $DIR/issue-36537.rs:15:1
+  --> $DIR/issue-36537.rs:14:10
    |
 14 |     p = &a;
-   |          - borrow occurs here
-15 | }
-   | ^ `a` dropped here while still borrowed
+   |          ^ borrowed value does not live long enough
+15 |     //~^ ERROR `a` does not live long enough
+16 | }
+   | - `a` dropped here while still borrowed
    |
    = note: values in a scope are dropped in the opposite order they are created
 
index 19f580f51b4f575e6dd3e99e8b66bce6f60e42c6..8e85ca5bceaaa942e1a4e1d5efc3339c26f3e764 100644 (file)
@@ -15,9 +15,9 @@ fn broken() {
     while x < 10 { //~ ERROR cannot use `x` because it was mutably borrowed
         let mut z = x; //~ ERROR cannot use `x` because it was mutably borrowed
         _y.push(&mut z);
+        //~^ ERROR `z` does not live long enough
         x += 1; //~ ERROR cannot assign
     }
-    //~^ ERROR `z` does not live long enough
 }
 
 fn main() { }
index 13614e3106663245518a5a7b98cbbb5e534a4c9b..73ff449b2b532b4e296cf7cc5817ff8bd4b7088f 100644 (file)
@@ -1,12 +1,11 @@
 error[E0597]: `z` does not live long enough
-  --> $DIR/regions-escape-loop-via-vec.rs:19:5
+  --> $DIR/regions-escape-loop-via-vec.rs:17:22
    |
 17 |         _y.push(&mut z);
-   |                      - borrow occurs here
-18 |         x += 1; //~ ERROR cannot assign
-19 |     }
-   |     ^ `z` dropped here while still borrowed
-20 |     //~^ ERROR `z` does not live long enough
+   |                      ^ borrowed value does not live long enough
+...
+20 |     }
+   |     - `z` dropped here while still borrowed
 21 | }
    | - borrowed value needs to live until here
 
@@ -28,12 +27,12 @@ error[E0503]: cannot use `x` because it was mutably borrowed
    |             ^^^^^ use of borrowed `x`
 
 error[E0506]: cannot assign to `x` because it is borrowed
-  --> $DIR/regions-escape-loop-via-vec.rs:18:9
+  --> $DIR/regions-escape-loop-via-vec.rs:19:9
    |
 14 |     let mut _y = vec![&mut x];
    |                            - borrow of `x` occurs here
 ...
-18 |         x += 1; //~ ERROR cannot assign
+19 |         x += 1; //~ ERROR cannot assign
    |         ^^^^^^ assignment to borrowed `x` occurs here
 
 error: aborting due to 4 previous errors