@@ -225,7 +225,7 @@ fn report_bin_hex_error(
225225 ( t. name_str ( ) , actually. to_string ( ) )
226226 }
227227 } ;
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) ) ;
229229 err. note ( & format ! (
230230 "the literal `{}` (decimal `{}`) does not fit into \
231231 the type `{}` and will become `{}{}`",
@@ -238,12 +238,12 @@ fn report_bin_hex_error(
238238 let ( sans_suffix, _) = repr_str. split_at ( pos) ;
239239 err. span_suggestion (
240240 expr. span ,
241- & format ! ( "consider using `{}` instead" , sugg_ty) ,
241+ & format ! ( "consider using the type `{}` instead" , sugg_ty) ,
242242 format ! ( "{}{}" , sans_suffix, sugg_ty) ,
243243 Applicability :: MachineApplicable ,
244244 ) ;
245245 } else {
246- err. help ( & format ! ( "consider using `{}` instead" , sugg_ty) ) ;
246+ err. help ( & format ! ( "consider using the type `{}` instead" , sugg_ty) ) ;
247247 }
248248 }
249249 err. emit ( ) ;
@@ -338,18 +338,23 @@ fn lint_int_literal<'tcx>(
338338 }
339339
340340 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 ( ) ;
353358 } ) ;
354359 }
355360}
0 commit comments