summaryrefslogtreecommitdiffstats
path: root/src/test/ui/span/slice-borrow.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/span/slice-borrow.rs')
-rw-r--r--src/test/ui/span/slice-borrow.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/test/ui/span/slice-borrow.rs b/src/test/ui/span/slice-borrow.rs
new file mode 100644
index 000000000..38cd7acbd
--- /dev/null
+++ b/src/test/ui/span/slice-borrow.rs
@@ -0,0 +1,14 @@
+// Test slicing expressions doesn't defeat the borrow checker.
+
+fn main() {
+ let y;
+ {
+ let x: &[isize] = &vec![1, 2, 3, 4, 5];
+ //~^ ERROR temporary value dropped while borrowed
+ y = &x[1..];
+ }
+ y.use_ref();
+}
+
+trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
+impl<T> Fake for T { }