@@ -2418,9 +2418,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
24182418 field_ident : Ident ,
24192419 base : & ' tcx hir:: Expr < ' tcx > ,
24202420 ty : Ty < ' tcx > ,
2421- ) {
2421+ ) -> bool {
24222422 let Some ( output_ty) = self . get_impl_future_output_ty ( ty) else {
2423- return ;
2423+ return false ;
24242424 } ;
24252425 let mut add_label = true ;
24262426 if let ty:: Adt ( def, _) = output_ty. kind ( ) {
@@ -2449,6 +2449,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
24492449 if add_label {
24502450 err. span_label ( field_ident. span , format ! ( "field not found in `{ty}`" ) ) ;
24512451 }
2452+ true
24522453 }
24532454
24542455 fn ban_nonexisting_field (
@@ -2464,20 +2465,27 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
24642465 ) ;
24652466 let mut err = self . no_such_field_err ( ident, base_ty, base. hir_id ) ;
24662467
2467- match * base_ty. peel_refs ( ) . kind ( ) {
2468+ let has_label = match * base_ty. peel_refs ( ) . kind ( ) {
24682469 ty:: Array ( _, len) => {
24692470 self . maybe_suggest_array_indexing ( & mut err, expr, base, ident, len) ;
2471+ false
24702472 }
24712473 ty:: RawPtr ( ..) => {
24722474 self . suggest_first_deref_field ( & mut err, expr, base, ident) ;
2475+ false
24732476 }
24742477 ty:: Param ( param_ty) => {
24752478 self . point_at_param_definition ( & mut err, param_ty) ;
2479+ false
24762480 }
24772481 ty:: Alias ( ty:: Opaque , _) => {
2478- self . suggest_await_on_field_access ( & mut err, ident, base, base_ty. peel_refs ( ) ) ;
2482+ self . suggest_await_on_field_access ( & mut err, ident, base, base_ty. peel_refs ( ) )
24792483 }
2480- _ => { }
2484+ _ => false ,
2485+ } ;
2486+
2487+ if !has_label {
2488+ err. span_label ( ident. span , "unknown field" ) ;
24812489 }
24822490
24832491 self . suggest_fn_call ( & mut err, base, base_ty, |output_ty| {
0 commit comments