Skip to content

Commit

Permalink
adjust applicability
Browse files Browse the repository at this point in the history
Signed-off-by: tabokie <[email protected]>
  • Loading branch information
tabokie committed Jul 22, 2022
1 parent 5796501 commit 68fe39c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions clippy_lints/src/assertions_on_result_states.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ declare_clippy_lint! {
#[clippy::version = "1.64.0"]
pub ASSERTIONS_ON_RESULT_STATES,
style,
"`assert!(r.is_ok())` gives worse error message than directly calling `r.unwrap()`"
"`assert!(r.is_ok())`/`assert!(r.is_err())` gives worse error message than directly calling `r.unwrap()`/`r.unwrap_err()`"
}

declare_lint_pass!(AssertionsOnResultStates => [ASSERTIONS_ON_RESULT_STATES]);
Expand Down Expand Up @@ -54,7 +54,7 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnResultStates {
"{}.unwrap()",
method_receiver_snippet
),
Applicability::MachineApplicable,
Applicability::MaybeIncorrect,
);
} else if method_segment.ident.name == sym!(is_err)
&& let Some(value_type) = get_result_child_type(cx, result_type, false /*err*/)
Expand All @@ -70,7 +70,7 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnResultStates {
"{}.unwrap_err()",
method_receiver_snippet
),
Applicability::MachineApplicable,
Applicability::MaybeIncorrect,
);
}
}
Expand All @@ -84,7 +84,7 @@ fn get_result_child_type<'a>(cx: &LateContext<'_>, ty: Ty<'a>, err: bool) -> Opt
if err {
substs.types().nth(1)
} else {
substs.types().nth(0)
substs.types().next()
}
},
_ => None,
Expand Down

0 comments on commit 68fe39c

Please sign in to comment.