@@ -53,7 +53,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
5353 // First, we instantiate each bound region in the supertype with a
5454 // fresh placeholder region.
5555 let ( b_prime, placeholder_map) =
56- self . infcx . replace_late_bound_regions_with_placeholders ( b) ;
56+ self . infcx . replace_bound_vars_with_placeholders ( b) ;
5757
5858 // Next, we instantiate each bound region in the subtype
5959 // with a fresh region variable. These region variables --
@@ -115,7 +115,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
115115 // First, we instantiate each bound region in the matcher
116116 // with a placeholder region.
117117 let ( ( a_match, a_value) , placeholder_map) =
118- self . infcx . replace_late_bound_regions_with_placeholders ( a_pair) ;
118+ self . infcx . replace_bound_vars_with_placeholders ( a_pair) ;
119119
120120 debug ! ( "higher_ranked_match: a_match={:?}" , a_match) ;
121121 debug ! ( "higher_ranked_match: placeholder_map={:?}" , placeholder_map) ;
@@ -314,10 +314,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
314314 region_vars
315315 }
316316
317- /// Replace all regions bound by `binder` with placeholder regions and
318- /// return a map indicating which bound-region was replaced with what
319- /// placeholder region. This is the first step of checking subtyping
320- /// when higher-ranked things are involved.
317+ /// Replace all regions (resp. types) bound by `binder` with placeholder
318+ /// regions (resp. types) and return a map indicating which bound-region
319+ /// was replaced with what placeholder region. This is the first step of
320+ /// checking subtyping when higher-ranked things are involved.
321321 ///
322322 /// **Important:** you must call this function from within a snapshot.
323323 /// Moreover, before committing the snapshot, you must eventually call
@@ -330,26 +330,37 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
330330 /// the [rustc guide].
331331 ///
332332 /// [rustc guide]: https://rust-lang-nursery.github.io/rustc-guide/traits/hrtb.html
333- pub fn replace_late_bound_regions_with_placeholders < T > (
333+ pub fn replace_bound_vars_with_placeholders < T > (
334334 & self ,
335- binder : & ty:: Binder < T > ,
335+ binder : & ty:: Binder < T >
336336 ) -> ( T , PlaceholderMap < ' tcx > )
337337 where
338- T : TypeFoldable < ' tcx > ,
338+ T : TypeFoldable < ' tcx >
339339 {
340340 let next_universe = self . create_next_universe ( ) ;
341341
342- let ( result , map ) = self . tcx . replace_late_bound_regions ( binder , |br| {
342+ let fld_r = |br| {
343343 self . tcx . mk_region ( ty:: RePlaceholder ( ty:: PlaceholderRegion {
344344 universe : next_universe,
345345 name : br,
346346 } ) )
347- } ) ;
347+ } ;
348+
349+ let fld_t = |bound_ty : ty:: BoundTy | {
350+ self . tcx . mk_ty ( ty:: Placeholder ( ty:: PlaceholderType {
351+ universe : next_universe,
352+ name : bound_ty. var ,
353+ } ) )
354+ } ;
355+
356+ let ( result, map) = self . tcx . replace_bound_vars ( binder, fld_r, fld_t) ;
348357
349- debug ! ( "replace_late_bound_regions_with_placeholders(binder={:?}, result={:?}, map={:?})" ,
350- binder,
351- result,
352- map) ;
358+ debug ! (
359+ "replace_bound_vars_with_placeholders(binder={:?}, result={:?}, map={:?})" ,
360+ binder,
361+ result,
362+ map
363+ ) ;
353364
354365 ( result, map)
355366 }
@@ -530,7 +541,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
530541
531542 /// Pops the placeholder regions found in `placeholder_map` from the region
532543 /// inference context. Whenever you create placeholder regions via
533- /// `replace_late_bound_regions_with_placeholders `, they must be popped before you
544+ /// `replace_bound_vars_with_placeholders `, they must be popped before you
534545 /// commit the enclosing snapshot (if you do not commit, e.g. within a
535546 /// probe or as a result of an error, then this is not necessary, as
536547 /// popping happens as part of the rollback).
0 commit comments