@@ -5289,6 +5289,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
52895289 expected : Ty < ' tcx > ,
52905290 found : Ty < ' tcx > ,
52915291 ) {
5292+ debug ! ( "suggest_missing_await: expr={:?} expected={:?}, found={:?}" , expr, expected, found) ;
52925293 // `.await` is not permitted outside of `async` bodies, so don't bother to suggest if the
52935294 // body isn't `async`.
52945295 let item_id = self . tcx ( ) . hir ( ) . get_parent_node ( self . body_id ) ;
@@ -5306,22 +5307,33 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
53065307 . next ( )
53075308 . unwrap ( )
53085309 . 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+
53095320 let predicate =
53105321 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,
53215323 ty : expected,
53225324 } ) ) ;
53235325 let obligation = traits:: Obligation :: new ( self . misc ( sp) , self . param_env , predicate) ;
53245326 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+
53255337 if self . infcx . predicate_may_hold ( & obligation) {
53265338 debug ! ( "suggest_missing_await: obligation held: {:?}" , obligation) ;
53275339 if let Ok ( code) = self . sess ( ) . source_map ( ) . span_to_snippet ( sp) {
0 commit comments