about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/issue-18937.rs1
-rw-r--r--src/test/mir-opt/nll/named-lifetimes-basic.rs10
-rw-r--r--src/test/mir-opt/nll/reborrow-basic.rs8
-rw-r--r--src/test/mir-opt/nll/region-liveness-basic.rs6
-rw-r--r--src/test/mir-opt/nll/region-liveness-drop-may-dangle.rs2
-rw-r--r--src/test/mir-opt/nll/region-liveness-drop-no-may-dangle.rs2
-rw-r--r--src/test/mir-opt/nll/region-liveness-two-disjoint-uses.rs12
-rw-r--r--src/test/mir-opt/nll/region-subtyping-basic.rs10
-rw-r--r--src/test/run-pass/implied-bounds-closure-arg-outlives.rs44
-rw-r--r--src/test/run-pass/regions-relate-bound-regions-on-closures-to-inference-variables.rs2
-rw-r--r--src/test/ui/compare-method/proj-outlives-region.stderr6
-rw-r--r--src/test/ui/compare-method/region-unrelated.stderr6
-rw-r--r--src/test/ui/nll/get_default.rs53
-rw-r--r--src/test/ui/nll/get_default.stderr47
14 files changed, 172 insertions, 37 deletions
diff --git a/src/test/compile-fail/issue-18937.rs b/src/test/compile-fail/issue-18937.rs
index 5996c8e5438..f7f84e6452d 100644
--- a/src/test/compile-fail/issue-18937.rs
+++ b/src/test/compile-fail/issue-18937.rs
@@ -27,7 +27,6 @@ trait A<'a> {
 
 impl<'a> A<'a> for B {
     fn foo<F>(&mut self, f: F) //~ ERROR impl has stricter
-        //~^ WARNING future release
         where F: fmt::Debug + 'static,
     {
         self.list.push(Box::new(f));
diff --git a/src/test/mir-opt/nll/named-lifetimes-basic.rs b/src/test/mir-opt/nll/named-lifetimes-basic.rs
index e3f67d817f3..34d0482a623 100644
--- a/src/test/mir-opt/nll/named-lifetimes-basic.rs
+++ b/src/test/mir-opt/nll/named-lifetimes-basic.rs
@@ -26,9 +26,9 @@ fn main() {
 
 // END RUST SOURCE
 // START rustc.use_x.nll.0.mir
-// | '_#0r: {bb0[0], bb0[1], '_#0r}
-// | '_#1r: {bb0[0], bb0[1], '_#0r, '_#1r}
-// | '_#2r: {bb0[0], bb0[1], '_#2r}
-// ...
-// fn use_x(_1: &'_#0r mut i32, _2: &'_#1r u32, _3: &'_#0r u32, _4: &'_#2r u32) -> bool {
+// | '_#0r: {bb0[0], bb0[1], '_#0r, '_#1r, '_#2r, '_#3r}
+// | '_#1r: {bb0[0], bb0[1], '_#1r}
+// | '_#2r: {bb0[0], bb0[1], '_#1r, '_#2r}
+// | '_#3r: {bb0[0], bb0[1], '_#3r}
+// fn use_x(_1: &'_#1r mut i32, _2: &'_#2r u32, _3: &'_#1r u32, _4: &'_#3r u32) -> bool {
 // END rustc.use_x.nll.0.mir
diff --git a/src/test/mir-opt/nll/reborrow-basic.rs b/src/test/mir-opt/nll/reborrow-basic.rs
index c3df0c840de..f51e839e4fc 100644
--- a/src/test/mir-opt/nll/reborrow-basic.rs
+++ b/src/test/mir-opt/nll/reborrow-basic.rs
@@ -28,12 +28,12 @@ fn main() {
 
 // END RUST SOURCE
 // START rustc.main.nll.0.mir
-// | '_#5r: {bb0[6], bb0[7], bb0[8], bb0[9], bb0[10], bb0[11], bb0[12], bb0[13], bb0[14]}
+// | '_#6r: {bb0[6], bb0[7], bb0[8], bb0[9], bb0[10], bb0[11], bb0[12], bb0[13], bb0[14]}
 // ...
-// | '_#7r: {bb0[11], bb0[12], bb0[13], bb0[14]}
+// | '_#8r: {bb0[11], bb0[12], bb0[13], bb0[14]}
 // END rustc.main.nll.0.mir
 // START rustc.main.nll.0.mir
-// let _2: &'_#5r mut i32;
+// let _2: &'_#6r mut i32;
 // ...
-// let _4: &'_#7r mut i32;
+// let _4: &'_#8r mut i32;
 // END rustc.main.nll.0.mir
diff --git a/src/test/mir-opt/nll/region-liveness-basic.rs b/src/test/mir-opt/nll/region-liveness-basic.rs
index f7276cb2979..ae059febc71 100644
--- a/src/test/mir-opt/nll/region-liveness-basic.rs
+++ b/src/test/mir-opt/nll/region-liveness-basic.rs
@@ -31,15 +31,15 @@ fn main() {
 
 // END RUST SOURCE
 // START rustc.main.nll.0.mir
-// | '_#0r: {bb1[1], bb2[0], bb2[1]}
 // | '_#1r: {bb1[1], bb2[0], bb2[1]}
+// | '_#2r: {bb1[1], bb2[0], bb2[1]}
 // ...
-//             let _2: &'_#1r usize;
+//             let _2: &'_#2r usize;
 // END rustc.main.nll.0.mir
 // START rustc.main.nll.0.mir
 //    bb1: {
 //            | Live variables at bb1[0]: [_1, _3]
-//        _2 = &'_#0r _1[_3];
+//        _2 = &'_#1r _1[_3];
 //            | Live variables at bb1[1]: [_2]
 //        switchInt(const true) -> [0u8: bb3, otherwise: bb2];
 //    }
diff --git a/src/test/mir-opt/nll/region-liveness-drop-may-dangle.rs b/src/test/mir-opt/nll/region-liveness-drop-may-dangle.rs
index 6527df26eae..6d7aa0a26c8 100644
--- a/src/test/mir-opt/nll/region-liveness-drop-may-dangle.rs
+++ b/src/test/mir-opt/nll/region-liveness-drop-may-dangle.rs
@@ -44,5 +44,5 @@ unsafe impl<#[may_dangle] T> Drop for Wrap<T> {
 
 // END RUST SOURCE
 // START rustc.main.nll.0.mir
-// | '_#4r: {bb1[3], bb1[4], bb1[5], bb2[0], bb2[1]}
+// | '_#5r: {bb1[3], bb1[4], bb1[5], bb2[0], bb2[1]}
 // END rustc.main.nll.0.mir
diff --git a/src/test/mir-opt/nll/region-liveness-drop-no-may-dangle.rs b/src/test/mir-opt/nll/region-liveness-drop-no-may-dangle.rs
index aedb3f562a6..2968ae7d485 100644
--- a/src/test/mir-opt/nll/region-liveness-drop-no-may-dangle.rs
+++ b/src/test/mir-opt/nll/region-liveness-drop-no-may-dangle.rs
@@ -46,5 +46,5 @@ impl<T> Drop for Wrap<T> {
 
 // END RUST SOURCE
 // START rustc.main.nll.0.mir
-// | '_#4r: {bb1[3], bb1[4], bb1[5], bb2[0], bb2[1], bb2[2], bb3[0], bb3[1], bb3[2], bb4[0], bb4[1], bb4[2], bb6[0], bb7[0], bb7[1], bb7[2], bb8[0]}
+// | '_#5r: {bb1[3], bb1[4], bb1[5], bb2[0], bb2[1], bb2[2], bb3[0], bb3[1], bb3[2], bb4[0], bb4[1], bb4[2], bb6[0], bb7[0], bb7[1], bb7[2], bb8[0]}
 // END rustc.main.nll.0.mir
diff --git a/src/test/mir-opt/nll/region-liveness-two-disjoint-uses.rs b/src/test/mir-opt/nll/region-liveness-two-disjoint-uses.rs
index 23809d176f6..736d2902ec6 100644
--- a/src/test/mir-opt/nll/region-liveness-two-disjoint-uses.rs
+++ b/src/test/mir-opt/nll/region-liveness-two-disjoint-uses.rs
@@ -36,14 +36,14 @@ fn main() {
 
 // END RUST SOURCE
 // START rustc.main.nll.0.mir
-// | '_#0r: {bb1[1], bb2[0], bb2[1]}
+// | '_#1r: {bb1[1], bb2[0], bb2[1]}
 // ...
-// | '_#2r: {bb7[2], bb7[3], bb7[4]}
-// | '_#3r: {bb1[1], bb2[0], bb2[1], bb7[2], bb7[3], bb7[4]}
+// | '_#3r: {bb7[2], bb7[3], bb7[4]}
+// | '_#4r: {bb1[1], bb2[0], bb2[1], bb7[2], bb7[3], bb7[4]}
 // ...
-// let mut _2: &'_#3r usize;
+// let mut _2: &'_#4r usize;
 // ...
-// _2 = &'_#0r _1[_3];
+// _2 = &'_#1r _1[_3];
 // ...
-// _2 = &'_#2r (*_11);
+// _2 = &'_#3r (*_11);
 // END rustc.main.nll.0.mir
diff --git a/src/test/mir-opt/nll/region-subtyping-basic.rs b/src/test/mir-opt/nll/region-subtyping-basic.rs
index cada9c7b254..fb178b46b47 100644
--- a/src/test/mir-opt/nll/region-subtyping-basic.rs
+++ b/src/test/mir-opt/nll/region-subtyping-basic.rs
@@ -32,16 +32,16 @@ fn main() {
 
 // END RUST SOURCE
 // START rustc.main.nll.0.mir
-// | '_#0r: {bb1[1], bb1[2], bb1[3], bb1[4], bb1[5], bb1[6], bb2[0], bb2[1]}
 // | '_#1r: {bb1[1], bb1[2], bb1[3], bb1[4], bb1[5], bb1[6], bb2[0], bb2[1]}
-// | '_#2r: {bb1[5], bb1[6], bb2[0], bb2[1]}
+// | '_#2r: {bb1[1], bb1[2], bb1[3], bb1[4], bb1[5], bb1[6], bb2[0], bb2[1]}
+// | '_#3r: {bb1[5], bb1[6], bb2[0], bb2[1]}
 // END rustc.main.nll.0.mir
 // START rustc.main.nll.0.mir
-// let _2: &'_#1r usize;
+// let _2: &'_#2r usize;
 // ...
-// let _6: &'_#2r usize;
+// let _6: &'_#3r usize;
 // ...
-// _2 = &'_#0r _1[_3];
+// _2 = &'_#1r _1[_3];
 // ...
 // _7 = _2;
 // ...
diff --git a/src/test/run-pass/implied-bounds-closure-arg-outlives.rs b/src/test/run-pass/implied-bounds-closure-arg-outlives.rs
new file mode 100644
index 00000000000..0e5cc574f00
--- /dev/null
+++ b/src/test/run-pass/implied-bounds-closure-arg-outlives.rs
@@ -0,0 +1,44 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test that we are able to handle the relationships between free
+// regions bound in a closure callback.
+
+#[derive(Copy, Clone)]
+struct MyCx<'short, 'long: 'short> {
+    short: &'short u32,
+    long: &'long u32,
+}
+
+impl<'short, 'long> MyCx<'short, 'long> {
+    fn short(self) -> &'short u32 { self.short }
+    fn long(self) -> &'long u32 { self.long }
+    fn set_short(&mut self, v: &'short u32) { self.short = v; }
+}
+
+fn with<F, R>(op: F) -> R
+where
+    F: for<'short, 'long> FnOnce(MyCx<'short, 'long>) -> R,
+{
+    op(MyCx {
+        short: &22,
+        long: &22,
+    })
+}
+
+fn main() {
+    with(|mut cx| {
+        // For this to type-check, we need to be able to deduce that
+        // the lifetime of `l` can be `'short`, even though it has
+        // input from `'long`.
+        let l = if true { cx.long() } else { cx.short() };
+        cx.set_short(l);
+    });
+}
diff --git a/src/test/run-pass/regions-relate-bound-regions-on-closures-to-inference-variables.rs b/src/test/run-pass/regions-relate-bound-regions-on-closures-to-inference-variables.rs
index ae4adbfb1f4..3162ef54f39 100644
--- a/src/test/run-pass/regions-relate-bound-regions-on-closures-to-inference-variables.rs
+++ b/src/test/run-pass/regions-relate-bound-regions-on-closures-to-inference-variables.rs
@@ -42,7 +42,7 @@ impl<'a,'tcx> Foo<'a,'tcx> {
             // inferring `'_2` to be `'static` in this case, because
             // it is created outside the closure but then related to
             // regions bound by the closure itself. See the
-            // `region_inference.rs` file (and the `givens` field, in
+            // `region_constraints.rs` file (and the `givens` field, in
             // particular) for more details.
             this.foo()
         }))
diff --git a/src/test/ui/compare-method/proj-outlives-region.stderr b/src/test/ui/compare-method/proj-outlives-region.stderr
index e58251c846f..f871f034a92 100644
--- a/src/test/ui/compare-method/proj-outlives-region.stderr
+++ b/src/test/ui/compare-method/proj-outlives-region.stderr
@@ -1,4 +1,4 @@
-error: impl has stricter requirements than trait
+error[E0276]: impl has stricter requirements than trait
   --> $DIR/proj-outlives-region.rs:19:5
    |
 14 |     fn foo() where T: 'a;
@@ -6,10 +6,6 @@ error: impl has stricter requirements than trait
 ...
 19 |     fn foo() where U: 'a { } //~ ERROR E0276
    |     ^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `U: 'a`
-   |
-   = note: #[deny(extra_requirement_in_impl)] on by default
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-   = note: for more information, see issue #37166 <https://github.com/rust-lang/rust/issues/37166>
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/compare-method/region-unrelated.stderr b/src/test/ui/compare-method/region-unrelated.stderr
index 95db68fea5c..1df83c7fb0c 100644
--- a/src/test/ui/compare-method/region-unrelated.stderr
+++ b/src/test/ui/compare-method/region-unrelated.stderr
@@ -1,4 +1,4 @@
-error: impl has stricter requirements than trait
+error[E0276]: impl has stricter requirements than trait
   --> $DIR/region-unrelated.rs:19:5
    |
 14 |     fn foo() where T: 'a;
@@ -6,10 +6,6 @@ error: impl has stricter requirements than trait
 ...
 19 |     fn foo() where V: 'a { }
    |     ^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `V: 'a`
-   |
-   = note: #[deny(extra_requirement_in_impl)] on by default
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-   = note: for more information, see issue #37166 <https://github.com/rust-lang/rust/issues/37166>
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/nll/get_default.rs b/src/test/ui/nll/get_default.rs
new file mode 100644
index 00000000000..5605206221a
--- /dev/null
+++ b/src/test/ui/nll/get_default.rs
@@ -0,0 +1,53 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Basic test for free regions in the NLL code. This test ought to
+// report an error due to a reborrowing constraint. Right now, we get
+// a variety of errors from the older, AST-based machinery (notably
+// borrowck), and then we get the NLL error at the end.
+
+// compile-flags:-Znll -Zborrowck-mir
+
+struct Map {
+}
+
+impl Map {
+    fn get(&self) -> Option<&String> { None }
+    fn set(&mut self, v: String) { }
+}
+
+fn ok(map: &mut Map) -> &String {
+    loop {
+        match map.get() {
+            Some(v) => {
+                return v;
+            }
+            None => {
+                map.set(String::new()); // Just AST errors here
+            }
+        }
+    }
+}
+
+fn err(map: &mut Map) -> &String {
+    loop {
+        match map.get() {
+            Some(v) => {
+                map.set(String::new()); // Both AST and MIR error here
+                return v;
+            }
+            None => {
+                map.set(String::new()); // Just AST errors here
+            }
+        }
+    }
+}
+
+fn main() { }
diff --git a/src/test/ui/nll/get_default.stderr b/src/test/ui/nll/get_default.stderr
new file mode 100644
index 00000000000..9586f426720
--- /dev/null
+++ b/src/test/ui/nll/get_default.stderr
@@ -0,0 +1,47 @@
+error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Ast)
+  --> $DIR/get_default.rs:33:17
+   |
+28 |         match map.get() {
+   |               --- immutable borrow occurs here
+...
+33 |                 map.set(String::new()); // Just AST errors here
+   |                 ^^^ mutable borrow occurs here
+...
+37 | }
+   | - immutable borrow ends here
+
+error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Ast)
+  --> $DIR/get_default.rs:43:17
+   |
+41 |         match map.get() {
+   |               --- immutable borrow occurs here
+42 |             Some(v) => {
+43 |                 map.set(String::new()); // Both AST and MIR error here
+   |                 ^^^ mutable borrow occurs here
+...
+51 | }
+   | - immutable borrow ends here
+
+error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Ast)
+  --> $DIR/get_default.rs:47:17
+   |
+41 |         match map.get() {
+   |               --- immutable borrow occurs here
+...
+47 |                 map.set(String::new()); // Just AST errors here
+   |                 ^^^ mutable borrow occurs here
+...
+51 | }
+   | - immutable borrow ends here
+
+error[E0502]: cannot borrow `(*map)` as mutable because it is also borrowed as immutable (Mir)
+  --> $DIR/get_default.rs:43:17
+   |
+41 |         match map.get() {
+   |               --- immutable borrow occurs here
+42 |             Some(v) => {
+43 |                 map.set(String::new()); // Both AST and MIR error here
+   |                 ^^^ mutable borrow occurs here
+
+error: aborting due to 4 previous errors
+