1 #![deny(clippy::try_err)]
3 // Tests that a simple case works
4 // Should flag `Err(err)?`
5 pub fn basic_test() -> Result<i32, i32> {
11 // Tests that `.into()` is added when appropriate
12 pub fn into_test() -> Result<i32, i32> {
18 // Tests that tries in general don't trigger the error
19 pub fn negative_test() -> Result<i32, i32> {
20 Ok(nested_error()? + 1)
24 // Tests that `.into()` isn't added when the error type
25 // matches the surrounding closure's return type, even
26 // when it doesn't match the surrounding function's.
27 pub fn closure_matches_test() -> Result<i32, i32> {
28 let res: Result<i32, i8> = Some(1).into_iter()
40 // Tests that `.into()` isn't added when the error type
41 // doesn't match the surrounding closure's return type.
42 pub fn closure_into_test() -> Result<i32, i32> {
43 let res: Result<i32, i16> = Some(1).into_iter()
55 fn nested_error() -> Result<i32, i32> {
60 basic_test().unwrap();
62 negative_test().unwrap();
63 closure_matches_test().unwrap();
64 closure_into_test().unwrap();