1 // Copyright 2018 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 // check that existing borrows due to a closure capture give a special note
15 fn move_while_borrowed(x: String) {
21 fn borrow_mut_while_borrowed(mut x: i32) {
23 let y = &mut x; //~ ERROR
27 fn drop_while_borrowed() {
36 fn assign_while_borrowed(mut x: i32) {
42 fn copy_while_borrowed_mut(mut x: i32) {
48 fn borrow_while_borrowed_mut(mut x: i32) {
54 fn borrow_mut_while_borrowed_mut(mut x: i32) {
56 let y = &mut x; //~ ERROR
60 fn drop_while_borrowed_mut() {
64 f = || x = 0; //~ ERROR
69 fn assign_while_borrowed_mut(mut x: i32) {
75 fn copy_while_borrowed_unique(x: &mut i32) {
81 fn borrow_while_borrowed_unique(x: &mut i32) {
87 fn borrow_mut_while_borrowed_unique(mut x: &mut i32) {
89 let y = &mut x; //~ ERROR
93 fn drop_while_borrowed_unique() {
98 f = || *x = 0; //~ ERROR
103 fn assign_while_borrowed_unique(x: &mut i32) {
111 trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
112 impl<T> Fake for T { }