@@ -3278,6 +3278,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
32783278 }
32793279
32803280 fn suggest_first_deref_field( & self , err : & mut Diag < ' _ > , base : & hir:: Expr < ' _ > , field : Ident ) {
3281+ <<<<<<< HEAD
32813282 err. span_label( field . span, "unknown field" ) ;
32823283 let val = if let Ok ( base) = self . tcx. sess. source_map( ) . span_to_snippet( base. span)
32833284 && base. len( ) < 20
@@ -3293,6 +3294,26 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
32933294 ( base. span. to( field. span. shrink_to_lo( ) ) , format!( "{val})." ) ) ,
32943295 ] ,
32953296 Applicability :: MaybeIncorrect ,
3297+ =======
3298+ let full_span = base. span. to( field. span) ;
3299+
3300+ let base_snippet = self
3301+ . tcx
3302+ . sess
3303+ . source_map( )
3304+ . span_to_snippet( base. span)
3305+ . unwrap_or_else( |_| "ptr" . to_string( ) ) ;
3306+
3307+ let replacement = format ! ( "(*{}).{}" , base_snippet, field. name) ;
3308+
3309+ err. span_label( full_span, "unknown field access via raw pointer" ) ;
3310+
3311+ err. span_suggestion_verbose(
3312+ full_span,
3313+ "`->` is not valid in Rust; use `.` on a dereferenced raw pointer instead" ,
3314+ replacement,
3315+ Applicability :: MachineApplicable ,
3316+ >>>>>>> cf551dbca4b ( improve diagnostic for raw pointer field access with ->)
32963317 ) ;
32973318 }
32983319
0 commit comments