@@ -318,7 +318,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
318318 trait_ref : ty:: PolyTraitRef < ' tcx > ,
319319 body_id : hir:: HirId ,
320320 ) {
321- let self_ty = trait_ref. self_ty ( ) ;
321+ let self_ty = trait_ref. skip_binder ( ) . self_ty ( ) ;
322322 let ( param_ty, projection) = match & self_ty. kind {
323323 ty:: Param ( _) => ( true , None ) ,
324324 ty:: Projection ( projection) => ( false , Some ( projection) ) ,
@@ -524,7 +524,11 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
524524 trait_ref : & ty:: Binder < ty:: TraitRef < ' tcx > > ,
525525 points_at_arg : bool ,
526526 ) {
527- let self_ty = trait_ref. self_ty ( ) ;
527+ let self_ty = match trait_ref. self_ty ( ) . no_bound_vars ( ) {
528+ None => return ,
529+ Some ( ty) => ty,
530+ } ;
531+
528532 let ( def_id, output_ty, callable) = match self_ty. kind {
529533 ty:: Closure ( def_id, substs) => ( def_id, substs. as_closure ( ) . sig ( ) . output ( ) , "closure" ) ,
530534 ty:: FnDef ( def_id, _) => ( def_id, self_ty. fn_sig ( self . tcx ) . output ( ) , "function" ) ,
@@ -829,6 +833,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
829833 span : Span ,
830834 trait_ref : & ty:: Binder < ty:: TraitRef < ' tcx > > ,
831835 ) {
836+ let is_empty_tuple =
837+ |ty : ty:: Binder < Ty < ' _ > > | ty. skip_binder ( ) . kind == ty:: Tuple ( ty:: List :: empty ( ) ) ;
838+
832839 let hir = self . tcx . hir ( ) ;
833840 let parent_node = hir. get_parent_node ( obligation. cause . body_id ) ;
834841 let node = hir. find ( parent_node) ;
@@ -840,7 +847,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
840847 if let hir:: ExprKind :: Block ( blk, _) = & body. value . kind {
841848 if sig. decl . output . span ( ) . overlaps ( span)
842849 && blk. expr . is_none ( )
843- && "()" == & trait_ref. self_ty ( ) . to_string ( )
850+ && is_empty_tuple ( trait_ref. self_ty ( ) )
844851 {
845852 // FIXME(estebank): When encountering a method with a trait
846853 // bound not satisfied in the return type with a body that has
@@ -1271,7 +1278,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
12711278 ObligationCauseCode :: DerivedObligation ( derived_obligation)
12721279 | ObligationCauseCode :: BuiltinDerivedObligation ( derived_obligation)
12731280 | ObligationCauseCode :: ImplDerivedObligation ( derived_obligation) => {
1274- let ty = derived_obligation. parent_trait_ref . self_ty ( ) ;
1281+ let ty = derived_obligation. parent_trait_ref . skip_binder ( ) . self_ty ( ) ;
12751282 debug ! (
12761283 "maybe_note_obligation_cause_for_async_await: \
12771284 parent_trait_ref={:?} self_ty.kind={:?}",
@@ -1911,7 +1918,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
19111918
19121919 let impls_future = self . tcx . type_implements_trait ( (
19131920 future_trait,
1914- self_ty,
1921+ self_ty. skip_binder ( ) ,
19151922 ty:: List :: empty ( ) ,
19161923 obligation. param_env ,
19171924 ) ) ;
@@ -1927,7 +1934,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
19271934 let projection_ty = ty:: ProjectionTy {
19281935 // `T`
19291936 substs : self . tcx . mk_substs_trait (
1930- trait_ref. self_ty ( ) ,
1937+ trait_ref. self_ty ( ) . skip_binder ( ) ,
19311938 self . fresh_substs_for_item ( span, item_def_id) ,
19321939 ) ,
19331940 // `Future::Output`
0 commit comments