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