bound_vars -> infer: don't return lt map

This commit is contained in:
lcnr 2022-06-02 12:48:56 +02:00
parent 543ca7d9e7
commit cc013e05b4
16 changed files with 40 additions and 54 deletions

View file

@ -60,13 +60,11 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
// Replace the bound items in the fn sig with fresh // Replace the bound items in the fn sig with fresh
// variables, so that they represent the view from // variables, so that they represent the view from
// "inside" the closure. // "inside" the closure.
self.infcx self.infcx.replace_bound_vars_with_fresh_vars(
.replace_bound_vars_with_fresh_vars(
body.span, body.span,
LateBoundRegionConversionTime::FnCall, LateBoundRegionConversionTime::FnCall,
poly_sig, poly_sig,
) )
.0
}, },
); );
} }

View file

@ -38,8 +38,7 @@ impl<'a, 'tcx> CombineFields<'a, 'tcx> {
// with a fresh region variable. These region variables -- // with a fresh region variable. These region variables --
// but no other pre-existing region variables -- can name // but no other pre-existing region variables -- can name
// the placeholders. // the placeholders.
let (a_prime, _) = let a_prime = self.infcx.replace_bound_vars_with_fresh_vars(span, HigherRankedType, a);
self.infcx.replace_bound_vars_with_fresh_vars(span, HigherRankedType, a);
debug!("a_prime={:?}", a_prime); debug!("a_prime={:?}", a_prime);
debug!("b_prime={:?}", b_prime); debug!("b_prime={:?}", b_prime);

View file

@ -1524,7 +1524,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
span: Span, span: Span,
lbrct: LateBoundRegionConversionTime, lbrct: LateBoundRegionConversionTime,
value: ty::Binder<'tcx, T>, value: ty::Binder<'tcx, T>,
) -> (T, BTreeMap<ty::BoundRegion, ty::Region<'tcx>>) ) -> T
where where
T: TypeFoldable<'tcx>, T: TypeFoldable<'tcx>,
{ {
@ -1553,8 +1553,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
) )
}) })
}; };
let result = self.tcx.replace_bound_vars_uncached(value, fld_r, fld_t, fld_c); self.tcx.replace_bound_vars_uncached(value, fld_r, fld_t, fld_c)
(result, region_map)
} }
/// See the [`region_constraints::RegionConstraintCollector::verify_generic_bound`] method. /// See the [`region_constraints::RegionConstraintCollector::verify_generic_bound`] method.

View file

