rust/tests/ui/array-slice-vec/vec-matching-legal-tail-element-borrow.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

16 lines
304 B
Rust
Raw Normal View History

//@ run-pass
2019-12-30 00:23:42 +00:00
#![allow(unused_variables)]
pub fn main() {
2015-01-25 21:05:03 +00:00
let x = &[1, 2, 3, 4, 5];
let x: &[isize] = &[1, 2, 3, 4, 5];
2012-12-15 23:13:55 +00:00
if !x.is_empty() {
let el = match x {
2019-07-07 23:47:46 +00:00
&[1, ref tail @ ..] => &tail[0],
_ => unreachable!()
2012-12-15 23:13:55 +00:00
};
println!("{}", *el);
2012-12-15 23:13:55 +00:00
}
}