]> git.lizzy.rs Git - rust.git/blob - src/test/ui/mut/mut-suggestion.rs
use structured suggestion for "missing mut" label
[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     //~^ HELP make this binding mutable
21     //~| SUGGESTION mut arg
22     arg.mutate();
23     //~^ ERROR cannot borrow immutable argument
24     //~| cannot borrow mutably
25 }
26
27 fn main() {
28     let local = S;
29     //~^ HELP make this binding mutable
30     //~| SUGGESTION mut local
31     local.mutate();
32     //~^ ERROR cannot borrow immutable local variable
33     //~| cannot borrow mutably
34 }