File tree 1 file changed +6
-5
lines changed
1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -17,20 +17,21 @@ pub(super) fn check<'tcx>(
17
17
unwrap_recv : & ' tcx rustc_hir:: Expr < ' _ > ,
18
18
msrv : & Msrv ,
19
19
) {
20
+ // Don't lint if:
21
+
22
+ // 1. the `expr` is generated by a macro
20
23
if expr. span . from_expansion ( ) {
21
24
return ;
22
25
}
23
26
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`
27
28
let is_option = is_type_diagnostic_item ( cx, cx. typeck_results ( ) . expr_ty ( map_recv) , sym:: Option ) ;
28
29
let is_result = is_type_diagnostic_item ( cx, cx. typeck_results ( ) . expr_ty ( map_recv) , sym:: Result ) ;
29
30
if !is_option && !is_result {
30
31
return ;
31
32
}
32
33
33
- // 2 . the `map_arg` maps `T` to `bool`
34
+ // 3 . the `map_arg` function/closure doesn't return `bool`
34
35
let map_arg_return_bool = expr_sig ( cx, map_arg) . is_some_and ( |fn_sig| {
35
36
fn_sig
36
37
. output ( )
@@ -40,7 +41,7 @@ pub(super) fn check<'tcx>(
40
41
return ;
41
42
}
42
43
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`
44
45
if !msrv. meets ( OPTION_IS_SOME_AND ) || !msrv. meets ( RESULT_IS_OK_AND ) {
45
46
return ;
46
47
}
You can’t perform that action at this time.
0 commit comments