]>
git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/borrowck-lend-flow-if.rs
0efe8622621785c0e762210c11463bd3b51db05c
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.
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.
11 // Note: the borrowck analysis is currently flow-insensitive.
12 // Therefore, some of these errors are marked as spurious and could be
13 // corrected by a simple change to the analysis. The others are
14 // either genuine or would require more advanced changes. The latter
17 #![feature(box_syntax)]
19 fn borrow(_v
: &isize) {}
20 fn borrow_mut(_v
: &mut isize) {}
21 fn cond() -> bool { panic!() }
22 fn for_func
<F
>(_f
: F
) where F
: FnOnce() -> bool { panic!() }
23 fn produce
<T
>() -> T { panic!(); }
25 fn inc(v
: &mut Box
<isize>) {
29 fn pre_freeze_cond() {
30 // In this instance, the freeze is conditional and starts before
33 let mut v
: Box
<_
> = box 3;
38 borrow_mut(&mut *v
); //~ ERROR cannot borrow
41 fn pre_freeze_else() {
42 // In this instance, the freeze and mut borrow are on separate sides
45 let mut v
: Box
<_
> = box 3;