@@ -14,7 +14,7 @@ use std::cmp::Ordering;
1414
1515use crate :: utils:: sugg:: Sugg ;
1616use crate :: utils:: {
17- get_parent_expr, is_integer_const, meets_msrv, single_segment_path, snippet, snippet_opt,
17+ get_parent_expr, in_constant , is_integer_const, meets_msrv, single_segment_path, snippet, snippet_opt,
1818 snippet_with_applicability, span_lint, span_lint_and_sugg, span_lint_and_then,
1919} ;
2020use crate :: utils:: { higher, SpanlessEq } ;
@@ -190,7 +190,7 @@ impl<'tcx> LateLintPass<'tcx> for Ranges {
190190 } ,
191191 ExprKind :: Binary ( ref op, ref l, ref r) => {
192192 if meets_msrv ( self . msrv . as_ref ( ) , & MANUAL_RANGE_CONTAINS_MSRV ) {
193- check_possible_range_contains ( cx, op. node , l, r, expr. span ) ;
193+ check_possible_range_contains ( cx, op. node , l, r, expr) ;
194194 }
195195 } ,
196196 _ => { } ,
@@ -203,7 +203,12 @@ impl<'tcx> LateLintPass<'tcx> for Ranges {
203203 extract_msrv_attr ! ( LateContext ) ;
204204}
205205
206- fn check_possible_range_contains ( cx : & LateContext < ' _ > , op : BinOpKind , l : & Expr < ' _ > , r : & Expr < ' _ > , span : Span ) {
206+ fn check_possible_range_contains ( cx : & LateContext < ' _ > , op : BinOpKind , l : & Expr < ' _ > , r : & Expr < ' _ > , expr : & Expr < ' _ > ) {
207+ if in_constant ( cx, expr. hir_id ) {
208+ return ;
209+ }
210+
211+ let span = expr. span ;
207212 let combine_and = match op {
208213 BinOpKind :: And | BinOpKind :: BitAnd => true ,
209214 BinOpKind :: Or | BinOpKind :: BitOr => false ,
0 commit comments