@@ -8,7 +8,6 @@ use crate::infer::InferCtxt;
8
8
use crate :: traits:: normalize_to;
9
9
10
10
use hir:: HirId ;
11
- use rustc_ast:: Movability ;
12
11
use rustc_data_structures:: fx:: FxHashSet ;
13
12
use rustc_data_structures:: stack:: ensure_sufficient_stack;
14
13
use rustc_errors:: {
@@ -2406,19 +2405,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
2406
2405
}
2407
2406
} ;
2408
2407
2409
- let future_trait = self . tcx . lang_items ( ) . future_trait ( ) . unwrap ( ) ;
2410
- let opaque_ty_is_future = |def_id| {
2411
- self . tcx . explicit_item_bounds ( def_id) . iter ( ) . any ( |( predicate, _) | {
2412
- if let ty:: PredicateKind :: Trait ( trait_predicate) =
2413
- predicate. kind ( ) . skip_binder ( )
2414
- {
2415
- trait_predicate. trait_ref . def_id == future_trait
2416
- } else {
2417
- false
2418
- }
2419
- } )
2420
- } ;
2421
-
2422
2408
let from_generator = tcx. lang_items ( ) . from_generator_fn ( ) . unwrap ( ) ;
2423
2409
2424
2410
// Don't print the tuple of capture types
@@ -2444,13 +2430,13 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
2444
2430
2445
2431
// If the previous type is `from_generator`, this is the future generated by the body of an async function.
2446
2432
// Avoid printing it twice (it was already printed in the `ty::Generator` arm below).
2447
- let is_future = opaque_ty_is_future ( def_id ) ;
2433
+ let is_future = tcx . ty_is_opaque_future ( ty ) ;
2448
2434
debug ! (
2449
2435
?obligated_types,
2450
2436
?is_future,
2451
2437
"note_obligation_cause_code: check for async fn"
2452
2438
) ;
2453
- if opaque_ty_is_future ( def_id )
2439
+ if is_future
2454
2440
&& obligated_types. last ( ) . map_or ( false , |ty| match ty. kind ( ) {
2455
2441
ty:: Opaque ( last_def_id, _) => {
2456
2442
tcx. parent ( * last_def_id) == from_generator
@@ -2475,15 +2461,11 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
2475
2461
}
2476
2462
err. note ( msg. trim_end_matches ( ", " ) )
2477
2463
}
2478
- ty:: Generator ( def_id, _, movability ) => {
2464
+ ty:: Generator ( def_id, _, _ ) => {
2479
2465
let sp = self . tcx . def_span ( def_id) ;
2480
2466
2481
2467
// Special-case this to say "async block" instead of `[static generator]`.
2482
- let kind = if * movability == Movability :: Static {
2483
- "async block"
2484
- } else {
2485
- "generator"
2486
- } ;
2468
+ let kind = tcx. generator_kind ( def_id) . unwrap ( ) ;
2487
2469
err. span_note (
2488
2470
sp,
2489
2471
& format ! ( "required because it's used within this {}" , kind) ,
0 commit comments