mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 22:41:50 +00:00
29 lines
629 B
Rust
29 lines
629 B
Rust
//run-rustfix
|
|
#![allow(unused)]
|
|
|
|
struct S;
|
|
impl S {
|
|
fn foo(&mut self) {
|
|
let x = |this: &Self, v: i32| {
|
|
this.bar();
|
|
this.hel();
|
|
};
|
|
self.qux(); //~ ERROR cannot borrow `*self` as mutable because it is also borrowed as immutable
|
|
x(self, 1);
|
|
x(self, 3);
|
|
}
|
|
fn bar(&self) {}
|
|
fn hel(&self) {}
|
|
fn qux(&mut self) {}
|
|
|
|
fn hello(&mut self) {
|
|
let y = |this: &Self| {
|
|
this.bar();
|
|
};
|
|
self.qux(); //~ ERROR cannot borrow `*self` as mutable because it is also borrowed as immutable
|
|
y(self);
|
|
}
|
|
}
|
|
|
|
fn main() {}
|