]> git.proxmox.com Git - rustc.git/blob - src/test/ui/suggestions/enum-method-probe.fixed
New upstream version 1.63.0+dfsg1
[rustc.git] / src / test / ui / suggestions / enum-method-probe.fixed
1 // compile-flags: --edition=2021
2 // run-rustfix
3
4 #![allow(unused)]
5
6 struct Foo;
7
8 impl Foo {
9 fn get(&self) -> u8 {
10 42
11 }
12 }
13
14 fn test_result_in_result() -> Result<(), ()> {
15 let res: Result<_, ()> = Ok(Foo);
16 res?.get();
17 //~^ ERROR no method named `get` found for enum `Result` in the current scope
18 //~| HELP use the `?` operator
19 Ok(())
20 }
21
22 async fn async_test_result_in_result() -> Result<(), ()> {
23 let res: Result<_, ()> = Ok(Foo);
24 res?.get();
25 //~^ ERROR no method named `get` found for enum `Result` in the current scope
26 //~| HELP use the `?` operator
27 Ok(())
28 }
29
30 fn test_result_in_unit_return() {
31 let res: Result<_, ()> = Ok(Foo);
32 res.expect("REASON").get();
33 //~^ ERROR no method named `get` found for enum `Result` in the current scope
34 //~| HELP consider using `Result::expect` to unwrap the `Foo` value, panicking if the value is a `Result::Err`
35 }
36
37 async fn async_test_result_in_unit_return() {
38 let res: Result<_, ()> = Ok(Foo);
39 res.expect("REASON").get();
40 //~^ ERROR no method named `get` found for enum `Result` in the current scope
41 //~| HELP consider using `Result::expect` to unwrap the `Foo` value, panicking if the value is a `Result::Err`
42 }
43
44 fn test_option_in_option() -> Option<()> {
45 let res: Option<_> = Some(Foo);
46 res?.get();
47 //~^ ERROR no method named `get` found for enum `Option` in the current scope
48 //~| HELP use the `?` operator
49 Some(())
50 }
51
52 fn test_option_in_unit_return() {
53 let res: Option<_> = Some(Foo);
54 res.expect("REASON").get();
55 //~^ ERROR no method named `get` found for enum `Option` in the current scope
56 //~| HELP consider using `Option::expect` to unwrap the `Foo` value, panicking if the value is an `Option::None`
57 }
58
59 fn main() {}