@ -1536,7 +1536,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
let bound_predicate = predicate.kind(); let bound_predicate = predicate.kind();
if let ty::PredicateKind::Projection(data) = bound_predicate.skip_binder() { if let ty::PredicateKind::Projection(data) = bound_predicate.skip_binder() {
let mut selcx = SelectionContext::new(self); 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, obligation.cause.span,
infer::LateBoundRegionConversionTime::HigherRankedType, infer::LateBoundRegionConversionTime::HigherRankedType,
bound_predicate.rebind(data), bound_predicate.rebind(data),

View file

@ -1920,7 +1920,7 @@ fn confirm_param_env_candidate<'cx, 'tcx>(
let cause = &obligation.cause; let cause = &obligation.cause;
let param_env = obligation.param_env; 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, cause.span,
LateBoundRegionConversionTime::HigherRankedType, LateBoundRegionConversionTime::HigherRankedType,
poly_cache_entry, poly_cache_entry,

View file

@ -421,14 +421,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let object_trait_ref = data.principal().unwrap_or_else(|| { let object_trait_ref = data.principal().unwrap_or_else(|| {
span_bug!(obligation.cause.span, "object candidate with no principal") span_bug!(obligation.cause.span, "object candidate with no principal")
}); });
let object_trait_ref = self let object_trait_ref = self.infcx.replace_bound_vars_with_fresh_vars(
.infcx
.replace_bound_vars_with_fresh_vars(
obligation.cause.span, obligation.cause.span,
HigherRankedType, HigherRankedType,
object_trait_ref, object_trait_ref,
) );
.0;
let object_trait_ref = object_trait_ref.with_self_ty(self.tcx(), self_ty); let object_trait_ref = object_trait_ref.with_self_ty(self.tcx(), self_ty);
let mut nested = vec![]; let mut nested = vec![];

View file

@ -1453,7 +1453,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
potentially_unnormalized_candidates: bool, potentially_unnormalized_candidates: bool,
) -> ProjectionMatchesProjection { ) -> ProjectionMatchesProjection {
let mut nested_obligations = Vec::new(); 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, obligation.cause.span,
LateBoundRegionConversionTime::HigherRankedType, LateBoundRegionConversionTime::HigherRankedType,
env_predicate, env_predicate,

View file

@ -152,13 +152,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// fnmut vs fnonce. If so, we have to defer further processing. // fnmut vs fnonce. If so, we have to defer further processing.
if self.closure_kind(substs).is_none() { if self.closure_kind(substs).is_none() {
let closure_sig = substs.as_closure().sig(); let closure_sig = substs.as_closure().sig();
let closure_sig = self let closure_sig = self.replace_bound_vars_with_fresh_vars(
.replace_bound_vars_with_fresh_vars(
call_expr.span, call_expr.span,
infer::FnCall, infer::FnCall,
closure_sig, closure_sig,
) );
.0;
let adjustments = self.adjust_steps(autoderef); let adjustments = self.adjust_steps(autoderef);
self.record_deferred_call_resolution( self.record_deferred_call_resolution(
def_id, def_id,
@ -503,8 +501,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// renormalize the associated types at this point, since they // renormalize the associated types at this point, since they
// previously appeared within a `Binder<>` and hence would not // previously appeared within a `Binder<>` and hence would not
// have been normalized before. // have been normalized before.
let fn_sig = let fn_sig = self.replace_bound_vars_with_fresh_vars(call_expr.span, infer::FnCall, fn_sig);
self.replace_bound_vars_with_fresh_vars(call_expr.span, infer::FnCall, fn_sig).0;
let fn_sig = self.normalize_associated_types_in(call_expr.span, fn_sig); let fn_sig = self.normalize_associated_types_in(call_expr.span, fn_sig);
// Call the generic checker. // Call the generic checker.

View file

@ -550,7 +550,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
expected_sigs.liberated_sig.inputs(), // `liberated_sig` is E'. expected_sigs.liberated_sig.inputs(), // `liberated_sig` is E'.
) { ) {
// Instantiate (this part of..) S to S', i.e., with fresh variables. // 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, hir_ty.span,
LateBoundRegionConversionTime::FnCall, LateBoundRegionConversionTime::FnCall,
supplied_sig.inputs().rebind(supplied_ty), supplied_sig.inputs().rebind(supplied_ty),
@ -563,7 +563,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
all_obligations.extend(obligations); 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(), decl.output.span(),
LateBoundRegionConversionTime::FnCall, LateBoundRegionConversionTime::FnCall,
supplied_sig.output(), supplied_sig.output(),

View file

@ -255,7 +255,7 @@ fn compare_predicate_entailment<'tcx>(
let mut wf_tys = FxHashSet::default(); 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, impl_m_span,
infer::HigherRankedType, infer::HigherRankedType,
tcx.fn_sig(impl_m.def_id), tcx.fn_sig(impl_m.def_id),

View file

@ -561,13 +561,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// placeholder lifetimes with probing, we just replace higher lifetimes // placeholder lifetimes with probing, we just replace higher lifetimes
// with fresh vars. // with fresh vars.
let span = args.get(i).map(|a| a.span).unwrap_or(expr.span); let span = args.get(i).map(|a| a.span).unwrap_or(expr.span);
let input = self let input = self.replace_bound_vars_with_fresh_vars(
.replace_bound_vars_with_fresh_vars(
span, span,
infer::LateBoundRegionConversionTime::FnCall, infer::LateBoundRegionConversionTime::FnCall,
fn_sig.input(i), fn_sig.input(i),
) );
.0;
self.require_type_is_sized_deferred( self.require_type_is_sized_deferred(
input, input,
span, span,
@ -581,13 +579,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// Also, as we just want to check sizedness, instead of introducing // Also, as we just want to check sizedness, instead of introducing
// placeholder lifetimes with probing, we just replace higher lifetimes // placeholder lifetimes with probing, we just replace higher lifetimes
// with fresh vars. // with fresh vars.
let output = self let output = self.replace_bound_vars_with_fresh_vars(
.replace_bound_vars_with_fresh_vars(
expr.span, expr.span,
infer::LateBoundRegionConversionTime::FnCall, infer::LateBoundRegionConversionTime::FnCall,
fn_sig.output(), fn_sig.output(),
) );
.0;
self.require_type_is_sized_deferred(output, expr.span, traits::SizedReturnType); self.require_type_is_sized_deferred(output, expr.span, traits::SizedReturnType);
} }

View file

@ -256,7 +256,7 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> {
item_segment: &hir::PathSegment<'_>, item_segment: &hir::PathSegment<'_>,
poly_trait_ref: ty::PolyTraitRef<'tcx>, poly_trait_ref: ty::PolyTraitRef<'tcx>,
) -> Ty<'tcx> { ) -> Ty<'tcx> {
let (trait_ref, _) = self.replace_bound_vars_with_fresh_vars( let trait_ref = self.replace_bound_vars_with_fresh_vars(
span, span,
infer::LateBoundRegionConversionTime::AssocTypeProjection(item_def_id), infer::LateBoundRegionConversionTime::AssocTypeProjection(item_def_id),
poly_trait_ref, poly_trait_ref,

View file

@ -85,7 +85,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
_ => return false, _ => 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); let sig = self.normalize_associated_types_in(expr.span, sig);
if self.can_coerce(sig.output(), expected) { if self.can_coerce(sig.output(), expected) {
let (mut sugg_call, applicability) = if sig.inputs().is_empty() { let (mut sugg_call, applicability) = if sig.inputs().is_empty() {

View file

@ -574,6 +574,6 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
where where
T: TypeFoldable<'tcx>, 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)
} }
} }

View file

@ -462,7 +462,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// may reference those regions. // may reference those regions.
let fn_sig = tcx.bound_fn_sig(def_id); let fn_sig = tcx.bound_fn_sig(def_id);
let fn_sig = fn_sig.subst(self.tcx, substs); 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 { let InferOk { value, obligations: o } = if is_op {
self.normalize_op_associated_types_in_as_infer_ok(span, fn_sig, opt_input_expr) self.normalize_op_associated_types_in_as_infer_ok(span, fn_sig, opt_input_expr)

View file

@ -905,7 +905,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
self.probe(|_| { self.probe(|_| {
let substs = self.fresh_substs_for_item(self.span, method.def_id); let substs = self.fresh_substs_for_item(self.span, method.def_id);
let fty = fty.subst(self.tcx, substs); let fty = fty.subst(self.tcx, substs);
let (fty, _) = let fty =
self.replace_bound_vars_with_fresh_vars(self.span, infer::FnCall, fty); self.replace_bound_vars_with_fresh_vars(self.span, infer::FnCall, fty);
if let Some(self_ty) = self_ty { if let Some(self_ty) = self_ty {