@@ -5289,6 +5289,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
5289
5289
expected : Ty < ' tcx > ,
5290
5290
found : Ty < ' tcx > ,
5291
5291
) {
5292
+ debug ! ( "suggest_missing_await: expr={:?} expected={:?}, found={:?}" , expr, expected, found) ;
5292
5293
// `.await` is not permitted outside of `async` bodies, so don't bother to suggest if the
5293
5294
// body isn't `async`.
5294
5295
let item_id = self . tcx ( ) . hir ( ) . get_parent_node ( self . body_id ) ;
@@ -5306,22 +5307,33 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
5306
5307
. next ( )
5307
5308
. unwrap ( )
5308
5309
. def_id ;
5310
+ // `<T as Future>::Output`
5311
+ let projection_ty = ty:: ProjectionTy {
5312
+ // `T`
5313
+ substs : self
5314
+ . tcx
5315
+ . mk_substs_trait ( found, self . fresh_substs_for_item ( sp, item_def_id) ) ,
5316
+ // `Future::Output`
5317
+ item_def_id,
5318
+ } ;
5319
+
5309
5320
let predicate =
5310
5321
ty:: Predicate :: Projection ( ty:: Binder :: bind ( ty:: ProjectionPredicate {
5311
- // `<T as Future>::Output`
5312
- projection_ty : ty:: ProjectionTy {
5313
- // `T`
5314
- substs : self . tcx . mk_substs_trait (
5315
- found,
5316
- self . fresh_substs_for_item ( sp, item_def_id) ,
5317
- ) ,
5318
- // `Future::Output`
5319
- item_def_id,
5320
- } ,
5322
+ projection_ty,
5321
5323
ty : expected,
5322
5324
} ) ) ;
5323
5325
let obligation = traits:: Obligation :: new ( self . misc ( sp) , self . param_env , predicate) ;
5324
5326
debug ! ( "suggest_missing_await: trying obligation {:?}" , obligation) ;
5327
+
5328
+ //let try_trait_def_id = self.tcx.require_lang_item(lang_items::TryTraitLangItem, None);
5329
+ //let try_trait_ref = ty::TraitRef {
5330
+ // def_id: try_trait_def_id,
5331
+ // substs: self.tcx.mk_substs_trait(self.tcx.type_of(item_def_id), &[]),
5332
+ //};
5333
+ //let try_obligation = traits::Obligation::new(self.misc(sp), self.param_env, try_trait_ref.without_const().to_predicate());
5334
+ //let try_trait_is_implemented = self.predicate_must_hold_modulo_regions(&try_obligation);
5335
+ //debug!("suggest_missing_await: try trait is implemented {}", try_trait_is_implemented);
5336
+
5325
5337
if self . infcx . predicate_may_hold ( & obligation) {
5326
5338
debug ! ( "suggest_missing_await: obligation held: {:?}" , obligation) ;
5327
5339
if let Ok ( code) = self . sess ( ) . source_map ( ) . span_to_snippet ( sp) {
0 commit comments