@@ -10,7 +10,7 @@ use rustc_span::sym;
10
10
11
11
declare_clippy_lint ! {
12
12
/// ### What it does
13
- /// Checks for `Result::ok();` when the result is not captured .
13
+ /// Checks for calls to `Result::ok()` without using the returned `Option` .
14
14
///
15
15
/// ### Why is this bad?
16
16
/// Using `Result::ok()` may look like the result is checked like `unwrap` or `expect` would do
@@ -35,14 +35,14 @@ declare_lint_pass!(UnusedResultOk => [UNUSED_RESULT_OK]);
35
35
36
36
impl LateLintPass < ' _ > for UnusedResultOk {
37
37
fn check_stmt ( & mut self , cx : & LateContext < ' _ > , stmt : & Stmt < ' _ > ) {
38
- if let StmtKind :: Semi ( expr) = stmt. kind &&
39
- let ExprKind :: MethodCall ( ok_path, recv, [ ] , ..) = expr. kind //check is expr.ok() has type Result<T,E>.ok(, _)
38
+ if let StmtKind :: Semi ( expr) = stmt. kind
39
+ && let ExprKind :: MethodCall ( ok_path, recv, [ ] , ..) = expr. kind //check is expr.ok() has type Result<T,E>.ok(, _)
40
40
&& ok_path. ident . as_str ( ) == "ok"
41
41
&& is_type_diagnostic_item ( cx, cx. typeck_results ( ) . expr_ty ( recv) , sym:: Result )
42
42
&& !in_external_macro ( cx. sess ( ) , stmt. span )
43
43
{
44
44
let ctxt = expr. span . ctxt ( ) ;
45
- let mut applicability = Applicability :: MachineApplicable ;
45
+ let mut applicability = Applicability :: MaybeIncorrect ;
46
46
let snippet = snippet_with_context ( cx, recv. span , ctxt, "" , & mut applicability) . 0 ;
47
47
let sugg = format ! ( "let _ = {snippet}" ) ;
48
48
span_lint_and_sugg (
0 commit comments