1 // compile-flags: --edition=2021
9 pub fn method(&self) {}
11 pub fn some_mutable_method(&mut self) {}
15 let other_item = std::cell::RefCell::new(Struct { p: 42_u32 });
17 other_item.borrow().method();
18 //~^ ERROR no method named `method` found for struct `RefCell` in the current scope [E0599]
19 //~| HELP use `.borrow()` to borrow the `Struct<u32>`, panicking if a mutable borrow exists
21 other_item.borrow_mut().some_mutable_method();
22 //~^ ERROR no method named `some_mutable_method` found for struct `RefCell` in the current scope [E0599]
23 //~| HELP .borrow_mut()` to mutably borrow the `Struct<u32>`, panicking if any borrows exist
25 let another_item = std::sync::Mutex::new(Struct { p: 42_u32 });
27 another_item.lock().unwrap().method();
28 //~^ ERROR no method named `method` found for struct `Mutex` in the current scope [E0599]
29 //~| HELP use `.lock().unwrap()` to borrow the `Struct<u32>`, blocking the current thread until it can be acquired
31 let another_item = std::sync::RwLock::new(Struct { p: 42_u32 });
33 another_item.read().unwrap().method();
34 //~^ ERROR no method named `method` found for struct `RwLock` in the current scope [E0599]
35 //~| HELP use `.read().unwrap()` to borrow the `Struct<u32>`, blocking the current thread until it can be acquired
37 another_item.write().unwrap().some_mutable_method();
38 //~^ ERROR no method named `some_mutable_method` found for struct `RwLock` in the current scope [E0599]
39 //~| HELP use `.write().unwrap()` to mutably borrow the `Struct<u32>`, blocking the current thread until it can be acquired