@@ -6,7 +6,8 @@ use clippy_utils::ty::implements_trait;
6
6
use clippy_utils:: visitors:: is_const_evaluatable;
7
7
use clippy_utils:: MaybePath ;
8
8
use 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,
10
11
} ;
11
12
use itertools:: Itertools ;
12
13
use rustc_errors:: Applicability ;
@@ -117,7 +118,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualClamp {
117
118
if !self . msrv . meets ( msrvs:: CLAMP ) {
118
119
return ;
119
120
}
120
- if !expr. span . from_expansion ( ) {
121
+ if !expr. span . from_expansion ( ) && ! in_constant ( cx , expr . hir_id ) {
121
122
let suggestion = is_if_elseif_else_pattern ( cx, expr)
122
123
. or_else ( || is_max_min_pattern ( cx, expr) )
123
124
. or_else ( || is_call_max_min_pattern ( cx, expr) )
@@ -130,7 +131,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualClamp {
130
131
}
131
132
132
133
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 ) {
134
135
return ;
135
136
}
136
137
for suggestion in is_two_if_pattern ( cx, block) {
0 commit comments