]> git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/nll/loan_ends_mid_block_vec.rs
New upstream version 1.23.0+dfsg1
[rustc.git] / src / test / compile-fail / nll / loan_ends_mid_block_vec.rs
1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11
12 // compile-flags:-Zborrowck-mir -Znll
13
14 #![allow(warnings)]
15 #![feature(rustc_attrs)]
16
17 fn main() {
18 }
19
20 fn nll_fail() {
21 let mut data = vec!['a', 'b', 'c'];
22 let slice = &mut data;
23 capitalize(slice);
24 data.push('d');
25 //~^ ERROR (Ast) [E0499]
26 //~| ERROR (Mir) [E0499]
27 data.push('e');
28 //~^ ERROR (Ast) [E0499]
29 //~| ERROR (Mir) [E0499]
30 data.push('f');
31 //~^ ERROR (Ast) [E0499]
32 //~| ERROR (Mir) [E0499]
33 capitalize(slice);
34 }
35
36 fn nll_ok() {
37 let mut data = vec!['a', 'b', 'c'];
38 let slice = &mut data;
39 capitalize(slice);
40 data.push('d');
41 //~^ ERROR (Ast) [E0499]
42 data.push('e');
43 //~^ ERROR (Ast) [E0499]
44 data.push('f');
45 //~^ ERROR (Ast) [E0499]
46 }
47
48 fn capitalize(_: &mut [char]) {
49 }