1 // Copyright 2012-2014 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 // ignore-pretty -- comments are unfaithfully preserved
13 #![allow(unused_variable)]
14 #![allow(dead_assignment)]
16 fn cond() -> bool { fail!() }
17 fn link<'a>(v: &'a uint, w: &mut &'a uint) -> bool { *w = v; true }
20 // Here both arms perform assignments, but only is illegal.
25 // It is ok to reassign x here, because there is in
26 // fact no outstanding loan of x!
30 x = Some(1); //~ ERROR cannot assign
33 x.clone(); // just to prevent liveness warnings
37 // Here the guard performs a borrow. This borrow "infects" all
38 // subsequent arms (but not the prior ones).
48 _ if link(&*b, &mut w) => {
49 b = box 6; //~ ERROR cannot assign
53 b = box 7; //~ ERROR cannot assign
57 b = box 8; //~ ERROR cannot assign