about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorSantiago Pastorino <spastorino@gmail.com>2017-11-28 00:39:38 -0300
committerNiko Matsakis <niko@alum.mit.edu>2017-12-13 06:03:25 -0500
commitd6772cb972a5ca531ecbe45ad779bafe33895caa (patch)
tree5f93ddf8a01a779230788b46c7172278d54055f0 /src/test
parentdcf3db47c7382d0540a81f01bd0915f5c7a6e411 (diff)
downloadrust-d6772cb972a5ca531ecbe45ad779bafe33895caa.tar.gz
rust-d6772cb972a5ca531ecbe45ad779bafe33895caa.zip
Check Repeat Rvalue
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/nll/where_clauses_in_repeat_rvalue.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/test/compile-fail/nll/where_clauses_in_repeat_rvalue.rs b/src/test/compile-fail/nll/where_clauses_in_repeat_rvalue.rs
new file mode 100644
index 00000000000..aae0cd3fdb0
--- /dev/null
+++ b/src/test/compile-fail/nll/where_clauses_in_repeat_rvalue.rs
@@ -0,0 +1,39 @@
+// Copyright 2017 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.
+
+// compile-flags: -Z borrowck=mir -Z nll
+
+#![allow(warnings)]
+
+struct Foo<T> {
+    t: T,
+}
+
+impl<T: 'static + Copy> Copy for Foo<T> {}
+impl<T: 'static + Copy> Clone for Foo<T> {
+    fn clone(&self) -> Self {
+        *self
+    }
+}
+
+fn main() {
+    let mut x = 22;
+
+    {
+        let p = &x; //~ ERROR borrowed value does not live long enough
+        let w = Foo { t: p };
+
+        let v = [w; 22];
+    }
+
+    x += 1;
+    //~^ ERROR cannot assign to `x` because it is borrowed [E0506]
+}
+//~^ ERROR borrowed value does not live long enough [E0597]