@@ -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:: {
@@ -2395,19 +2394,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
2395
2394
}
2396
2395
} ;
2397
2396
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
-
2411
2397
let from_generator = tcx. lang_items ( ) . from_generator_fn ( ) . unwrap ( ) ;
2412
2398
2413
2399
// Don't print the tuple of capture types
@@ -2433,13 +2419,13 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
2433
2419
2434
2420
// If the previous type is `from_generator`, this is the future generated by the body of an async function.
2435
2421
// 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 ) ;
2437
2423
debug ! (
2438
2424
?obligated_types,
2439
2425
?is_future,
2440
2426
"note_obligation_cause_code: check for async fn"
2441
2427
) ;
2442
- if opaque_ty_is_future ( def_id )
2428
+ if is_future
2443
2429
&& obligated_types. last ( ) . map_or ( false , |ty| match ty. kind ( ) {
2444
2430
ty:: Opaque ( last_def_id, _) => {
2445
2431
tcx. parent ( * last_def_id) == from_generator
@@ -2464,15 +2450,11 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
2464
2450
}
2465
2451
err. note ( msg. trim_end_matches ( ", " ) )
2466
2452
}
2467
- ty:: Generator ( def_id, _, movability ) => {
2453
+ ty:: Generator ( def_id, _, _ ) => {
2468
2454
let sp = self . tcx . def_span ( def_id) ;
2469
2455
2470
2456
// 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 ( ) ;
2476
2458
err. span_note (
2477
2459
sp,
2478
2460
& format ! ( "required because it's used within this {}" , kind) ,
0 commit comments