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