@@ -2952,30 +2952,34 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
2952
2952
. emit ( ) ;
2953
2953
self . tcx ( ) . types . err
2954
2954
} else {
2955
- let mut err = self . type_error_struct ( field. span , |actual| {
2956
- format ! ( "no field `{}` on type `{}`" ,
2957
- field. node, actual)
2958
- } , expr_t) ;
2959
- match expr_t. sty {
2960
- ty:: TyAdt ( def, _) if !def. is_enum ( ) => {
2961
- if let Some ( suggested_field_name) =
2962
- Self :: suggest_field_name ( def. struct_variant ( ) , field, vec ! [ ] ) {
2963
- err. span_label ( field. span ,
2964
- format ! ( "did you mean `{}`?" , suggested_field_name) ) ;
2965
- } else {
2966
- err. span_label ( field. span ,
2967
- "unknown field" ) ;
2968
- } ;
2969
- }
2970
- ty:: TyRawPtr ( ..) => {
2971
- err. note ( & format ! ( "`{0}` is a native pointer; perhaps you need to deref with \
2972
- `(*{0}).{1}`",
2973
- self . tcx. hir. node_to_pretty_string( base. id) ,
2974
- field. node) ) ;
2955
+ if !expr_t. is_primitive_ty ( ) {
2956
+ let mut err = type_error_struct ! ( self . tcx( ) . sess, field. span, expr_t, E0609 ,
2957
+ "no field `{}` on type `{}`" ,
2958
+ field. node, expr_t) ;
2959
+ match expr_t. sty {
2960
+ ty:: TyAdt ( def, _) if !def. is_enum ( ) => {
2961
+ if let Some ( suggested_field_name) =
2962
+ Self :: suggest_field_name ( def. struct_variant ( ) , field, vec ! [ ] ) {
2963
+ err. span_label ( field. span ,
2964
+ format ! ( "did you mean `{}`?" , suggested_field_name) ) ;
2965
+ } else {
2966
+ err. span_label ( field. span , "unknown field" ) ;
2967
+ } ;
2968
+ }
2969
+ ty:: TyRawPtr ( ..) => {
2970
+ err. note ( & format ! ( "`{0}` is a native pointer; perhaps you need to deref \
2971
+ with `(*{0}).{1}`",
2972
+ self . tcx. hir. node_to_pretty_string( base. id) ,
2973
+ field. node) ) ;
2974
+ }
2975
+ _ => { }
2975
2976
}
2976
- _ => { }
2977
- }
2978
- err. emit ( ) ;
2977
+ err
2978
+ } else {
2979
+ type_error_struct ! ( self . tcx( ) . sess, field. span, expr_t, E0610 ,
2980
+ "`{}` is a primitive type and therefore doesn't have fields" ,
2981
+ expr_t)
2982
+ } . emit ( ) ;
2979
2983
self . tcx ( ) . types . err
2980
2984
}
2981
2985
}
0 commit comments