]> git.lizzy.rs Git - rust.git/blob - tests/ui/suggestions/inner_type.rs
Rollup merge of #106670 - albertlarsan68:check-docs-in-pr-ci, r=Mark-Simulacrum
[rust.git] / tests / ui / suggestions / inner_type.rs
1 // compile-flags: --edition=2021
2 // run-rustfix
3
4 pub struct Struct<T> {
5     pub p: T,
6 }
7
8 impl<T> Struct<T> {
9     pub fn method(&self) {}
10
11     pub fn some_mutable_method(&mut self) {}
12 }
13
14 fn main() {
15     let other_item = std::cell::RefCell::new(Struct { p: 42_u32 });
16
17     other_item.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
20
21     other_item.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
24
25     let another_item = std::sync::Mutex::new(Struct { p: 42_u32 });
26
27     another_item.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
30
31     let another_item = std::sync::RwLock::new(Struct { p: 42_u32 });
32
33     another_item.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
36
37     another_item.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
40 }