summaryrefslogtreecommitdiffstats
path: root/tests/ui/span/slice-borrow.rs
blob: 38cd7acbdfa131ea1e493684b9f1fea1111f6818 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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 { }