bound_vars -> infer: don't return lt map
This commit is contained in:
parent
543ca7d9e7
commit
cc013e05b4
@ -60,13 +60,11 @@ pub(super) fn equate_inputs_and_outputs(
|
||||
// Replace the bound items in the fn sig with fresh
|
||||
// variables, so that they represent the view from
|
||||
// "inside" the closure.
|
||||
self.infcx
|
||||
.replace_bound_vars_with_fresh_vars(
|
||||
body.span,
|
||||
LateBoundRegionConversionTime::FnCall,
|
||||
poly_sig,
|
||||
)
|
||||
.0
|
||||
self.infcx.replace_bound_vars_with_fresh_vars(
|
||||
body.span,
|
||||
LateBoundRegionConversionTime::FnCall,
|
||||
poly_sig,
|
||||
)
|
||||
},
|
||||
);
|
||||
}
|
||||
|
@ -38,8 +38,7 @@ pub fn higher_ranked_sub<T>(
|
||||
// with a fresh region variable. These region variables --
|
||||
// but no other pre-existing region variables -- can name
|
||||
// the placeholders.
|
||||
let (a_prime, _) =
|
||||
self.infcx.replace_bound_vars_with_fresh_vars(span, HigherRankedType, a);
|
||||
let a_prime = self.infcx.replace_bound_vars_with_fresh_vars(span, HigherRankedType, a);
|
||||
|
||||
debug!("a_prime={:?}", a_prime);
|
||||
debug!("b_prime={:?}", b_prime);
|
||||
|
@ -1524,7 +1524,7 @@ pub fn replace_bound_vars_with_fresh_vars<T>(
|
||||
span: Span,
|
||||
lbrct: LateBoundRegionConversionTime,
|
||||
value: ty::Binder<'tcx, T>,
|
||||
) -> (T, BTreeMap<ty::BoundRegion, ty::Region<'tcx>>)
|
||||
) -> T
|
||||
where
|
||||
T: TypeFoldable<'tcx>,
|
||||
{
|
||||
@ -1553,8 +1553,7 @@ pub fn replace_bound_vars_with_fresh_vars<T>(
|
||||
)
|
||||
})
|
||||
};
|
||||
let result = self.tcx.replace_bound_vars_uncached(value, fld_r, fld_t, fld_c);
|
||||
(result, region_map)
|
||||
self.tcx.replace_bound_vars_uncached(value, fld_r, fld_t, fld_c)
|
||||
}
|
||||
|
||||
/// See the [`region_constraints::RegionConstraintCollector::verify_generic_bound`] method.
|
||||
|
@ -1536,7 +1536,7 @@ fn report_projection_error(
|
||||
let bound_predicate = predicate.kind();
|
||||
if let ty::PredicateKind::Projection(data) = bound_predicate.skip_binder() {
|
||||
let mut selcx = SelectionContext::new(self);
|
||||
let (data, _) = self.replace_bound_vars_with_fresh_vars(
|
||||
let data = self.replace_bound_vars_with_fresh_vars(
|
||||
obligation.cause.span,
|
||||
infer::LateBoundRegionConversionTime::HigherRankedType,
|
||||
bound_predicate.rebind(data),
|
||||
|
@ -1920,7 +1920,7 @@ fn confirm_param_env_candidate<'cx, 'tcx>(
|
||||
let cause = &obligation.cause;
|
||||
let param_env = obligation.param_env;
|
||||
|
||||
let (cache_entry, _) = infcx.replace_bound_vars_with_fresh_vars(
|
||||
let cache_entry = infcx.replace_bound_vars_with_fresh_vars(
|
||||
cause.span,
|
||||
LateBoundRegionConversionTime::HigherRankedType,
|
||||
poly_cache_entry,
|
||||
|
@ -421,14 +421,11 @@ fn confirm_object_candidate(
|
||||
let object_trait_ref = data.principal().unwrap_or_else(|| {
|
||||
span_bug!(obligation.cause.span, "object candidate with no principal")
|
||||
});
|
||||
let object_trait_ref = self
|
||||
.infcx
|
||||
.replace_bound_vars_with_fresh_vars(
|
||||
obligation.cause.span,
|
||||
HigherRankedType,
|
||||
object_trait_ref,
|
||||
)
|
||||
.0;
|
||||
let object_trait_ref = self.infcx.replace_bound_vars_with_fresh_vars(
|
||||
obligation.cause.span,
|
||||
HigherRankedType,
|
||||
object_trait_ref,
|
||||
);
|
||||
let object_trait_ref = object_trait_ref.with_self_ty(self.tcx(), self_ty);
|
||||
|
||||
let mut nested = vec![];
|
||||
|
@ -1453,7 +1453,7 @@ pub(super) fn match_projection_projections(
|
||||
potentially_unnormalized_candidates: bool,
|
||||
) -> ProjectionMatchesProjection {
|
||||
let mut nested_obligations = Vec::new();
|
||||
let (infer_predicate, _) = self.infcx.replace_bound_vars_with_fresh_vars(
|
||||
let infer_predicate = self.infcx.replace_bound_vars_with_fresh_vars(
|
||||
obligation.cause.span,
|
||||
LateBoundRegionConversionTime::HigherRankedType,
|
||||
env_predicate,
|
||||
|
@ -152,13 +152,11 @@ fn try_overloaded_call_step(
|
||||
// fnmut vs fnonce. If so, we have to defer further processing.
|
||||
if self.closure_kind(substs).is_none() {
|
||||
let closure_sig = substs.as_closure().sig();
|
||||
let closure_sig = self
|
||||
.replace_bound_vars_with_fresh_vars(
|
||||
call_expr.span,
|
||||
infer::FnCall,
|
||||
closure_sig,
|
||||
)
|
||||
.0;
|
||||
let closure_sig = self.replace_bound_vars_with_fresh_vars(
|
||||
call_expr.span,
|
||||
infer::FnCall,
|
||||
closure_sig,
|
||||
);
|
||||
let adjustments = self.adjust_steps(autoderef);
|
||||
self.record_deferred_call_resolution(
|
||||
def_id,
|
||||
@ -503,8 +501,7 @@ fn confirm_builtin_call(
|
||||
// renormalize the associated types at this point, since they
|
||||
// previously appeared within a `Binder<>` and hence would not
|
||||
// have been normalized before.
|
||||
let fn_sig =
|
||||
self.replace_bound_vars_with_fresh_vars(call_expr.span, infer::FnCall, fn_sig).0;
|
||||
let fn_sig = self.replace_bound_vars_with_fresh_vars(call_expr.span, infer::FnCall, fn_sig);
|
||||
let fn_sig = self.normalize_associated_types_in(call_expr.span, fn_sig);
|
||||
|
||||
// Call the generic checker.
|
||||
|
@ -550,7 +550,7 @@ fn check_supplied_sig_against_expectation(
|
||||
expected_sigs.liberated_sig.inputs(), // `liberated_sig` is E'.
|
||||
) {
|
||||
// Instantiate (this part of..) S to S', i.e., with fresh variables.
|
||||
let (supplied_ty, _) = self.infcx.replace_bound_vars_with_fresh_vars(
|
||||
let supplied_ty = self.infcx.replace_bound_vars_with_fresh_vars(
|
||||
hir_ty.span,
|
||||
LateBoundRegionConversionTime::FnCall,
|
||||
supplied_sig.inputs().rebind(supplied_ty),
|
||||
@ -563,7 +563,7 @@ fn check_supplied_sig_against_expectation(
|
||||
all_obligations.extend(obligations);
|
||||
}
|
||||
|
||||
let (supplied_output_ty, _) = self.infcx.replace_bound_vars_with_fresh_vars(
|
||||
let supplied_output_ty = self.infcx.replace_bound_vars_with_fresh_vars(
|
||||
decl.output.span(),
|
||||
LateBoundRegionConversionTime::FnCall,
|
||||
supplied_sig.output(),
|
||||
|
@ -255,7 +255,7 @@ fn compare_predicate_entailment<'tcx>(
|
||||
|
||||
let mut wf_tys = FxHashSet::default();
|
||||
|
||||
let (impl_sig, _) = infcx.replace_bound_vars_with_fresh_vars(
|
||||
let impl_sig = infcx.replace_bound_vars_with_fresh_vars(
|
||||
impl_m_span,
|
||||
infer::HigherRankedType,
|
||||
tcx.fn_sig(impl_m.def_id),
|
||||
|
@ -561,13 +561,11 @@ pub(crate) fn check_expr_path(
|
||||
// placeholder lifetimes with probing, we just replace higher lifetimes
|
||||
// with fresh vars.
|
||||
let span = args.get(i).map(|a| a.span).unwrap_or(expr.span);
|
||||
let input = self
|
||||
.replace_bound_vars_with_fresh_vars(
|
||||
span,
|
||||
infer::LateBoundRegionConversionTime::FnCall,
|
||||
fn_sig.input(i),
|
||||
)
|
||||
.0;
|
||||
let input = self.replace_bound_vars_with_fresh_vars(
|
||||
span,
|
||||
infer::LateBoundRegionConversionTime::FnCall,
|
||||
fn_sig.input(i),
|
||||
);
|
||||
self.require_type_is_sized_deferred(
|
||||
input,
|
||||
span,
|
||||
@ -581,13 +579,11 @@ pub(crate) fn check_expr_path(
|
||||
// Also, as we just want to check sizedness, instead of introducing
|
||||
// placeholder lifetimes with probing, we just replace higher lifetimes
|
||||
// with fresh vars.
|
||||
let output = self
|
||||
.replace_bound_vars_with_fresh_vars(
|
||||
expr.span,
|
||||
infer::LateBoundRegionConversionTime::FnCall,
|
||||
fn_sig.output(),
|
||||
)
|
||||
.0;
|
||||
let output = self.replace_bound_vars_with_fresh_vars(
|
||||
expr.span,
|
||||
infer::LateBoundRegionConversionTime::FnCall,
|
||||
fn_sig.output(),
|
||||
);
|
||||
self.require_type_is_sized_deferred(output, expr.span, traits::SizedReturnType);
|
||||
}
|
||||
|
||||
|
@ -256,7 +256,7 @@ fn projected_ty_from_poly_trait_ref(
|
||||
item_segment: &hir::PathSegment<'_>,
|
||||
poly_trait_ref: ty::PolyTraitRef<'tcx>,
|
||||
) -> Ty<'tcx> {
|
||||
let (trait_ref, _) = self.replace_bound_vars_with_fresh_vars(
|
||||
let trait_ref = self.replace_bound_vars_with_fresh_vars(
|
||||
span,
|
||||
infer::LateBoundRegionConversionTime::AssocTypeProjection(item_def_id),
|
||||
poly_trait_ref,
|
||||
|
@ -85,7 +85,7 @@ fn suggest_fn_call(
|
||||
_ => return false,
|
||||
};
|
||||
|
||||
let sig = self.replace_bound_vars_with_fresh_vars(expr.span, infer::FnCall, sig).0;
|
||||
let sig = self.replace_bound_vars_with_fresh_vars(expr.span, infer::FnCall, sig);
|
||||
let sig = self.normalize_associated_types_in(expr.span, sig);
|
||||
if self.can_coerce(sig.output(), expected) {
|
||||
let (mut sugg_call, applicability) = if sig.inputs().is_empty() {
|
||||
|
@ -574,6 +574,6 @@ fn replace_bound_vars_with_fresh_vars<T>(&self, value: ty::Binder<'tcx, T>) -> T
|
||||
where
|
||||
T: TypeFoldable<'tcx>,
|
||||
{
|
||||
self.fcx.replace_bound_vars_with_fresh_vars(self.span, infer::FnCall, value).0
|
||||
self.fcx.replace_bound_vars_with_fresh_vars(self.span, infer::FnCall, value)
|
||||
}
|
||||
}
|
||||
|
@ -462,7 +462,7 @@ fn construct_obligation_for_trait(
|
||||
// may reference those regions.
|
||||
let fn_sig = tcx.bound_fn_sig(def_id);
|
||||
let fn_sig = fn_sig.subst(self.tcx, substs);
|
||||
let fn_sig = self.replace_bound_vars_with_fresh_vars(span, infer::FnCall, fn_sig).0;
|
||||
let fn_sig = self.replace_bound_vars_with_fresh_vars(span, infer::FnCall, fn_sig);
|
||||
|
||||
let InferOk { value, obligations: o } = if is_op {
|
||||
self.normalize_op_associated_types_in_as_infer_ok(span, fn_sig, opt_input_expr)
|
||||
|
@ -905,7 +905,7 @@ pub fn matches_return_type(
|
||||
self.probe(|_| {
|
||||
let substs = self.fresh_substs_for_item(self.span, method.def_id);
|
||||
let fty = fty.subst(self.tcx, substs);
|
||||
let (fty, _) =
|
||||
let fty =
|
||||
self.replace_bound_vars_with_fresh_vars(self.span, infer::FnCall, fty);
|
||||
|
||||
if let Some(self_ty) = self_ty {
|
||||
|
Loading…
Reference in New Issue
Block a user