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 // Test that assignments to an `&mut` pointer which is found in a
12 // borrowed (but otherwise non-aliasable) location is illegal.
14 // compile-flags: -Z emit-end-regions -Z borrowck=compare -C overflow-checks=on
17 pointer: &'a mut isize
20 fn copy_borrowed_ptr<'a>(p: &'a mut S<'a>) -> S<'a> {
21 S { pointer: &mut *p.pointer }
28 let mut y = S { pointer: &mut x };
29 let z = copy_borrowed_ptr(&mut y);
31 //~^ ERROR cannot assign to `*y.pointer` because it is borrowed (Ast) [E0506]
32 //~| ERROR cannot use `*y.pointer` because it was mutably borrowed (Mir) [E0503]