@@ -318,7 +318,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
318
318
trait_ref : ty:: PolyTraitRef < ' tcx > ,
319
319
body_id : hir:: HirId ,
320
320
) {
321
- let self_ty = trait_ref. self_ty ( ) ;
321
+ let self_ty = trait_ref. skip_binder ( ) . self_ty ( ) ;
322
322
let ( param_ty, projection) = match & self_ty. kind {
323
323
ty:: Param ( _) => ( true , None ) ,
324
324
ty:: Projection ( projection) => ( false , Some ( projection) ) ,
@@ -524,7 +524,11 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
524
524
trait_ref : & ty:: Binder < ty:: TraitRef < ' tcx > > ,
525
525
points_at_arg : bool ,
526
526
) {
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
+
528
532
let ( def_id, output_ty, callable) = match self_ty. kind {
529
533
ty:: Closure ( def_id, substs) => ( def_id, substs. as_closure ( ) . sig ( ) . output ( ) , "closure" ) ,
530
534
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> {
707
711
return ;
708
712
}
709
713
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
+ } ;
711
718
712
719
for refs_remaining in 0 ..refs_number {
713
720
if let ty:: Ref ( _, inner_ty, _) = suggested_ty. kind {
@@ -829,6 +836,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
829
836
span : Span ,
830
837
trait_ref : & ty:: Binder < ty:: TraitRef < ' tcx > > ,
831
838
) {
839
+ let is_empty_tuple =
840
+ |ty : ty:: Binder < Ty < ' _ > > | ty. skip_binder ( ) . kind == ty:: Tuple ( ty:: List :: empty ( ) ) ;
841
+
832
842
let hir = self . tcx . hir ( ) ;
833
843
let parent_node = hir. get_parent_node ( obligation. cause . body_id ) ;
834
844
let node = hir. find ( parent_node) ;
@@ -840,7 +850,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
840
850
if let hir:: ExprKind :: Block ( blk, _) = & body. value . kind {
841
851
if sig. decl . output . span ( ) . overlaps ( span)
842
852
&& blk. expr . is_none ( )
843
- && "()" == & trait_ref. self_ty ( ) . to_string ( )
853
+ && is_empty_tuple ( trait_ref. self_ty ( ) )
844
854
{
845
855
// FIXME(estebank): When encountering a method with a trait
846
856
// 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> {
1271
1281
ObligationCauseCode :: DerivedObligation ( derived_obligation)
1272
1282
| ObligationCauseCode :: BuiltinDerivedObligation ( derived_obligation)
1273
1283
| 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 ( ) ;
1275
1285
debug ! (
1276
1286
"maybe_note_obligation_cause_for_async_await: \
1277
1287
parent_trait_ref={:?} self_ty.kind={:?}",
@@ -1917,7 +1927,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1917
1927
1918
1928
let impls_future = self . tcx . type_implements_trait ( (
1919
1929
future_trait,
1920
- self_ty,
1930
+ self_ty. skip_binder ( ) ,
1921
1931
ty:: List :: empty ( ) ,
1922
1932
obligation. param_env ,
1923
1933
) ) ;
@@ -1933,7 +1943,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1933
1943
let projection_ty = ty:: ProjectionTy {
1934
1944
// `T`
1935
1945
substs : self . tcx . mk_substs_trait (
1936
- trait_ref. self_ty ( ) ,
1946
+ trait_ref. self_ty ( ) . skip_binder ( ) ,
1937
1947
self . fresh_substs_for_item ( span, item_def_id) ,
1938
1948
) ,
1939
1949
// `Future::Output`
0 commit comments