@@ -2921,29 +2921,34 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
2921
2921
. emit ( ) ;
2922
2922
self . tcx ( ) . types . err
2923
2923
} else {
2924
- let mut err = type_error_struct ! ( self . tcx( ) . sess, field. span, expr_t, E0609 ,
2925
- "no field `{}` on type `{}`" ,
2926
- field. node, expr_t) ;
2927
- match expr_t. sty {
2928
- ty:: TyAdt ( def, _) if !def. is_enum ( ) => {
2929
- if let Some ( suggested_field_name) =
2930
- Self :: suggest_field_name ( def. struct_variant ( ) , field, vec ! [ ] ) {
2931
- err. span_label ( field. span ,
2932
- format ! ( "did you mean `{}`?" , suggested_field_name) ) ;
2933
- } else {
2934
- err. span_label ( field. span ,
2935
- "unknown field" ) ;
2936
- } ;
2937
- }
2938
- ty:: TyRawPtr ( ..) => {
2939
- err. note ( & format ! ( "`{0}` is a native pointer; perhaps you need to deref with \
2940
- `(*{0}).{1}`",
2941
- self . tcx. hir. node_to_pretty_string( base. id) ,
2942
- field. node) ) ;
2924
+ if !expr_t. is_primitive_ty ( ) {
2925
+ let mut err = type_error_struct ! ( self . tcx( ) . sess, field. span, expr_t, E0609 ,
2926
+ "no field `{}` on type `{}`" ,
2927
+ field. node, expr_t) ;
2928
+ match expr_t. sty {
2929
+ ty:: TyAdt ( def, _) if !def. is_enum ( ) => {
2930
+ if let Some ( suggested_field_name) =
2931
+ Self :: suggest_field_name ( def. struct_variant ( ) , field, vec ! [ ] ) {
2932
+ err. span_label ( field. span ,
2933
+ format ! ( "did you mean `{}`?" , suggested_field_name) ) ;
2934
+ } else {
2935
+ err. span_label ( field. span , "unknown field" ) ;
2936
+ } ;
2937
+ }
2938
+ ty:: TyRawPtr ( ..) => {
2939
+ err. note ( & format ! ( "`{0}` is a native pointer; perhaps you need to deref \
2940
+ with `(*{0}).{1}`",
2941
+ self . tcx. hir. node_to_pretty_string( base. id) ,
2942
+ field. node) ) ;
2943
+ }
2944
+ _ => { }
2943
2945
}
2944
- _ => { }
2945
- }
2946
- err. emit ( ) ;
2946
+ err
2947
+ } else {
2948
+ type_error_struct ! ( self . tcx( ) . sess, field. span, expr_t, E0610 ,
2949
+ "`{}` is a primitive type and therefore doesn't have fields" ,
2950
+ expr_t)
2951
+ } . emit ( ) ;
2947
2952
self . tcx ( ) . types . err
2948
2953
}
2949
2954
}
0 commit comments