@@ -2591,9 +2591,22 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
2591
2591
// arguments which we skipped above.
2592
2592
if variadic {
2593
2593
fn variadic_error < ' tcx > ( s : & Session , span : Span , t : Ty < ' tcx > , cast_ty : & str ) {
2594
- type_error_struct ! ( s, span, t, E0617 ,
2595
- "can't pass `{}` to variadic function, cast to `{}`" ,
2596
- t, cast_ty) . emit ( ) ;
2594
+ let mut err = type_error_struct ! (
2595
+ s, span, t, E0617 , "can't pass `{}` to variadic function" , t) ;
2596
+ if s. opts . debugging_opts . explain {
2597
+ err. note ( & format ! ( "certain types, like `{}`, must be cast before passing them \
2598
+ to a variadic function, because of arcane ABI rules \
2599
+ dictated by the C standard",
2600
+ t) ) ;
2601
+ }
2602
+ if let Ok ( snippet) = s. codemap ( ) . span_to_snippet ( span) {
2603
+ err. span_suggestion ( span,
2604
+ & format ! ( "cast the value to `{}`" , cast_ty) ,
2605
+ format ! ( "{} as {}" , snippet, cast_ty) ) ;
2606
+ } else {
2607
+ err. help ( & format ! ( "cast the value to `{}`" , cast_ty) ) ;
2608
+ }
2609
+ err. emit ( ) ;
2597
2610
}
2598
2611
2599
2612
for arg in args. iter ( ) . skip ( expected_arg_count) {
0 commit comments