@@ -1988,11 +1988,6 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
1988
1988
. as_local ( )
1989
1989
. and_then ( |def_id| hir. maybe_body_owned_by ( def_id) )
1990
1990
. map ( |body_id| hir. body ( body_id) ) ;
1991
- let is_async = self
1992
- . tcx
1993
- . generator_kind ( generator_did)
1994
- . map ( |generator_kind| matches ! ( generator_kind, hir:: GeneratorKind :: Async ( ..) ) )
1995
- . unwrap_or ( false ) ;
1996
1991
let mut visitor = AwaitsVisitor :: default ( ) ;
1997
1992
if let Some ( body) = generator_body {
1998
1993
visitor. visit_body ( body) ;
@@ -2069,6 +2064,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
2069
2064
2070
2065
debug ! ( ?interior_or_upvar_span) ;
2071
2066
if let Some ( interior_or_upvar_span) = interior_or_upvar_span {
2067
+ let is_async = self . tcx . generator_is_async ( generator_did) ;
2072
2068
let typeck_results = match generator_data {
2073
2069
GeneratorData :: Local ( typeck_results) => Some ( typeck_results) ,
2074
2070
GeneratorData :: Foreign ( _) => None ,
@@ -2641,10 +2637,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
2641
2637
if is_future
2642
2638
&& obligated_types. last ( ) . map_or ( false , |ty| match ty. kind ( ) {
2643
2639
ty:: Generator ( last_def_id, ..) => {
2644
- matches ! (
2645
- tcx. generator_kind( last_def_id) ,
2646
- Some ( GeneratorKind :: Async ( ..) )
2647
- )
2640
+ tcx. generator_is_async ( * last_def_id)
2648
2641
}
2649
2642
_ => false ,
2650
2643
} )
0 commit comments