Skip to content

Commit b5d2079

Browse files
Rename normalization functions to raw
1 parent c5205e9 commit b5d2079

File tree

7 files changed

+18
-16
lines changed

7 files changed

+18
-16
lines changed

compiler/rustc_borrowck/src/type_check/canonical.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
193193
.unwrap_or_else(|_| bug!("struct tail should have been computable, since we computed it in HIR"))
194194
};
195195

196-
let tail = tcx.struct_tail_with_normalize(
196+
let tail = tcx.struct_tail_raw(
197197
ty,
198198
structurally_normalize,
199199
|| {},
@@ -207,7 +207,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
207207
.unwrap_or_else(|guar| Ty::new_error(tcx, guar))
208208
} else {
209209
let mut normalize = |ty| self.normalize(ty, location);
210-
let tail = tcx.struct_tail_with_normalize(ty, &mut normalize, || {});
210+
let tail = tcx.struct_tail_raw(ty, &mut normalize, || {});
211211
normalize(tail)
212212
}
213213
}

compiler/rustc_const_eval/src/const_eval/valtrees.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ fn reconstruct_place_meta<'tcx>(
195195

196196
let mut last_valtree = valtree;
197197
// Traverse the type, and update `last_valtree` as we go.
198-
let tail = tcx.struct_tail_with_normalize(
198+
let tail = tcx.struct_tail_raw(
199199
layout.ty,
200200
|ty| ty,
201201
|| {

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
404404
code: traits::ObligationCauseCode<'tcx>,
405405
) {
406406
if !ty.references_error() {
407-
let tail = self.tcx.struct_tail_with_normalize(
407+
let tail = self.tcx.struct_tail_raw(
408408
ty,
409409
|ty| {
410410
if self.next_trait_solver() {

compiler/rustc_middle/src/ty/layout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ impl<'tcx> SizeSkeleton<'tcx> {
362362
ty::Ref(_, pointee, _) | ty::RawPtr(pointee, _) => {
363363
let non_zero = !ty.is_unsafe_ptr();
364364

365-
let tail = tcx.struct_tail_with_normalize(
365+
let tail = tcx.struct_tail_raw(
366366
pointee,
367367
|ty| match tcx.try_normalize_erasing_regions(param_env, ty) {
368368
Ok(ty) => ty,

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,7 +1590,7 @@ impl<'tcx> Ty<'tcx> {
15901590
tcx: TyCtxt<'tcx>,
15911591
normalize: impl FnMut(Ty<'tcx>) -> Ty<'tcx>,
15921592
) -> Result<Ty<'tcx>, Ty<'tcx>> {
1593-
let tail = tcx.struct_tail_with_normalize(self, normalize, || {});
1593+
let tail = tcx.struct_tail_raw(self, normalize, || {});
15941594
match tail.kind() {
15951595
// Sized types
15961596
ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
@@ -1614,10 +1614,10 @@ impl<'tcx> Ty<'tcx> {
16141614
| ty::Foreign(..)
16151615
// `dyn*` has metadata = ().
16161616
| ty::Dynamic(_, _, ty::DynStar)
1617-
// If returned by `struct_tail_with_normalize` this is a unit struct
1617+
// If returned by `struct_tail_raw` this is a unit struct
16181618
// without any fields, or not a struct, and therefore is Sized.
16191619
| ty::Adt(..)
1620-
// If returned by `struct_tail_with_normalize` this is the empty tuple,
1620+
// If returned by `struct_tail_raw` this is the empty tuple,
16211621
// a.k.a. unit type, which is Sized
16221622
| ty::Tuple(..) => Ok(tcx.types.unit),
16231623

compiler/rustc_middle/src/ty/util.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ impl<'tcx> TyCtxt<'tcx> {
176176
/// if input `ty` is not a structure at all.
177177
pub fn struct_tail_without_normalization(self, ty: Ty<'tcx>) -> Ty<'tcx> {
178178
let tcx = self;
179-
tcx.struct_tail_with_normalize(ty, |ty| ty, || {})
179+
tcx.struct_tail_raw(ty, |ty| ty, || {})
180180
}
181181

182182
/// Returns the deeply last field of nested structures, or the same type if
@@ -188,20 +188,22 @@ impl<'tcx> TyCtxt<'tcx> {
188188
/// normalization attempt may cause compiler bugs.
189189
pub fn struct_tail_for_codegen(self, ty: Ty<'tcx>, param_env: ty::ParamEnv<'tcx>) -> Ty<'tcx> {
190190
let tcx = self;
191-
tcx.struct_tail_with_normalize(ty, |ty| tcx.normalize_erasing_regions(param_env, ty), || {})
191+
tcx.struct_tail_raw(ty, |ty| tcx.normalize_erasing_regions(param_env, ty), || {})
192192
}
193193

194194
/// Returns the deeply last field of nested structures, or the same type if
195195
/// not a structure at all. Corresponds to the only possible unsized field,
196196
/// and its type can be used to determine unsizing strategy.
197197
///
198198
/// This is parameterized over the normalization strategy (i.e. how to
199-
/// handle `<T as Trait>::Assoc` and `impl Trait`); pass the identity
200-
/// function to indicate no normalization should take place.
199+
/// handle `<T as Trait>::Assoc` and `impl Trait`). You almost certainly do
200+
/// **NOT** want to pass the identity function here, unless you know what
201+
/// you're doing, or you're within normalization code itself and will handle
202+
/// an unnormalized tail recursively.
201203
///
202204
/// See also `struct_tail_for_codegen`, which is suitable for use
203205
/// during codegen.
204-
pub fn struct_tail_with_normalize(
206+
pub fn struct_tail_raw(
205207
self,
206208
mut ty: Ty<'tcx>,
207209
mut normalize: impl FnMut(Ty<'tcx>) -> Ty<'tcx>,
@@ -281,7 +283,7 @@ impl<'tcx> TyCtxt<'tcx> {
281283
param_env: ty::ParamEnv<'tcx>,
282284
) -> (Ty<'tcx>, Ty<'tcx>) {
283285
let tcx = self;
284-
tcx.struct_lockstep_tails_with_normalize(source, target, |ty| {
286+
tcx.struct_lockstep_tails_raw(source, target, |ty| {
285287
tcx.normalize_erasing_regions(param_env, ty)
286288
})
287289
}
@@ -294,7 +296,7 @@ impl<'tcx> TyCtxt<'tcx> {
294296
///
295297
/// See also `struct_lockstep_tails_for_codegen`, which is suitable for use
296298
/// during codegen.
297-
pub fn struct_lockstep_tails_with_normalize(
299+
pub fn struct_lockstep_tails_raw(
298300
self,
299301
source: Ty<'tcx>,
300302
target: Ty<'tcx>,

compiler/rustc_trait_selection/src/traits/project.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
11101110
| ty::Error(_) => false,
11111111
}
11121112
} else if tcx.is_lang_item(trait_ref.def_id, LangItem::PointeeTrait) {
1113-
let tail = selcx.tcx().struct_tail_with_normalize(
1113+
let tail = selcx.tcx().struct_tail_raw(
11141114
self_ty,
11151115
|ty| {
11161116
// We throw away any obligations we get from this, since we normalize

0 commit comments

Comments
 (0)