Skip to content

Commit f15997f

Browse files
Remove struct_tail_no_normalization
1 parent b5d2079 commit f15997f

File tree

5 files changed

+10
-13
lines changed

5 files changed

+10
-13
lines changed

compiler/rustc_const_eval/src/const_eval/eval_queries.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ pub(super) fn op_to_const<'tcx>(
226226
let pointee_ty = imm.layout.ty.builtin_deref(false).unwrap(); // `false` = no raw ptrs
227227
debug_assert!(
228228
matches!(
229-
ecx.tcx.struct_tail_without_normalization(pointee_ty).kind(),
229+
ecx.tcx.struct_tail_for_codegen(pointee_ty, ecx.param_env).kind(),
230230
ty::Str | ty::Slice(..),
231231
),
232232
"`ConstValue::Slice` is for slice-tailed types only, but got {}",

compiler/rustc_hir_typeck/src/expectation.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ impl<'a, 'tcx> Expectation<'tcx> {
7070
/// See the test case `test/ui/coerce-expect-unsized.rs` and #20169
7171
/// for examples of where this comes up,.
7272
pub(super) fn rvalue_hint(fcx: &FnCtxt<'a, 'tcx>, ty: Ty<'tcx>) -> Expectation<'tcx> {
73-
match fcx.tcx.struct_tail_without_normalization(ty).kind() {
73+
// FIXME: This is not right, even in the old solver...
74+
match fcx.tcx.struct_tail_raw(ty, |ty| ty, || {}).kind() {
7475
ty::Slice(_) | ty::Str | ty::Dynamic(..) => ExpectRvalueLikeUnsized(ty),
7576
_ => ExpectHasType(ty),
7677
}

compiler/rustc_middle/src/ty/util.rs

-8
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,6 @@ impl<'tcx> TyCtxt<'tcx> {
171171
}
172172
}
173173

174-
/// Attempts to returns the deeply last field of nested structures, but
175-
/// does not apply any normalization in its search. Returns the same type
176-
/// if input `ty` is not a structure at all.
177-
pub fn struct_tail_without_normalization(self, ty: Ty<'tcx>) -> Ty<'tcx> {
178-
let tcx = self;
179-
tcx.struct_tail_raw(ty, |ty| ty, || {})
180-
}
181-
182174
/// Returns the deeply last field of nested structures, or the same type if
183175
/// not a structure at all. Corresponds to the only possible unsized field,
184176
/// and its type can be used to determine unsizing strategy.

compiler/rustc_trait_selection/src/traits/project.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1149,10 +1149,10 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
11491149
| ty::Never
11501150
// Extern types have unit metadata, according to RFC 2850
11511151
| ty::Foreign(_)
1152-
// If returned by `struct_tail_without_normalization` this is a unit struct
1152+
// If returned by `struct_tail` this is a unit struct
11531153
// without any fields, or not a struct, and therefore is Sized.
11541154
| ty::Adt(..)
1155-
// If returned by `struct_tail_without_normalization` this is the empty tuple.
1155+
// If returned by `struct_tail` this is the empty tuple.
11561156
| ty::Tuple(..)
11571157
// Integers and floats are always Sized, and so have unit type metadata.
11581158
| ty::Infer(ty::InferTy::IntVar(_) | ty::InferTy::FloatVar(..)) => true,

compiler/rustc_ty_utils/src/layout.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,13 @@ fn layout_of_uncached<'tcx>(
219219
// its struct tail cannot be normalized either, so try to get a
220220
// more descriptive layout error here, which will lead to less confusing
221221
// diagnostics.
222+
//
223+
// We use the raw struct tail function here to get the first tail
224+
// that is an alias, which is likely the cause of the normalization
225+
// error.
222226
match tcx.try_normalize_erasing_regions(
223227
param_env,
224-
tcx.struct_tail_without_normalization(pointee),
228+
tcx.struct_tail_raw(pointee, |ty| ty, || {}),
225229
) {
226230
Ok(_) => {}
227231
Err(better_err) => {

0 commit comments

Comments
 (0)