rust/src/test/ui/span/slice-borrow.rs

20 lines
673 B
Rust
Raw Normal View History

// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test slicing expressions doesn't defeat the borrow checker.
fn main() {
let y;
{
2017-08-13 08:46:49 +00:00
let x: &[isize] = &vec![1, 2, 3, 4, 5];
2015-01-03 00:34:13 +00:00
y = &x[1..];
2017-11-20 12:13:27 +00:00
} //~ ERROR does not live long enough
}