@@ -6,7 +6,8 @@ use clippy_utils::ty::implements_trait;
66use clippy_utils:: visitors:: is_const_evaluatable;
77use clippy_utils:: MaybePath ;
88use clippy_utils:: {
9- eq_expr_value, is_diag_trait_item, is_trait_method, path_res, path_to_local_id, peel_blocks, peel_blocks_with_stmt,
9+ eq_expr_value, in_constant, is_diag_trait_item, is_trait_method, path_res, path_to_local_id, peel_blocks,
10+ peel_blocks_with_stmt,
1011} ;
1112use itertools:: Itertools ;
1213use rustc_errors:: Applicability ;
@@ -117,7 +118,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualClamp {
117118 if !self . msrv . meets ( msrvs:: CLAMP ) {
118119 return ;
119120 }
120- if !expr. span . from_expansion ( ) {
121+ if !expr. span . from_expansion ( ) && ! in_constant ( cx , expr . hir_id ) {
121122 let suggestion = is_if_elseif_else_pattern ( cx, expr)
122123 . or_else ( || is_max_min_pattern ( cx, expr) )
123124 . or_else ( || is_call_max_min_pattern ( cx, expr) )
@@ -130,7 +131,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualClamp {
130131 }
131132
132133 fn check_block ( & mut self , cx : & LateContext < ' tcx > , block : & ' tcx Block < ' tcx > ) {
133- if !self . msrv . meets ( msrvs:: CLAMP ) {
134+ if !self . msrv . meets ( msrvs:: CLAMP ) || in_constant ( cx , block . hir_id ) {
134135 return ;
135136 }
136137 for suggestion in is_two_if_pattern ( cx, block) {
0 commit comments