@@ -2418,11 +2418,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
24182418 field_ident : Ident ,
24192419 base : & ' tcx hir:: Expr < ' tcx > ,
24202420 ty : Ty < ' tcx > ,
2421- ) -> bool {
2421+ ) {
24222422 let Some ( output_ty) = self . get_impl_future_output_ty ( ty) else {
2423- return false ;
2423+ return ;
24242424 } ;
2425- let mut add_label = true ;
24262425 if let ty:: Adt ( def, _) = output_ty. kind ( ) {
24272426 // no field access on enum type
24282427 if !def. is_enum ( ) {
@@ -2432,7 +2431,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
24322431 . iter ( )
24332432 . any ( |field| field. ident ( self . tcx ) == field_ident)
24342433 {
2435- add_label = false ;
24362434 err. span_label (
24372435 field_ident. span ,
24382436 "field not available in `impl Future`, but it is available in its `Output`" ,
@@ -2446,10 +2444,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
24462444 }
24472445 }
24482446 }
2449- if add_label {
2450- err. span_label ( field_ident. span , format ! ( "field not found in `{ty}`" ) ) ;
2451- }
2452- true
24532447 }
24542448
24552449 fn ban_nonexisting_field (
@@ -2465,29 +2459,24 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
24652459 ) ;
24662460 let mut err = self . no_such_field_err ( ident, base_ty, base. hir_id ) ;
24672461
2468- let has_label = match * base_ty. peel_refs ( ) . kind ( ) {
2462+ match * base_ty. peel_refs ( ) . kind ( ) {
24692463 ty:: Array ( _, len) => {
24702464 self . maybe_suggest_array_indexing ( & mut err, expr, base, ident, len) ;
2471- false
24722465 }
24732466 ty:: RawPtr ( ..) => {
24742467 self . suggest_first_deref_field ( & mut err, expr, base, ident) ;
2475- false
24762468 }
24772469 ty:: Param ( param_ty) => {
24782470 self . point_at_param_definition ( & mut err, param_ty) ;
2479- false
24802471 }
24812472 ty:: Alias ( ty:: Opaque , _) => {
2482- self . suggest_await_on_field_access ( & mut err, ident, base, base_ty. peel_refs ( ) )
2473+ self . suggest_await_on_field_access ( & mut err, ident, base, base_ty. peel_refs ( ) ) ;
24832474 }
2484- _ => false ,
2485- } ;
2486-
2487- if !has_label {
2488- err. span_label ( ident. span , "unknown field" ) ;
2475+ _ => { }
24892476 }
24902477
2478+ err. span_label ( ident. span , "unknown field" ) ;
2479+
24912480 self . suggest_fn_call ( & mut err, base, base_ty, |output_ty| {
24922481 if let ty:: Adt ( def, _) = output_ty. kind ( )
24932482 && !def. is_enum ( )
0 commit comments