Rename normalization functions to raw
This commit is contained in:
parent
c5205e9d56
commit
b5d2079fb9
@ -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"))
|
.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,
|
ty,
|
||||||
structurally_normalize,
|
structurally_normalize,
|
||||||
|| {},
|
|| {},
|
||||||
@ -207,7 +207,7 @@ pub(super) fn struct_tail(
|
|||||||
.unwrap_or_else(|guar| Ty::new_error(tcx, guar))
|
.unwrap_or_else(|guar| Ty::new_error(tcx, guar))
|
||||||
} else {
|
} else {
|
||||||
let mut normalize = |ty| self.normalize(ty, location);
|
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)
|
normalize(tail)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ fn reconstruct_place_meta<'tcx>(
|
|||||||
|
|
||||||
let mut last_valtree = valtree;
|
let mut last_valtree = valtree;
|
||||||
// Traverse the type, and update `last_valtree` as we go.
|
// 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,
|
layout.ty,
|
||||||
|ty| ty,
|
|ty| ty,
|
||||||
|| {
|
|| {
|
||||||
|
@ -404,7 +404,7 @@ pub fn require_type_has_static_alignment(
|
|||||||
code: traits::ObligationCauseCode<'tcx>,
|
code: traits::ObligationCauseCode<'tcx>,
|
||||||
) {
|
) {
|
||||||
if !ty.references_error() {
|
if !ty.references_error() {
|
||||||
let tail = self.tcx.struct_tail_with_normalize(
|
let tail = self.tcx.struct_tail_raw(
|
||||||
ty,
|
ty,
|
||||||
|ty| {
|
|ty| {
|
||||||
if self.next_trait_solver() {
|
if self.next_trait_solver() {
|
||||||
|
@ -362,7 +362,7 @@ pub fn compute(
|
|||||||
ty::Ref(_, pointee, _) | ty::RawPtr(pointee, _) => {
|
ty::Ref(_, pointee, _) | ty::RawPtr(pointee, _) => {
|
||||||
let non_zero = !ty.is_unsafe_ptr();
|
let non_zero = !ty.is_unsafe_ptr();
|
||||||
|
|
||||||
let tail = tcx.struct_tail_with_normalize(
|
let tail = tcx.struct_tail_raw(
|
||||||
pointee,
|
pointee,
|
||||||
|ty| match tcx.try_normalize_erasing_regions(param_env, ty) {
|
|ty| match tcx.try_normalize_erasing_regions(param_env, ty) {
|
||||||
Ok(ty) => ty,
|
Ok(ty) => ty,
|
||||||
|
@ -1590,7 +1590,7 @@ pub fn ptr_metadata_ty_or_tail(
|
|||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
normalize: impl FnMut(Ty<'tcx>) -> Ty<'tcx>,
|
normalize: impl FnMut(Ty<'tcx>) -> Ty<'tcx>,
|
||||||
) -> Result<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() {
|
match tail.kind() {
|
||||||
// Sized types
|
// Sized types
|
||||||
ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
|
ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
|
||||||
@ -1614,10 +1614,10 @@ pub fn ptr_metadata_ty_or_tail(
|
|||||||
| ty::Foreign(..)
|
| ty::Foreign(..)
|
||||||
// `dyn*` has metadata = ().
|
// `dyn*` has metadata = ().
|
||||||
| ty::Dynamic(_, _, ty::DynStar)
|
| 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.
|
// without any fields, or not a struct, and therefore is Sized.
|
||||||
| ty::Adt(..)
|
| 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
|
// a.k.a. unit type, which is Sized
|
||||||
| ty::Tuple(..) => Ok(tcx.types.unit),
|
| ty::Tuple(..) => Ok(tcx.types.unit),
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ pub fn res_generics_def_id(self, res: Res) -> Option<DefId> {
|
|||||||
/// if input `ty` is not a structure at all.
|
/// if input `ty` is not a structure at all.
|
||||||
pub fn struct_tail_without_normalization(self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
pub fn struct_tail_without_normalization(self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||||
let tcx = self;
|
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
|
/// 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.
|
/// normalization attempt may cause compiler bugs.
|
||||||
pub fn struct_tail_for_codegen(self, ty: Ty<'tcx>, param_env: ty::ParamEnv<'tcx>) -> Ty<'tcx> {
|
pub fn struct_tail_for_codegen(self, ty: Ty<'tcx>, param_env: ty::ParamEnv<'tcx>) -> Ty<'tcx> {
|
||||||
let tcx = self;
|
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
|
/// 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.
|
/// and its type can be used to determine unsizing strategy.
|
||||||
///
|
///
|
||||||
/// This is parameterized over the normalization strategy (i.e. how to
|
/// This is parameterized over the normalization strategy (i.e. how to
|
||||||
/// handle `<T as Trait>::Assoc` and `impl Trait`); pass the identity
|
/// handle `<T as Trait>::Assoc` and `impl Trait`). You almost certainly do
|
||||||
/// function to indicate no normalization should take place.
|
/// **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
|
/// See also `struct_tail_for_codegen`, which is suitable for use
|
||||||
/// during codegen.
|
/// during codegen.
|
||||||
pub fn struct_tail_with_normalize(
|
pub fn struct_tail_raw(
|
||||||
self,
|
self,
|
||||||
mut ty: Ty<'tcx>,
|
mut ty: Ty<'tcx>,
|
||||||
mut normalize: impl FnMut(Ty<'tcx>) -> 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>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
) -> (Ty<'tcx>, Ty<'tcx>) {
|
) -> (Ty<'tcx>, Ty<'tcx>) {
|
||||||
let tcx = self;
|
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)
|
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
|
/// See also `struct_lockstep_tails_for_codegen`, which is suitable for use
|
||||||
/// during codegen.
|
/// during codegen.
|
||||||
pub fn struct_lockstep_tails_with_normalize(
|
pub fn struct_lockstep_tails_raw(
|
||||||
self,
|
self,
|
||||||
source: Ty<'tcx>,
|
source: Ty<'tcx>,
|
||||||
target: Ty<'tcx>,
|
target: Ty<'tcx>,
|
||||||
|
@ -1110,7 +1110,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
|
|||||||
| ty::Error(_) => false,
|
| ty::Error(_) => false,
|
||||||
}
|
}
|
||||||
} else if tcx.is_lang_item(trait_ref.def_id, LangItem::PointeeTrait) {
|
} 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,
|
self_ty,
|
||||||
|ty| {
|
|ty| {
|
||||||
// We throw away any obligations we get from this, since we normalize
|
// We throw away any obligations we get from this, since we normalize
|
||||||
|
Loading…
Reference in New Issue
Block a user