Skip to content

Commit 87ef71a

Browse files
committed
chore: update comments
1 parent e346244 commit 87ef71a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

clippy_lints/src/methods/map_unwrap_or_default.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,21 @@ pub(super) fn check<'tcx>(
1717
unwrap_recv: &'tcx rustc_hir::Expr<'_>,
1818
msrv: &Msrv,
1919
) {
20+
// Don't lint if:
21+
22+
// 1. the `expr` is generated by a macro
2023
if expr.span.from_expansion() {
2124
return;
2225
}
2326

24-
// Lint if:
25-
26-
// 1. the caller of `map()` is an `Option` or `Result`
27+
// 2. the caller of `map()` is neither `Option` nor `Result`
2728
let is_option = is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(map_recv), sym::Option);
2829
let is_result = is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(map_recv), sym::Result);
2930
if !is_option && !is_result {
3031
return;
3132
}
3233

33-
// 2. the `map_arg` maps `T` to `bool`
34+
// 3. the `map_arg` function/closure doesn't return `bool`
3435
let map_arg_return_bool = expr_sig(cx, map_arg).is_some_and(|fn_sig| {
3536
fn_sig
3637
.output()
@@ -40,7 +41,7 @@ pub(super) fn check<'tcx>(
4041
return;
4142
}
4243

43-
// 3. msrv meets `OPTION_IS_SOME_AND` and `RESULT_IS_OK_AND`
44+
// 4. msrv doesn't meet either `OPTION_IS_SOME_AND` or `RESULT_IS_OK_AND`
4445
if !msrv.meets(OPTION_IS_SOME_AND) || !msrv.meets(RESULT_IS_OK_AND) {
4546
return;
4647
}

0 commit comments

Comments
 (0)