]> git.lizzy.rs Git - rust.git/blob - src/test/ui/mut/mut-suggestion.rs
0015c8e5c00a1212731754a71b73af892d25d0e2
[rust.git] / src / test / ui / mut / mut-suggestion.rs
1 // Copyright 2015 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 #[derive(Copy, Clone)]
12 struct S;
13
14 impl S {
15     fn mutate(&mut self) {
16     }
17 }
18
19 fn func(arg: S) {
20     //~^ consider changing this to `mut arg`
21     arg.mutate();
22     //~^ ERROR cannot borrow immutable argument
23     //~| cannot borrow mutably
24 }
25
26 fn main() {
27     let local = S;
28     //~^ consider changing this to `mut local`
29     local.mutate();
30     //~^ ERROR cannot borrow immutable local variable
31     //~| cannot borrow mutably
32 }