@@ -3440,7 +3440,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
3440
3440
len. assert_usize ( self . tcx ) ,
3441
3441
field. as_str ( ) . parse :: < u64 > ( )
3442
3442
) {
3443
- let base = self . tcx . hir ( ) . node_to_pretty_string ( base. id ) ;
3443
+ let base = self . tcx . sess . source_map ( )
3444
+ . span_to_snippet ( base. span )
3445
+ . unwrap_or_else ( |_| self . tcx . hir ( ) . node_to_pretty_string ( base. id ) ) ;
3444
3446
let help = "instead of using tuple indexing, use array indexing" ;
3445
3447
let suggestion = format ! ( "{}[{}]" , base, field) ;
3446
3448
let applicability = if len < user_index {
@@ -3454,11 +3456,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
3454
3456
}
3455
3457
}
3456
3458
ty:: RawPtr ( ..) => {
3457
- let base = self . tcx . hir ( ) . node_to_pretty_string ( base. id ) ;
3458
- let msg = format ! ( "`{}` is a native pointer; try dereferencing it" , base) ;
3459
+ let base = self . tcx . sess . source_map ( )
3460
+ . span_to_snippet ( base. span )
3461
+ . unwrap_or_else ( |_| self . tcx . hir ( ) . node_to_pretty_string ( base. id ) ) ;
3462
+ let msg = format ! ( "`{}` is a raw pointer; try dereferencing it" , base) ;
3459
3463
let suggestion = format ! ( "(*{}).{}" , base, field) ;
3460
3464
err. span_suggestion_with_applicability (
3461
- field . span ,
3465
+ expr . span ,
3462
3466
& msg,
3463
3467
suggestion,
3464
3468
Applicability :: MaybeIncorrect ,
0 commit comments