]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/issue-51191.rs
87ec3e5df0b81b7b9ade8464a296934d28559158
[rust.git] / src / test / ui / nll / issue-51191.rs
1 // Copyright 2016 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 #![feature(nll)]
12
13 struct Struct;
14
15 impl Struct {
16     fn bar(self: &mut Self) {
17         (&mut self).bar();
18         //~^ ERROR cannot borrow `self` as mutable, as it is not declared as mutable [E0596]
19     }
20
21     fn imm(self) {
22         (&mut self).bar();
23         //~^ ERROR cannot borrow `self` as mutable, as it is not declared as mutable [E0596]
24     }
25
26     fn mtbl(mut self) {
27         (&mut self).bar();
28     }
29
30     fn immref(&self) {
31         (&mut self).bar();
32         //~^ ERROR cannot borrow `self` as mutable, as it is not declared as mutable [E0596]
33         //~^^ ERROR cannot borrow data in a `&` reference as mutable [E0596]
34     }
35
36     fn mtblref(&mut self) {
37         (&mut self).bar();
38         //~^ ERROR cannot borrow `self` as mutable, as it is not declared as mutable [E0596]
39     }
40 }
41
42 fn main () {}