@@ -53,7 +53,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
53
53
// First, we instantiate each bound region in the supertype with a
54
54
// fresh placeholder region.
55
55
let ( b_prime, placeholder_map) =
56
- self . infcx . replace_late_bound_regions_with_placeholders ( b) ;
56
+ self . infcx . replace_bound_vars_with_placeholders ( b) ;
57
57
58
58
// Next, we instantiate each bound region in the subtype
59
59
// with a fresh region variable. These region variables --
@@ -115,7 +115,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
115
115
// First, we instantiate each bound region in the matcher
116
116
// with a placeholder region.
117
117
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) ;
119
119
120
120
debug ! ( "higher_ranked_match: a_match={:?}" , a_match) ;
121
121
debug ! ( "higher_ranked_match: placeholder_map={:?}" , placeholder_map) ;
@@ -314,10 +314,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
314
314
region_vars
315
315
}
316
316
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.
321
321
///
322
322
/// **Important:** you must call this function from within a snapshot.
323
323
/// Moreover, before committing the snapshot, you must eventually call
@@ -330,26 +330,37 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
330
330
/// the [rustc guide].
331
331
///
332
332
/// [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 > (
334
334
& self ,
335
- binder : & ty:: Binder < T > ,
335
+ binder : & ty:: Binder < T >
336
336
) -> ( T , PlaceholderMap < ' tcx > )
337
337
where
338
- T : TypeFoldable < ' tcx > ,
338
+ T : TypeFoldable < ' tcx >
339
339
{
340
340
let next_universe = self . create_next_universe ( ) ;
341
341
342
- let ( result , map ) = self . tcx . replace_late_bound_regions ( binder , |br| {
342
+ let fld_r = |br| {
343
343
self . tcx . mk_region ( ty:: RePlaceholder ( ty:: PlaceholderRegion {
344
344
universe : next_universe,
345
345
name : br,
346
346
} ) )
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) ;
348
357
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
+ ) ;
353
364
354
365
( result, map)
355
366
}
@@ -530,7 +541,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
530
541
531
542
/// Pops the placeholder regions found in `placeholder_map` from the region
532
543
/// 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
534
545
/// commit the enclosing snapshot (if you do not commit, e.g. within a
535
546
/// probe or as a result of an error, then this is not necessary, as
536
547
/// popping happens as part of the rollback).
0 commit comments