Skip to content

Commit 85b5e42

Browse files
Do normalize when computing struct tails in codegen
1 parent d3a3939 commit 85b5e42

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Diff for: compiler/rustc_codegen_llvm/src/builder.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ use rustc_data_structures::small_c_str::SmallCStr;
1212
use rustc_hir::def_id::DefId;
1313
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
1414
use rustc_middle::ty::layout::{
15-
FnAbiError, FnAbiOfHelpers, FnAbiRequest, LayoutError, LayoutOfHelpers, TyAndLayout,
15+
FnAbiError, FnAbiOfHelpers, FnAbiRequest, HasParamEnv, LayoutError, LayoutOfHelpers,
16+
TyAndLayout,
1617
};
1718
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
1819
use rustc_sanitizers::{cfi, kcfi};
@@ -531,7 +532,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
531532
#[instrument(level = "trace", skip(self))]
532533
fn load_operand(&mut self, place: PlaceRef<'tcx, &'ll Value>) -> OperandRef<'tcx, &'ll Value> {
533534
if place.layout.is_unsized() {
534-
let tail = self.tcx.struct_tail_with_normalize(place.layout.ty, |ty| ty, || {});
535+
let tail = self.tcx.struct_tail_erasing_lifetimes(place.layout.ty, self.param_env());
535536
if matches!(tail.kind(), ty::Foreign(..)) {
536537
// Unsized locals and, at least conceptually, even unsized arguments must be copied
537538
// around, which requires dynamically determining their size. Therefore, we cannot

Diff for: compiler/rustc_ty_utils/src/abi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ fn fn_abi_sanity_check<'tcx>(
549549
// With metadata. Must be unsized and not on the stack.
550550
assert!(arg.layout.is_unsized() && !on_stack);
551551
// Also, must not be `extern` type.
552-
let tail = cx.tcx.struct_tail_with_normalize(arg.layout.ty, |ty| ty, || {});
552+
let tail = cx.tcx.struct_tail_erasing_lifetimes(arg.layout.ty, cx.param_env());
553553
if matches!(tail.kind(), ty::Foreign(..)) {
554554
// These types do not have metadata, so having `meta_attrs` is bogus.
555555
// Conceptually, unsized arguments must be copied around, which requires dynamically

0 commit comments

Comments
 (0)