Skip to content

Commit 03a8a4f

Browse files
Replacing bound vars is actually instantiating a binder
1 parent bd39bbb commit 03a8a4f

File tree

28 files changed

+67
-60
lines changed

28 files changed

+67
-60
lines changed

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11391139
if let ty::Adt(def, substs) = ty.kind()
11401140
&& Some(def.did()) == tcx.lang_items().pin_type()
11411141
&& let ty::Ref(_, _, hir::Mutability::Mut) = substs.type_at(0).kind()
1142-
&& let self_ty = infcx.replace_bound_vars_with_fresh_vars(
1142+
&& let self_ty = infcx.instantiate_binder_with_fresh_vars(
11431143
fn_call_span,
11441144
LateBoundRegionConversionTime::FnCall,
11451145
tcx.fn_sig(method_did).subst(tcx, method_substs).input(0),

compiler/rustc_borrowck/src/type_check/input_output.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
3838
// so that they represent the view from "inside" the closure.
3939
let user_provided_sig = self
4040
.instantiate_canonical_with_fresh_inference_vars(body.span, &user_provided_poly_sig);
41-
let user_provided_sig = self.infcx.replace_bound_vars_with_fresh_vars(
41+
let user_provided_sig = self.infcx.instantiate_binder_with_fresh_vars(
4242
body.span,
4343
LateBoundRegionConversionTime::FnCall,
4444
user_provided_sig,

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ fn compare_method_predicate_entailment<'tcx>(
246246

247247
let mut wf_tys = FxIndexSet::default();
248248

249-
let unnormalized_impl_sig = infcx.replace_bound_vars_with_fresh_vars(
249+
let unnormalized_impl_sig = infcx.instantiate_binder_with_fresh_vars(
250250
impl_m_span,
251251
infer::HigherRankedType,
252252
tcx.fn_sig(impl_m.def_id).subst_identity(),
@@ -640,7 +640,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
640640
let impl_sig = ocx.normalize(
641641
&norm_cause,
642642
param_env,
643-
infcx.replace_bound_vars_with_fresh_vars(
643+
infcx.instantiate_binder_with_fresh_vars(
644644
return_span,
645645
infer::HigherRankedType,
646646
tcx.fn_sig(impl_m.def_id).subst_identity(),

compiler/rustc_hir_typeck/src/callee.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
156156
// fnmut vs fnonce. If so, we have to defer further processing.
157157
if self.closure_kind(substs).is_none() {
158158
let closure_sig = substs.as_closure().sig();
159-
let closure_sig = self.replace_bound_vars_with_fresh_vars(
159+
let closure_sig = self.instantiate_binder_with_fresh_vars(
160160
call_expr.span,
161161
infer::FnCall,
162162
closure_sig,
@@ -437,7 +437,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
437437
// renormalize the associated types at this point, since they
438438
// previously appeared within a `Binder<>` and hence would not
439439
// have been normalized before.
440-
let fn_sig = self.replace_bound_vars_with_fresh_vars(call_expr.span, infer::FnCall, fn_sig);
440+
let fn_sig = self.instantiate_binder_with_fresh_vars(call_expr.span, infer::FnCall, fn_sig);
441441
let fn_sig = self.normalize(call_expr.span, fn_sig);
442442

443443
// Call the generic checker.

compiler/rustc_hir_typeck/src/closure.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
544544
)
545545
.map(|(hir_ty, &supplied_ty)| {
546546
// Instantiate (this part of..) S to S', i.e., with fresh variables.
547-
self.replace_bound_vars_with_fresh_vars(
547+
self.instantiate_binder_with_fresh_vars(
548548
hir_ty.span,
549549
LateBoundRegionConversionTime::FnCall,
550550
// (*) binder moved to here
@@ -566,7 +566,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
566566
all_obligations.extend(obligations);
567567
}
568568

569-
let supplied_output_ty = self.replace_bound_vars_with_fresh_vars(
569+
let supplied_output_ty = self.instantiate_binder_with_fresh_vars(
570570
decl.output.span(),
571571
LateBoundRegionConversionTime::FnCall,
572572
supplied_sig.output(),

compiler/rustc_hir_typeck/src/expr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
568568
// placeholder lifetimes with probing, we just replace higher lifetimes
569569
// with fresh vars.
570570
let span = args.get(i).map(|a| a.span).unwrap_or(expr.span);
571-
let input = self.replace_bound_vars_with_fresh_vars(
571+
let input = self.instantiate_binder_with_fresh_vars(
572572
span,
573573
infer::LateBoundRegionConversionTime::FnCall,
574574
fn_sig.input(i),
@@ -586,7 +586,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
586586
// Also, as we just want to check sizedness, instead of introducing
587587
// placeholder lifetimes with probing, we just replace higher lifetimes
588588
// with fresh vars.
589-
let output = self.replace_bound_vars_with_fresh_vars(
589+
let output = self.instantiate_binder_with_fresh_vars(
590590
expr.span,
591591
infer::LateBoundRegionConversionTime::FnCall,
592592
fn_sig.output(),

compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> {
289289
item_segment: &hir::PathSegment<'_>,
290290
poly_trait_ref: ty::PolyTraitRef<'tcx>,
291291
) -> Ty<'tcx> {
292-
let trait_ref = self.replace_bound_vars_with_fresh_vars(
292+
let trait_ref = self.instantiate_binder_with_fresh_vars(
293293
span,
294294
infer::LateBoundRegionConversionTime::AssocTypeProjection(item_def_id),
295295
poly_trait_ref,

compiler/rustc_hir_typeck/src/method/confirm.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
262262
let original_poly_trait_ref = principal.with_self_ty(this.tcx, object_ty);
263263
let upcast_poly_trait_ref = this.upcast(original_poly_trait_ref, trait_def_id);
264264
let upcast_trait_ref =
265-
this.replace_bound_vars_with_fresh_vars(upcast_poly_trait_ref);
265+
this.instantiate_binder_with_fresh_vars(upcast_poly_trait_ref);
266266
debug!(
267267
"original_poly_trait_ref={:?} upcast_trait_ref={:?} target_trait={:?}",
268268
original_poly_trait_ref, upcast_trait_ref, trait_def_id
@@ -285,7 +285,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
285285
probe::WhereClausePick(poly_trait_ref) => {
286286
// Where clauses can have bound regions in them. We need to instantiate
287287
// those to convert from a poly-trait-ref to a trait-ref.
288-
self.replace_bound_vars_with_fresh_vars(poly_trait_ref).substs
288+
self.instantiate_binder_with_fresh_vars(poly_trait_ref).substs
289289
}
290290
}
291291
}
@@ -506,7 +506,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
506506
let sig = self.tcx.fn_sig(def_id).subst(self.tcx, all_substs);
507507
debug!("type scheme substituted, sig={:?}", sig);
508508

509-
let sig = self.replace_bound_vars_with_fresh_vars(sig);
509+
let sig = self.instantiate_binder_with_fresh_vars(sig);
510510
debug!("late-bound lifetimes from method instantiated, sig={:?}", sig);
511511

512512
(sig, method_predicates)
@@ -625,10 +625,10 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
625625
upcast_trait_refs.into_iter().next().unwrap()
626626
}
627627

628-
fn replace_bound_vars_with_fresh_vars<T>(&self, value: ty::Binder<'tcx, T>) -> T
628+
fn instantiate_binder_with_fresh_vars<T>(&self, value: ty::Binder<'tcx, T>) -> T
629629
where
630630
T: TypeFoldable<'tcx> + Copy,
631631
{
632-
self.fcx.replace_bound_vars_with_fresh_vars(self.span, infer::FnCall, value)
632+
self.fcx.instantiate_binder_with_fresh_vars(self.span, infer::FnCall, value)
633633
}
634634
}

compiler/rustc_hir_typeck/src/method/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
401401
// with bound regions.
402402
let fn_sig = tcx.fn_sig(def_id).subst(self.tcx, substs);
403403
let fn_sig =
404-
self.replace_bound_vars_with_fresh_vars(obligation.cause.span, infer::FnCall, fn_sig);
404+
self.instantiate_binder_with_fresh_vars(obligation.cause.span, infer::FnCall, fn_sig);
405405

406406
let InferOk { value, obligations: o } =
407407
self.at(&obligation.cause, self.param_env).normalize(fn_sig);

compiler/rustc_hir_typeck/src/method/probe.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
924924
ty::AssocKind::Fn => self.probe(|_| {
925925
let substs = self.fresh_substs_for_item(self.span, method.def_id);
926926
let fty = self.tcx.fn_sig(method.def_id).subst(self.tcx, substs);
927-
let fty = self.replace_bound_vars_with_fresh_vars(self.span, infer::FnCall, fty);
927+
let fty = self.instantiate_binder_with_fresh_vars(self.span, infer::FnCall, fty);
928928

929929
if let Some(self_ty) = self_ty {
930930
if self

0 commit comments

Comments
 (0)