fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
1.7 KiB59 linesraw
1// compile-flags: --edition=2021
2// run-rustfix
3
4#![allow(unused)]
5
6struct Foo;
7
8impl Foo {
9    fn get(&self) -> u8 {
10        42
11    }
12}
13
14fn 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
22async 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
30fn 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
37async 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
44fn 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
52fn 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
59fn main() {}