]> git.lizzy.rs Git - rust.git/commitdiff
Update ui/generator tests to reflect changes from new generator drop rules.
authorFelix S. Klock II <pnkfelix@pnkfx.org>
Mon, 16 Apr 2018 10:41:32 +0000 (12:41 +0200)
committerFelix S. Klock II <pnkfelix@pnkfx.org>
Tue, 1 May 2018 20:28:54 +0000 (22:28 +0200)
src/test/ui/generator/borrowing.nll.stderr
src/test/ui/generator/borrowing.rs
src/test/ui/generator/dropck.nll.stderr
src/test/ui/generator/dropck.rs
src/test/ui/generator/dropck.stderr
src/test/ui/generator/ref-escapes-but-not-over-yield.nll.stderr

index 1801da6c8b2ddf73720c50a74235335089d80fa2..243e9018585138442786b9830af0e71b0b978069 100644 (file)
@@ -1,14 +1,30 @@
-error: compilation successful
-  --> $DIR/borrowing.rs:15:1
+error[E0597]: `a` does not live long enough
+  --> $DIR/borrowing.rs:18:18
    |
-LL | / fn main() { #![rustc_error] // rust-lang/rust#49855
-LL | |     let _b = {
-LL | |         let a = 3;
-LL | |         unsafe { (|| yield &a).resume() }
-...  |
-LL | |     };
-LL | | }
-   | |_^
+LL |         unsafe { (|| yield &a).resume() }
+   |                  ^^^^^^^^^^^^^
+   |                  |
+   |                  borrowed value does not live long enough
+   |                  borrow may end up in a temporary, created here
+LL |         //~^ ERROR: `a` does not live long enough
+LL |     };
+   |     -- temporary later dropped here, potentially using the reference
+   |     |
+   |     borrowed value only lives until here
 
-error: aborting due to previous error
+error[E0597]: `a` does not live long enough
+  --> $DIR/borrowing.rs:24:9
+   |
+LL | /         || {
+LL | |             yield &a
+LL | |             //~^ ERROR: `a` does not live long enough
+LL | |         }
+   | |_________^ borrowed value does not live long enough
+LL |       };
+   |       - borrowed value only lives until here
+LL |   }
+   |   - borrow later used here, when `_b` is dropped
+
+error: aborting due to 2 previous errors
 
+For more information about this error, try `rustc --explain E0597`.
index f80aca9fb00e6c357b73554d5c7f69411bf9b152..e56927d81823131b1e38e66cbff0394b743489fe 100644 (file)
@@ -8,11 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![feature(generators, generator_trait, rustc_attrs)]
+#![feature(generators, generator_trait)]
 
 use std::ops::Generator;
 
-fn main() { #![rustc_error] // rust-lang/rust#49855
+fn main() {
     let _b = {
         let a = 3;
         unsafe { (|| yield &a).resume() }
index 72ebaab32789825674c71e21fbf6975a5a0f7ec4..c352fd6a62f28522f2fa1763579479dd94926b83 100644 (file)
@@ -1,14 +1,20 @@
-error: compilation successful
-  --> $DIR/dropck.rs:16:1
+error[E0597]: `ref_` does not live long enough
+  --> $DIR/dropck.rs:22:11
    |
-LL | / fn main() { #![rustc_error] // rust-lang/rust#49855
-LL | |     let (cell, mut gen);
-LL | |     cell = Box::new(RefCell::new(0));
-LL | |     let ref_ = Box::leak(Box::new(Some(cell.borrow_mut())));
-...  |
-LL | |     // drops the RefCell and then the Ref, leading to use-after-free
-LL | | }
-   | |_^
+LL |       gen = || {
+   |  ___________^
+LL | |         // but the generator can use it to drop a `Ref<'a, i32>`.
+LL | |         let _d = ref_.take(); //~ ERROR `ref_` does not live long enough
+LL | |         yield;
+LL | |     };
+   | |_____^ borrowed value does not live long enough
+...
+LL |   }
+   |   -
+   |   |
+   |   borrowed value only lives until here
+   |   borrow later used here, when `gen` is dropped
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0597`.
index 8f4ba64fd57276fc4a121b4d0c203d1e724173a9..857288818c67c5e0f80a7bef0b77b0a80d8eef84 100644 (file)
@@ -8,15 +8,16 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![feature(generators, generator_trait, box_leak, rustc_attrs)]
+#![feature(generators, generator_trait, box_leak)]
 
 use std::cell::RefCell;
 use std::ops::Generator;
 
-fn main() { #![rustc_error] // rust-lang/rust#49855
+fn main() {
     let (cell, mut gen);
     cell = Box::new(RefCell::new(0));
     let ref_ = Box::leak(Box::new(Some(cell.borrow_mut())));
+    //~^ ERROR `*cell` does not live long enough [E0597]
     // the upvar is the non-dropck `&mut Option<Ref<'a, i32>>`.
     gen = || {
         // but the generator can use it to drop a `Ref<'a, i32>`.
index 4a22d299701b496e9255d6fa786019d067c35aad..1a6fed2dd35944d0947eccee78ad7145e3b38a5e 100644 (file)
@@ -1,5 +1,16 @@
+error[E0597]: `*cell` does not live long enough
+  --> $DIR/dropck.rs:19:40
+   |
+LL |     let ref_ = Box::leak(Box::new(Some(cell.borrow_mut())));
+   |                                        ^^^^ borrowed value does not live long enough
+...
+LL | }
+   | - `*cell` dropped here while still borrowed
+   |
+   = note: values in a scope are dropped in the opposite order they are created
+
 error[E0597]: `ref_` does not live long enough
-  --> $DIR/dropck.rs:23:18
+  --> $DIR/dropck.rs:24:18
    |
 LL |     gen = || {
    |           -- capture occurs here
@@ -12,6 +23,6 @@ LL | }
    |
    = note: values in a scope are dropped in the opposite order they are created
 
-error: aborting due to previous error
+error: aborting due to 2 previous errors
 
 For more information about this error, try `rustc --explain E0597`.
index 08839c23c37622261aa1cb76e3a157e323af6534..70870b98365b9d1a1cb11fe0dd41f726273d5222 100644 (file)
@@ -1,11 +1,19 @@
 error[E0597]: `b` does not live long enough
   --> $DIR/ref-escapes-but-not-over-yield.rs:24:13
    |
-LL |         a = &b;
-   |             ^^ borrowed value does not live long enough
-LL |         //~^ ERROR `b` does not live long enough
-LL |     };
-   |     - borrowed value only lives until here
+LL |       let mut b = move || {
+   |  _________________-
+LL | |         yield();
+LL | |         let b = 5;
+LL | |         a = &b;
+   | |             ^^ borrowed value does not live long enough
+LL | |         //~^ ERROR `b` does not live long enough
+LL | |     };
+   | |     -
+   | |     |
+   | |     borrowed value only lives until here
+   | |_____temporary later dropped here, potentially using the reference
+   |       borrow may end up in a temporary, created here
 
 error: aborting due to previous error