@@ -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" ) ,
@@ -707,7 +711,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
707711 return ;
708712 }
709713
710- let mut suggested_ty = trait_ref. self_ty ( ) ;
714+ let mut suggested_ty = match trait_ref. self_ty ( ) . no_bound_vars ( ) {
715+ Some ( ty) => ty,
716+ None => return ,
717+ } ;
711718
712719 for refs_remaining in 0 ..refs_number {
713720 if let ty:: Ref ( _, inner_ty, _) = suggested_ty. kind {
@@ -829,6 +836,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
829836 span : Span ,
830837 trait_ref : & ty:: Binder < ty:: TraitRef < ' tcx > > ,
831838 ) {
839+ let is_empty_tuple =
840+ |ty : ty:: Binder < Ty < ' _ > > | ty. skip_binder ( ) . kind == ty:: Tuple ( ty:: List :: empty ( ) ) ;
841+
832842 let hir = self . tcx . hir ( ) ;
833843 let parent_node = hir. get_parent_node ( obligation. cause . body_id ) ;
834844 let node = hir. find ( parent_node) ;
@@ -840,7 +850,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
840850 if let hir:: ExprKind :: Block ( blk, _) = & body. value . kind {
841851 if sig. decl . output . span ( ) . overlaps ( span)
842852 && blk. expr . is_none ( )
843- && "()" == & trait_ref. self_ty ( ) . to_string ( )
853+ && is_empty_tuple ( trait_ref. self_ty ( ) )
844854 {
845855 // FIXME(estebank): When encountering a method with a trait
846856 // bound not satisfied in the return type with a body that has
@@ -1271,7 +1281,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
12711281 ObligationCauseCode :: DerivedObligation ( derived_obligation)
12721282 | ObligationCauseCode :: BuiltinDerivedObligation ( derived_obligation)
12731283 | ObligationCauseCode :: ImplDerivedObligation ( derived_obligation) => {
1274- let ty = derived_obligation. parent_trait_ref . self_ty ( ) ;
1284+ let ty = derived_obligation. parent_trait_ref . skip_binder ( ) . self_ty ( ) ;
12751285 debug ! (
12761286 "maybe_note_obligation_cause_for_async_await: \
12771287 parent_trait_ref={:?} self_ty.kind={:?}",
@@ -1917,7 +1927,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
19171927
19181928 let impls_future = self . tcx . type_implements_trait ( (
19191929 future_trait,
1920- self_ty,
1930+ self_ty. skip_binder ( ) ,
19211931 ty:: List :: empty ( ) ,
19221932 obligation. param_env ,
19231933 ) ) ;
@@ -1933,7 +1943,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
19331943 let projection_ty = ty:: ProjectionTy {
19341944 // `T`
19351945 substs : self . tcx . mk_substs_trait (
1936- trait_ref. self_ty ( ) ,
1946+ trait_ref. self_ty ( ) . skip_binder ( ) ,
19371947 self . fresh_substs_for_item ( span, item_def_id) ,
19381948 ) ,
19391949 // `Future::Output`
0 commit comments