@@ -3440,7 +3440,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
34403440 len. assert_usize ( self . tcx ) ,
34413441 field. as_str ( ) . parse :: < u64 > ( )
34423442 ) {
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 ) ) ;
34443446 let help = "instead of using tuple indexing, use array indexing" ;
34453447 let suggestion = format ! ( "{}[{}]" , base, field) ;
34463448 let applicability = if len < user_index {
@@ -3454,11 +3456,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
34543456 }
34553457 }
34563458 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) ;
34593463 let suggestion = format ! ( "(*{}).{}" , base, field) ;
34603464 err. span_suggestion_with_applicability (
3461- field . span ,
3465+ expr . span ,
34623466 & msg,
34633467 suggestion,
34643468 Applicability :: MaybeIncorrect ,
0 commit comments