@@ -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" ) ,
@@ -829,6 +833,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
829
833
span : Span ,
830
834
trait_ref : & ty:: Binder < ty:: TraitRef < ' tcx > > ,
831
835
) {
836
+ let is_empty_tuple =
837
+ |ty : ty:: Binder < Ty < ' _ > > | ty. skip_binder ( ) . kind == ty:: Tuple ( ty:: List :: empty ( ) ) ;
838
+
832
839
let hir = self . tcx . hir ( ) ;
833
840
let parent_node = hir. get_parent_node ( obligation. cause . body_id ) ;
834
841
let node = hir. find ( parent_node) ;
@@ -840,7 +847,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
840
847
if let hir:: ExprKind :: Block ( blk, _) = & body. value . kind {
841
848
if sig. decl . output . span ( ) . overlaps ( span)
842
849
&& blk. expr . is_none ( )
843
- && "()" == & trait_ref. self_ty ( ) . to_string ( )
850
+ && is_empty_tuple ( trait_ref. self_ty ( ) )
844
851
{
845
852
// FIXME(estebank): When encountering a method with a trait
846
853
// 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> {
1271
1278
ObligationCauseCode :: DerivedObligation ( derived_obligation)
1272
1279
| ObligationCauseCode :: BuiltinDerivedObligation ( derived_obligation)
1273
1280
| 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 ( ) ;
1275
1282
debug ! (
1276
1283
"maybe_note_obligation_cause_for_async_await: \
1277
1284
parent_trait_ref={:?} self_ty.kind={:?}",
@@ -1911,7 +1918,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1911
1918
1912
1919
let impls_future = self . tcx . type_implements_trait ( (
1913
1920
future_trait,
1914
- self_ty,
1921
+ self_ty. skip_binder ( ) ,
1915
1922
ty:: List :: empty ( ) ,
1916
1923
obligation. param_env ,
1917
1924
) ) ;
@@ -1927,7 +1934,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1927
1934
let projection_ty = ty:: ProjectionTy {
1928
1935
// `T`
1929
1936
substs : self . tcx . mk_substs_trait (
1930
- trait_ref. self_ty ( ) ,
1937
+ trait_ref. self_ty ( ) . skip_binder ( ) ,
1931
1938
self . fresh_substs_for_item ( span, item_def_id) ,
1932
1939
) ,
1933
1940
// `Future::Output`
0 commit comments