Rename normalization functions to raw

This commit is contained in:
Michael Goulet 2024-08-11 12:30:38 -04:00
parent c5205e9d56
commit b5d2079fb9
7 changed files with 18 additions and 16 deletions

View File

@ -193,7 +193,7 @@ pub(super) fn struct_tail(
.unwrap_or_else(|_| bug!("struct tail should have been computable, since we computed it in HIR"))
};
let tail = tcx.struct_tail_with_normalize(
let tail = tcx.struct_tail_raw(
ty,
structurally_normalize,
|| {},
@ -207,7 +207,7 @@ pub(super) fn struct_tail(
.unwrap_or_else(|guar| Ty::new_error(tcx, guar))
} else {
let mut normalize = |ty| self.normalize(ty, location);
let tail = tcx.struct_tail_with_normalize(ty, &mut normalize, || {});
let tail = tcx.struct_tail_raw(ty, &mut normalize, || {});
normalize(tail)
}
}

View File

@ -195,7 +195,7 @@ fn reconstruct_place_meta<'tcx>(
let mut last_valtree = valtree;
// Traverse the type, and update `last_valtree` as we go.
let tail = tcx.struct_tail_with_normalize(
let tail = tcx.struct_tail_raw(
layout.ty,
|ty| ty,
|| {

View File

@ -404,7 +404,7 @@ pub fn require_type_has_static_alignment(
code: traits::ObligationCauseCode<'tcx>,
) {
if !ty.references_error() {
let tail = self.tcx.struct_tail_with_normalize(
let tail = self.tcx.struct_tail_raw(
ty,
|ty| {
if self.next_trait_solver() {

View File

@ -362,7 +362,7 @@ pub fn compute(
ty::Ref(_, pointee, _) | ty::RawPtr(pointee, _) => {
let non_zero = !ty.is_unsafe_ptr();
let tail = tcx.struct_tail_with_normalize(
let tail = tcx.struct_tail_raw(
pointee,
|ty| match tcx.try_normalize_erasing_regions(param_env, ty) {
Ok(ty) => ty,

View File

@ -1590,7 +1590,7 @@ pub fn ptr_metadata_ty_or_tail(
tcx: TyCtxt<'tcx>,
normalize: impl FnMut(Ty<'tcx>) -> Ty<'tcx>,
) -> Result<Ty<'tcx>, Ty<'tcx>> {
let tail = tcx.struct_tail_with_normalize(self, normalize, || {});
let tail = tcx.struct_tail_raw(self, normalize, || {});
match tail.kind() {
// Sized types
ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
@ -1614,10 +1614,10 @@ pub fn ptr_metadata_ty_or_tail(
| ty::Foreign(..)
// `dyn*` has metadata = ().
| ty::Dynamic(_, _, ty::DynStar)
// If returned by `struct_tail_with_normalize` this is a unit struct
// If returned by `struct_tail_raw` this is a unit struct
// without any fields, or not a struct, and therefore is Sized.
| ty::Adt(..)
// If returned by `struct_tail_with_normalize` this is the empty tuple,
// If returned by `struct_tail_raw` this is the empty tuple,
// a.k.a. unit type, which is Sized
| ty::Tuple(..) => Ok(tcx.types.unit),

View File

@ -176,7 +176,7 @@ pub fn res_generics_def_id(self, res: Res) -> Option<DefId> {
/// if input `ty` is not a structure at all.
pub fn struct_tail_without_normalization(self, ty: Ty<'tcx>) -> Ty<'tcx> {
let tcx = self;
tcx.struct_tail_with_normalize(ty, |ty| ty, || {})
tcx.struct_tail_raw(ty, |ty| ty, || {})
}
/// Returns the deeply last field of nested structures, or the same type if
@ -188,7 +188,7 @@ pub fn struct_tail_without_normalization(self, ty: Ty<'tcx>) -> Ty<'tcx> {
/// normalization attempt may cause compiler bugs.
pub fn struct_tail_for_codegen(self, ty: Ty<'tcx>, param_env: ty::ParamEnv<'tcx>) -> Ty<'tcx> {
let tcx = self;
tcx.struct_tail_with_normalize(ty, |ty| tcx.normalize_erasing_regions(param_env, ty), || {})
tcx.struct_tail_raw(ty, |ty| tcx.normalize_erasing_regions(param_env, ty), || {})
}
/// Returns the deeply last field of nested structures, or the same type if
@ -196,12 +196,14 @@ pub fn struct_tail_for_codegen(self, ty: Ty<'tcx>, param_env: ty::ParamEnv<'tcx>
/// and its type can be used to determine unsizing strategy.
///
/// This is parameterized over the normalization strategy (i.e. how to
/// handle `<T as Trait>::Assoc` and `impl Trait`); pass the identity
/// function to indicate no normalization should take place.
/// handle `<T as Trait>::Assoc` and `impl Trait`). You almost certainly do
/// **NOT** want to pass the identity function here, unless you know what
/// you're doing, or you're within normalization code itself and will handle
/// an unnormalized tail recursively.
///
/// See also `struct_tail_for_codegen`, which is suitable for use
/// during codegen.
pub fn struct_tail_with_normalize(
pub fn struct_tail_raw(
self,
mut ty: Ty<'tcx>,
mut normalize: impl FnMut(Ty<'tcx>) -> Ty<'tcx>,
@ -281,7 +283,7 @@ pub fn struct_lockstep_tails_for_codegen(
param_env: ty::ParamEnv<'tcx>,
) -> (Ty<'tcx>, Ty<'tcx>) {
let tcx = self;
tcx.struct_lockstep_tails_with_normalize(source, target, |ty| {
tcx.struct_lockstep_tails_raw(source, target, |ty| {
tcx.normalize_erasing_regions(param_env, ty)
})
}
@ -294,7 +296,7 @@ pub fn struct_lockstep_tails_for_codegen(
///
/// See also `struct_lockstep_tails_for_codegen`, which is suitable for use
/// during codegen.
pub fn struct_lockstep_tails_with_normalize(
pub fn struct_lockstep_tails_raw(
self,
source: Ty<'tcx>,
target: Ty<'tcx>,

View File

@ -1110,7 +1110,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
| ty::Error(_) => false,
}
} else if tcx.is_lang_item(trait_ref.def_id, LangItem::PointeeTrait) {
let tail = selcx.tcx().struct_tail_with_normalize(
let tail = selcx.tcx().struct_tail_raw(
self_ty,
|ty| {
// We throw away any obligations we get from this, since we normalize