rust/src/test/ui/span/slice-borrow.rs
2018-12-25 21:08:33 -07:00

14 lines
335 B
Rust

// Test slicing expressions doesn't defeat the borrow checker.
fn main() {
let y;
{
let x: &[isize] = &vec![1, 2, 3, 4, 5];
//~^ ERROR borrowed value does not live long enough
y = &x[1..];
}
y.use_ref();
}
trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
impl<T> Fake for T { }