Auto merge of #145717 - BoxyUwU:erase_regions_rename, r=lcnr
rename erase_regions to erase_and_anonymize_regions I find it consistently confusing that `erase_regions` does more than replacing regions with `'erased`. it also makes some code look real goofy to be writing manual folders to erase regions with a comment saying "we cant use erase regions" :> or code that re-calls erase_regions on types with regions already erased just to anonymize all the bound regions. r? lcnr idk how i feel about the name being almost twice as long now
This commit is contained in:
@@ -1616,8 +1616,8 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||
&& let Some((e, f)) = values.ty()
|
||||
&& let TypeError::ArgumentSorts(..) | TypeError::Sorts(_) = terr
|
||||
{
|
||||
let e = self.tcx.erase_regions(e);
|
||||
let f = self.tcx.erase_regions(f);
|
||||
let e = self.tcx.erase_and_anonymize_regions(e);
|
||||
let f = self.tcx.erase_and_anonymize_regions(f);
|
||||
let mut expected = with_forced_trimmed_paths!(e.sort_string(self.tcx));
|
||||
let mut found = with_forced_trimmed_paths!(f.sort_string(self.tcx));
|
||||
if let ObligationCauseCode::Pattern { span, .. } = cause.code()
|
||||
|
||||
@@ -629,7 +629,11 @@ impl<T> Trait<T> for X {
|
||||
let tcx = self.tcx;
|
||||
|
||||
// Don't suggest constraining a projection to something containing itself
|
||||
if self.tcx.erase_regions(values.found).contains(self.tcx.erase_regions(values.expected)) {
|
||||
if self
|
||||
.tcx
|
||||
.erase_and_anonymize_regions(values.found)
|
||||
.contains(self.tcx.erase_and_anonymize_regions(values.expected))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||
{
|
||||
if let Some(cause) = self
|
||||
.tcx
|
||||
.diagnostic_hir_wf_check((tcx.erase_regions(obligation.predicate), *wf_loc))
|
||||
.diagnostic_hir_wf_check((tcx.erase_and_anonymize_regions(obligation.predicate), *wf_loc))
|
||||
{
|
||||
obligation.cause = cause.clone();
|
||||
span = obligation.cause.span;
|
||||
@@ -2612,8 +2612,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||
}
|
||||
|
||||
// Erase regions because layout code doesn't particularly care about regions.
|
||||
let trait_pred =
|
||||
self.tcx.erase_regions(self.tcx.instantiate_bound_regions_with_erased(trait_pred));
|
||||
let trait_pred = self.tcx.erase_and_anonymize_regions(
|
||||
self.tcx.instantiate_bound_regions_with_erased(trait_pred),
|
||||
);
|
||||
|
||||
let src_and_dst = rustc_transmute::Types {
|
||||
dst: trait_pred.trait_ref.args.type_at(0),
|
||||
|
||||
@@ -2442,7 +2442,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||
|
||||
// Look for a type inside the coroutine interior that matches the target type to get
|
||||
// a span.
|
||||
let target_ty_erased = self.tcx.erase_regions(target_ty);
|
||||
let target_ty_erased = self.tcx.erase_and_anonymize_regions(target_ty);
|
||||
let ty_matches = |ty| -> bool {
|
||||
// Careful: the regions for types that appear in the
|
||||
// coroutine interior are not generally known, so we
|
||||
@@ -2454,10 +2454,10 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||
// interior generally contain "bound regions" to
|
||||
// represent regions that are part of the suspended
|
||||
// coroutine frame. Bound regions are preserved by
|
||||
// `erase_regions` and so we must also call
|
||||
// `erase_and_anonymize_regions` and so we must also call
|
||||
// `instantiate_bound_regions_with_erased`.
|
||||
let ty_erased = self.tcx.instantiate_bound_regions_with_erased(ty);
|
||||
let ty_erased = self.tcx.erase_regions(ty_erased);
|
||||
let ty_erased = self.tcx.erase_and_anonymize_regions(ty_erased);
|
||||
let eq = ty_erased == target_ty_erased;
|
||||
debug!(?ty_erased, ?target_ty_erased, ?eq);
|
||||
eq
|
||||
|
||||
@@ -300,7 +300,7 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<
|
||||
) -> Result<Certainty, NoSolution> {
|
||||
// Erase regions because we compute layouts in `rustc_transmute`,
|
||||
// which will ICE for region vars.
|
||||
let (dst, src) = self.tcx.erase_regions((dst, src));
|
||||
let (dst, src) = self.tcx.erase_and_anonymize_regions((dst, src));
|
||||
|
||||
let Some(assume) = rustc_transmute::Assume::from_const(self.tcx, assume) else {
|
||||
return Err(NoSolution);
|
||||
|
||||
@@ -759,7 +759,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for IllegalSelfTypeVisitor<'tcx> {
|
||||
)),
|
||||
)
|
||||
.map(|trait_ref| {
|
||||
self.tcx.erase_regions(
|
||||
self.tcx.erase_and_anonymize_regions(
|
||||
self.tcx.instantiate_bound_regions_with_erased(trait_ref),
|
||||
)
|
||||
})
|
||||
|
||||
@@ -576,7 +576,7 @@ pub fn try_evaluate_const<'tcx>(
|
||||
let args =
|
||||
replace_param_and_infer_args_with_placeholder(tcx, uv.args);
|
||||
let typing_env = infcx
|
||||
.typing_env(tcx.erase_regions(param_env))
|
||||
.typing_env(tcx.erase_and_anonymize_regions(param_env))
|
||||
.with_post_analysis_normalized(tcx);
|
||||
(args, typing_env)
|
||||
}
|
||||
@@ -589,7 +589,7 @@ pub fn try_evaluate_const<'tcx>(
|
||||
}
|
||||
} else {
|
||||
let typing_env = infcx
|
||||
.typing_env(tcx.erase_regions(param_env))
|
||||
.typing_env(tcx.erase_and_anonymize_regions(param_env))
|
||||
.with_post_analysis_normalized(tcx);
|
||||
(uv.args, typing_env)
|
||||
}
|
||||
@@ -634,14 +634,14 @@ pub fn try_evaluate_const<'tcx>(
|
||||
}
|
||||
|
||||
let typing_env = infcx
|
||||
.typing_env(tcx.erase_regions(param_env))
|
||||
.typing_env(tcx.erase_and_anonymize_regions(param_env))
|
||||
.with_post_analysis_normalized(tcx);
|
||||
(uv.args, typing_env)
|
||||
}
|
||||
};
|
||||
|
||||
let uv = ty::UnevaluatedConst::new(uv.def, args);
|
||||
let erased_uv = tcx.erase_regions(uv);
|
||||
let erased_uv = tcx.erase_and_anonymize_regions(uv);
|
||||
|
||||
use rustc_middle::mir::interpret::ErrorHandled;
|
||||
// FIXME: `def_span` will point at the definition of this const; ideally, we'd point at
|
||||
|
||||
@@ -350,7 +350,9 @@ pub fn dtorck_constraint_for_ty_inner<'tcx>(
|
||||
// Note that we don't care about whether the resume type has any drops since this is
|
||||
// redundant; there is no storage for the resume type, so if it is actually stored
|
||||
// in the interior, we'll already detect the need for a drop by checking the interior.
|
||||
let typing_env = tcx.erase_regions(typing_env);
|
||||
//
|
||||
// FIXME(@lcnr): Why do we erase regions in the env here? Seems odd
|
||||
let typing_env = tcx.erase_and_anonymize_regions(typing_env);
|
||||
let needs_drop = tcx.mir_coroutine_witnesses(def_id).is_some_and(|witness| {
|
||||
witness.field_tys.iter().any(|field| field.ty.needs_drop(tcx, typing_env))
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user