@@ -1211,18 +1211,39 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12111211 expr : & hir:: Expr < ' _ > ,
12121212 expected_ty : Ty < ' tcx > ,
12131213 ) -> bool {
1214- if let ExprKind :: Struct ( QPath :: LangItem ( LangItem :: Range , ..) , [ start, _] , _) = expr. kind
1215- && expected_ty. is_floating_point ( )
1216- {
1217- err. span_suggestion_verbose (
1218- self . tcx . sess . source_map ( ) . next_point ( start. span ) ,
1219- "remove the unnecessary `.` operator to to use a floating point literal" ,
1220- "" ,
1221- Applicability :: MachineApplicable ,
1222- ) ;
1223- return true ;
1214+ if !expected_ty. is_floating_point ( ) {
1215+ return false ;
1216+ }
1217+ match expr. kind {
1218+ ExprKind :: Struct ( QPath :: LangItem ( LangItem :: Range , ..) , [ start, end] , _) => {
1219+ err. span_suggestion_verbose (
1220+ start. span . shrink_to_hi ( ) . with_hi ( end. span . lo ( ) ) ,
1221+ "remove the unnecessary `.` operator for a floating point literal" ,
1222+ '.' ,
1223+ Applicability :: MaybeIncorrect ,
1224+ ) ;
1225+ true
1226+ }
1227+ ExprKind :: Struct ( QPath :: LangItem ( LangItem :: RangeFrom , ..) , [ start] , _) => {
1228+ err. span_suggestion_verbose (
1229+ expr. span . with_lo ( start. span . hi ( ) ) ,
1230+ "remove the unnecessary `.` operator for a floating point literal" ,
1231+ '.' ,
1232+ Applicability :: MaybeIncorrect ,
1233+ ) ;
1234+ true
1235+ }
1236+ ExprKind :: Struct ( QPath :: LangItem ( LangItem :: RangeTo , ..) , [ end] , _) => {
1237+ err. span_suggestion_verbose (
1238+ expr. span . until ( end. span ) ,
1239+ "remove the unnecessary `.` operator and add an integer part for a floating point literal" ,
1240+ "0." ,
1241+ Applicability :: MaybeIncorrect ,
1242+ ) ;
1243+ true
1244+ }
1245+ _ => false ,
12241246 }
1225- false
12261247 }
12271248
12281249 fn is_loop ( & self , id : hir:: HirId ) -> bool {
0 commit comments