@@ -605,36 +605,32 @@ fn lint_nan<'tcx>(
605605 }
606606
607607 fn eq_ne (
608- cx : & LateContext < ' _ > ,
609608 e : & hir:: Expr < ' _ > ,
610609 l : & hir:: Expr < ' _ > ,
611610 r : & hir:: Expr < ' _ > ,
612611 f : impl FnOnce ( Span , Span ) -> InvalidNanComparisonsSuggestion ,
613612 ) -> InvalidNanComparisons {
614- // FIXME(#72505): This suggestion can be restored if `f{32,64}::is_nan` is made const.
615- let suggestion = ( !cx. tcx . hir ( ) . is_inside_const_context ( e. hir_id ) ) . then ( || {
616- if let Some ( l_span) = l. span . find_ancestor_inside ( e. span )
617- && let Some ( r_span) = r. span . find_ancestor_inside ( e. span )
618- {
619- f ( l_span, r_span)
620- } else {
621- InvalidNanComparisonsSuggestion :: Spanless
622- }
623- } ) ;
613+ let suggestion = if let Some ( l_span) = l. span . find_ancestor_inside ( e. span )
614+ && let Some ( r_span) = r. span . find_ancestor_inside ( e. span )
615+ {
616+ f ( l_span, r_span)
617+ } else {
618+ InvalidNanComparisonsSuggestion :: Spanless
619+ } ;
624620
625621 InvalidNanComparisons :: EqNe { suggestion }
626622 }
627623
628624 let lint = match binop. node {
629625 hir:: BinOpKind :: Eq | hir:: BinOpKind :: Ne if is_nan ( cx, l) => {
630- eq_ne ( cx , e, l, r, |l_span, r_span| InvalidNanComparisonsSuggestion :: Spanful {
626+ eq_ne ( e, l, r, |l_span, r_span| InvalidNanComparisonsSuggestion :: Spanful {
631627 nan_plus_binop : l_span. until ( r_span) ,
632628 float : r_span. shrink_to_hi ( ) ,
633629 neg : ( binop. node == hir:: BinOpKind :: Ne ) . then ( || r_span. shrink_to_lo ( ) ) ,
634630 } )
635631 }
636632 hir:: BinOpKind :: Eq | hir:: BinOpKind :: Ne if is_nan ( cx, r) => {
637- eq_ne ( cx , e, l, r, |l_span, r_span| InvalidNanComparisonsSuggestion :: Spanful {
633+ eq_ne ( e, l, r, |l_span, r_span| InvalidNanComparisonsSuggestion :: Spanful {
638634 nan_plus_binop : l_span. shrink_to_hi ( ) . to ( r_span) ,
639635 float : l_span. shrink_to_hi ( ) ,
640636 neg : ( binop. node == hir:: BinOpKind :: Ne ) . then ( || l_span. shrink_to_lo ( ) ) ,
0 commit comments