summaryrefslogtreecommitdiffstats
path: root/src/test/ui/suggestions/enum-method-probe.fixed
blob: 6499c92bc6f1545baeacbf6c66e696d6ff560139 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// compile-flags: --edition=2021
// run-rustfix

#![allow(unused)]

struct Foo;

impl Foo {
    fn get(&self) -> u8 {
        42
    }
}

fn test_result_in_result() -> Result<(), ()> {
    let res: Result<_, ()> = Ok(Foo);
    res?.get();
    //~^ ERROR no method named `get` found for enum `Result` in the current scope
    //~| HELP use the `?` operator
    Ok(())
}

async fn async_test_result_in_result() -> Result<(), ()> {
    let res: Result<_, ()> = Ok(Foo);
    res?.get();
    //~^ ERROR no method named `get` found for enum `Result` in the current scope
    //~| HELP use the `?` operator
    Ok(())
}

fn test_result_in_unit_return() {
    let res: Result<_, ()> = Ok(Foo);
    res.expect("REASON").get();
    //~^ ERROR no method named `get` found for enum `Result` in the current scope
    //~| HELP consider using `Result::expect` to unwrap the `Foo` value, panicking if the value is a `Result::Err`
}

async fn async_test_result_in_unit_return() {
    let res: Result<_, ()> = Ok(Foo);
    res.expect("REASON").get();
    //~^ ERROR no method named `get` found for enum `Result` in the current scope
    //~| HELP consider using `Result::expect` to unwrap the `Foo` value, panicking if the value is a `Result::Err`
}

fn test_option_in_option() -> Option<()> {
    let res: Option<_> = Some(Foo);
    res?.get();
    //~^ ERROR no method named `get` found for enum `Option` in the current scope
    //~| HELP use the `?` operator
    Some(())
}

fn test_option_in_unit_return() {
    let res: Option<_> = Some(Foo);
    res.expect("REASON").get();
    //~^ ERROR no method named `get` found for enum `Option` in the current scope
    //~| HELP consider using `Option::expect` to unwrap the `Foo` value, panicking if the value is an `Option::None`
}

fn main() {}