mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-15 21:47:04 +00:00
question_mark
don't lint on if let Err
with else
This commit is contained in:
parent
6f16596b6a
commit
98250af4a3
@ -189,6 +189,7 @@ fn is_early_return(smbl: Symbol, cx: &LateContext<'_>, if_block: &IfBlockType<'_
|
||||
&& expr_return_none_or_err(smbl, cx, if_else.unwrap(), let_expr, Some(let_pat_sym)))
|
||||
|| is_res_lang_ctor(cx, res, ResultErr)
|
||||
&& expr_return_none_or_err(smbl, cx, if_then, let_expr, Some(let_pat_sym))
|
||||
&& if_else.is_none()
|
||||
},
|
||||
_ => false,
|
||||
}
|
||||
|
@ -134,6 +134,9 @@ fn result_func(x: Result<i32, i32>) -> Result<i32, i32> {
|
||||
return func_returning_result();
|
||||
}
|
||||
|
||||
// no warning
|
||||
let _ = if let Err(e) = x { Err(e) } else { Ok(0) };
|
||||
|
||||
Ok(y)
|
||||
}
|
||||
|
||||
|
@ -166,6 +166,9 @@ fn result_func(x: Result<i32, i32>) -> Result<i32, i32> {
|
||||
return func_returning_result();
|
||||
}
|
||||
|
||||
// no warning
|
||||
let _ = if let Err(e) = x { Err(e) } else { Ok(0) };
|
||||
|
||||
Ok(y)
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ LL | | }
|
||||
| |_____^ help: replace it with: `x?;`
|
||||
|
||||
error: this block may be rewritten with the `?` operator
|
||||
--> $DIR/question_mark.rs:193:5
|
||||
--> $DIR/question_mark.rs:196:5
|
||||
|
|
||||
LL | / if let Err(err) = func_returning_result() {
|
||||
LL | | return Err(err);
|
||||
@ -123,7 +123,7 @@ LL | | }
|
||||
| |_____^ help: replace it with: `func_returning_result()?;`
|
||||
|
||||
error: this block may be rewritten with the `?` operator
|
||||
--> $DIR/question_mark.rs:200:5
|
||||
--> $DIR/question_mark.rs:203:5
|
||||
|
|
||||
LL | / if let Err(err) = func_returning_result() {
|
||||
LL | | return Err(err);
|
||||
|
Loading…
Reference in New Issue
Block a user