@@ -225,7 +225,7 @@ fn report_bin_hex_error(
225
225
( t. name_str ( ) , actually. to_string ( ) )
226
226
}
227
227
} ;
228
- let mut err = lint. build ( & format ! ( "literal out of range for {} " , t) ) ;
228
+ let mut err = lint. build ( & format ! ( "literal out of range for `{}` " , t) ) ;
229
229
err. note ( & format ! (
230
230
"the literal `{}` (decimal `{}`) does not fit into \
231
231
the type `{}` and will become `{}{}`",
@@ -238,12 +238,12 @@ fn report_bin_hex_error(
238
238
let ( sans_suffix, _) = repr_str. split_at ( pos) ;
239
239
err. span_suggestion (
240
240
expr. span ,
241
- & format ! ( "consider using `{}` instead" , sugg_ty) ,
241
+ & format ! ( "consider using the type `{}` instead" , sugg_ty) ,
242
242
format ! ( "{}{}" , sans_suffix, sugg_ty) ,
243
243
Applicability :: MachineApplicable ,
244
244
) ;
245
245
} else {
246
- err. help ( & format ! ( "consider using `{}` instead" , sugg_ty) ) ;
246
+ err. help ( & format ! ( "consider using the type `{}` instead" , sugg_ty) ) ;
247
247
}
248
248
}
249
249
err. emit ( ) ;
@@ -338,18 +338,23 @@ fn lint_int_literal<'tcx>(
338
338
}
339
339
340
340
cx. struct_span_lint ( OVERFLOWING_LITERALS , e. span , |lint| {
341
- lint. build ( & format ! ( "literal out of range for `{}`" , t. name_str( ) ) )
342
- . note ( & format ! (
343
- "the literal `{}` does not fit into the type `{}` whose range is `{}..={}`" ,
344
- cx. sess( )
345
- . source_map( )
346
- . span_to_snippet( lit. span)
347
- . expect( "must get snippet from literal" ) ,
348
- t. name_str( ) ,
349
- min,
350
- max,
351
- ) )
352
- . emit ( ) ;
341
+ let mut err = lint. build ( & format ! ( "literal out of range for `{}`" , t. name_str( ) ) ) ;
342
+ err. note ( & format ! (
343
+ "the literal `{}` does not fit into the type `{}` whose range is `{}..={}`" ,
344
+ cx. sess( )
345
+ . source_map( )
346
+ . span_to_snippet( lit. span)
347
+ . expect( "must get snippet from literal" ) ,
348
+ t. name_str( ) ,
349
+ min,
350
+ max,
351
+ ) ) ;
352
+ if let Some ( sugg_ty) =
353
+ get_type_suggestion ( & cx. typeck_results ( ) . node_type ( e. hir_id ) , v, negative)
354
+ {
355
+ err. help ( & format ! ( "consider using the type `{}` instead" , sugg_ty) ) ;
356
+ }
357
+ err. emit ( ) ;
353
358
} ) ;
354
359
}
355
360
}
0 commit comments