]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/ok_expect.rs
Auto merge of #84620 - Dylan-DPC:rollup-wkv97im, r=Dylan-DPC
[rust.git] / src / tools / clippy / tests / ui / ok_expect.rs
1 use std::io;
2
3 struct MyError(()); // doesn't implement Debug
4
5 #[derive(Debug)]
6 struct MyErrorWithParam<T> {
7     x: T,
8 }
9
10 fn main() {
11     let res: Result<i32, ()> = Ok(0);
12     let _ = res.unwrap();
13
14     res.ok().expect("disaster!");
15     // the following should not warn, since `expect` isn't implemented unless
16     // the error type implements `Debug`
17     let res2: Result<i32, MyError> = Ok(0);
18     res2.ok().expect("oh noes!");
19     let res3: Result<u32, MyErrorWithParam<u8>> = Ok(0);
20     res3.ok().expect("whoof");
21     let res4: Result<u32, io::Error> = Ok(0);
22     res4.ok().expect("argh");
23     let res5: io::Result<u32> = Ok(0);
24     res5.ok().expect("oops");
25     let res6: Result<u32, &str> = Ok(0);
26     res6.ok().expect("meh");
27 }