@@ -2,7 +2,7 @@ use crate::{map_unit_fn::OPTION_MAP_UNIT_FN, matches::MATCH_AS_REF};
2
2
use clippy_utils:: diagnostics:: span_lint_and_sugg;
3
3
use clippy_utils:: source:: { snippet_with_applicability, snippet_with_context} ;
4
4
use clippy_utils:: ty:: { can_partially_move_ty, is_type_diagnostic_item, peel_mid_ty_refs_is_mutable} ;
5
- use clippy_utils:: { is_allowed, is_else_clause, match_def_path, match_var, paths, peel_hir_expr_refs} ;
5
+ use clippy_utils:: { in_constant , is_allowed, is_else_clause, match_def_path, match_var, paths, peel_hir_expr_refs} ;
6
6
use rustc_ast:: util:: parser:: PREC_POSTFIX ;
7
7
use rustc_errors:: Applicability ;
8
8
use rustc_hir:: {
@@ -47,16 +47,16 @@ declare_lint_pass!(ManualMap => [MANUAL_MAP]);
47
47
impl LateLintPass < ' _ > for ManualMap {
48
48
#[ allow( clippy:: too_many_lines) ]
49
49
fn check_expr ( & mut self , cx : & LateContext < ' tcx > , expr : & ' tcx Expr < ' _ > ) {
50
- if in_external_macro ( cx. sess ( ) , expr. span ) {
51
- return ;
52
- }
53
-
54
50
if let ExprKind :: Match (
55
51
scrutinee,
56
52
[ arm1 @ Arm { guard : None , .. } , arm2 @ Arm { guard : None , .. } ] ,
57
53
match_kind,
58
54
) = expr. kind
59
55
{
56
+ if in_external_macro ( cx. sess ( ) , expr. span ) || in_constant ( cx, expr. hir_id ) {
57
+ return ;
58
+ }
59
+
60
60
let ( scrutinee_ty, ty_ref_count, ty_mutability) =
61
61
peel_mid_ty_refs_is_mutable ( cx. typeck_results ( ) . expr_ty ( scrutinee) ) ;
62
62
if !( is_type_diagnostic_item ( cx, scrutinee_ty, sym:: option_type)
0 commit comments