@@ -8,7 +8,6 @@ use crate::infer::InferCtxt;
88use  crate :: traits:: normalize_to; 
99
1010use  hir:: HirId ; 
11- use  rustc_ast:: Movability ; 
1211use  rustc_data_structures:: fx:: FxHashSet ; 
1312use  rustc_data_structures:: stack:: ensure_sufficient_stack; 
1413use  rustc_errors:: { 
@@ -2395,19 +2394,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
23952394                    } 
23962395                } ; 
23972396
2398-                 let  future_trait = self . tcx . lang_items ( ) . future_trait ( ) . unwrap ( ) ; 
2399-                 let  opaque_ty_is_future = |def_id| { 
2400-                     self . tcx . explicit_item_bounds ( def_id) . iter ( ) . any ( |( predicate,  _) | { 
2401-                         if  let  ty:: PredicateKind :: Trait ( trait_predicate)  =
2402-                             predicate. kind ( ) . skip_binder ( ) 
2403-                         { 
2404-                             trait_predicate. trait_ref . def_id  == future_trait
2405-                         }  else  { 
2406-                             false 
2407-                         } 
2408-                     } ) 
2409-                 } ; 
2410- 
24112397                let  from_generator = tcx. lang_items ( ) . from_generator_fn ( ) . unwrap ( ) ; 
24122398
24132399                // Don't print the tuple of capture types 
@@ -2433,13 +2419,13 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
24332419
24342420                                // If the previous type is `from_generator`, this is the future generated by the body of an async function. 
24352421                                // Avoid printing it twice (it was already printed in the `ty::Generator` arm below). 
2436-                                 let  is_future = opaque_ty_is_future ( def_id ) ; 
2422+                                 let  is_future = tcx . ty_is_opaque_future ( ty ) ; 
24372423                                debug ! ( 
24382424                                    ?obligated_types, 
24392425                                    ?is_future, 
24402426                                    "note_obligation_cause_code: check for async fn" 
24412427                                ) ; 
2442-                                 if  opaque_ty_is_future ( def_id ) 
2428+                                 if  is_future 
24432429                                    && obligated_types. last ( ) . map_or ( false ,  |ty| match  ty. kind ( )  { 
24442430                                        ty:: Opaque ( last_def_id,  _)  => { 
24452431                                            tcx. parent ( * last_def_id)  == from_generator
@@ -2464,15 +2450,11 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
24642450                                } 
24652451                                err. note ( msg. trim_end_matches ( ", " ) ) 
24662452                            } 
2467-                             ty:: Generator ( def_id,  _,  movability )  => { 
2453+                             ty:: Generator ( def_id,  _,  _ )  => { 
24682454                                let  sp = self . tcx . def_span ( def_id) ; 
24692455
24702456                                // Special-case this to say "async block" instead of `[static generator]`. 
2471-                                 let  kind = if  * movability == Movability :: Static  { 
2472-                                     "async block" 
2473-                                 }  else  { 
2474-                                     "generator" 
2475-                                 } ; 
2457+                                 let  kind = tcx. generator_kind ( def_id) . unwrap ( ) ; 
24762458                                err. span_note ( 
24772459                                    sp, 
24782460                                    & format ! ( "required because it's used within this {}" ,  kind) , 
0 commit comments