2014-09-15 03:48:58 -05:00
|
|
|
// Test slicing expressions doesn't defeat the borrow checker.
|
|
|
|
|
2018-05-25 05:36:58 -05:00
|
|
|
fn main() {
|
2014-09-15 03:48:58 -05:00
|
|
|
let y;
|
|
|
|
{
|
2017-08-13 03:46:49 -05:00
|
|
|
let x: &[isize] = &vec![1, 2, 3, 4, 5];
|
2019-04-22 02:40:08 -05:00
|
|
|
//~^ ERROR temporary value dropped while borrowed
|
2015-01-02 18:34:13 -06:00
|
|
|
y = &x[1..];
|
2017-12-13 19:27:23 -06:00
|
|
|
}
|
2018-05-25 05:36:58 -05:00
|
|
|
y.use_ref();
|
2014-09-15 03:48:58 -05:00
|
|
|
}
|
2018-05-25 05:36:58 -05:00
|
|
|
|
|
|
|
trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
|
|
|
|
impl<T> Fake for T { }
|