mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
29 lines
641 B
Rust
29 lines
641 B
Rust
struct Foo {}
|
|
|
|
impl Foo {
|
|
pub fn foo(&mut self) {
|
|
|| bar(&mut self);
|
|
//~^ ERROR cannot borrow `self` as mutable, as it is not declared as mutable
|
|
}
|
|
|
|
pub fn baz(&self) {
|
|
|| bar(&mut self);
|
|
//~^ ERROR cannot borrow `self` as mutable, as it is not declared as mutable
|
|
//~| ERROR cannot borrow data in a `&` reference as mutable
|
|
}
|
|
|
|
pub fn qux(mut self) {
|
|
|| bar(&mut self);
|
|
// OK
|
|
}
|
|
|
|
pub fn quux(self) {
|
|
|| bar(&mut self);
|
|
//~^ ERROR cannot borrow `self` as mutable, as it is not declared as mutable
|
|
}
|
|
}
|
|
|
|
fn bar(_: &mut Foo) {}
|
|
|
|
fn main() {}
|