@@ -21,7 +21,7 @@ const HARD_CODED_ALLOWED_BINARY: &[[&str; 2]] = &[
2121 [ "f64" , "f64" ] ,
2222 [ "std::num::Saturating" , "std::num::Saturating" ] ,
2323 [ "std::num::Wrapping" , "std::num::Wrapping" ] ,
24- [ "std::string::String" , "& str" ] ,
24+ [ "std::string::String" , "str" ] ,
2525] ;
2626const HARD_CODED_ALLOWED_UNARY : & [ & str ] = & [ "f32" , "f64" , "std::num::Saturating" , "std::num::Wrapping" ] ;
2727const INTEGER_METHODS : & [ & str ] = & [ "saturating_div" , "wrapping_div" , "wrapping_rem" , "wrapping_rem_euclid" ] ;
@@ -144,8 +144,10 @@ impl ArithmeticSideEffects {
144144 ) {
145145 return ;
146146 } ;
147- let lhs_ty = cx. typeck_results ( ) . expr_ty ( lhs) ;
148- let rhs_ty = cx. typeck_results ( ) . expr_ty ( rhs) ;
147+ let ( actual_lhs, lhs_ref_counter) = peel_hir_expr_refs ( lhs) ;
148+ let ( actual_rhs, rhs_ref_counter) = peel_hir_expr_refs ( rhs) ;
149+ let lhs_ty = cx. typeck_results ( ) . expr_ty ( actual_lhs) . peel_refs ( ) ;
150+ let rhs_ty = cx. typeck_results ( ) . expr_ty ( actual_rhs) . peel_refs ( ) ;
149151 if self . has_allowed_binary ( lhs_ty, rhs_ty) {
150152 return ;
151153 }
@@ -154,8 +156,6 @@ impl ArithmeticSideEffects {
154156 // At least for integers, shifts are already handled by the CTFE
155157 return ;
156158 }
157- let ( actual_lhs, lhs_ref_counter) = peel_hir_expr_refs ( lhs) ;
158- let ( actual_rhs, rhs_ref_counter) = peel_hir_expr_refs ( rhs) ;
159159 match (
160160 Self :: literal_integer ( cx, actual_lhs) ,
161161 Self :: literal_integer ( cx, actual_rhs) ,
0 commit comments