@@ -2,7 +2,7 @@ use crate::{map_unit_fn::OPTION_MAP_UNIT_FN, matches::MATCH_AS_REF};
22use clippy_utils:: diagnostics:: span_lint_and_sugg;
33use clippy_utils:: source:: { snippet_with_applicability, snippet_with_context} ;
44use 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} ;
66use rustc_ast:: util:: parser:: PREC_POSTFIX ;
77use rustc_errors:: Applicability ;
88use rustc_hir:: {
@@ -47,16 +47,16 @@ declare_lint_pass!(ManualMap => [MANUAL_MAP]);
4747impl LateLintPass < ' _ > for ManualMap {
4848 #[ allow( clippy:: too_many_lines) ]
4949 fn check_expr ( & mut self , cx : & LateContext < ' tcx > , expr : & ' tcx Expr < ' _ > ) {
50- if in_external_macro ( cx. sess ( ) , expr. span ) {
51- return ;
52- }
53-
5450 if let ExprKind :: Match (
5551 scrutinee,
5652 [ arm1 @ Arm { guard : None , .. } , arm2 @ Arm { guard : None , .. } ] ,
5753 match_kind,
5854 ) = expr. kind
5955 {
56+ if in_external_macro ( cx. sess ( ) , expr. span ) || in_constant ( cx, expr. hir_id ) {
57+ return ;
58+ }
59+
6060 let ( scrutinee_ty, ty_ref_count, ty_mutability) =
6161 peel_mid_ty_refs_is_mutable ( cx. typeck_results ( ) . expr_ty ( scrutinee) ) ;
6262 if !( is_type_diagnostic_item ( cx, scrutinee_ty, sym:: option_type)
0 commit comments