Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 2577efb

Browse files
committed
Sync from rust 67b3e81
2 parents c5ec4d3 + 8723fe0 commit 2577efb

File tree

6 files changed

+31
-17
lines changed

6 files changed

+31
-17
lines changed

src/abi/comments.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,14 @@ pub(super) fn add_local_place_comments<'tcx>(
8282
return;
8383
}
8484
let TyAndLayout { ty, layout } = place.layout();
85-
let rustc_target::abi::Layout { size, align, abi: _, variants: _, fields: _, largest_niche: _ } =
86-
layout;
85+
let rustc_target::abi::LayoutS {
86+
size,
87+
align,
88+
abi: _,
89+
variants: _,
90+
fields: _,
91+
largest_niche: _,
92+
} = layout.0.0;
8793

8894
let (kind, extra) = match *place.inner() {
8995
CPlaceInner::Var(place_local, var) => {

src/constant.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
//! Handling of `static`s, `const`s and promoted allocations
22
33
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
4-
use rustc_errors::ErrorReported;
4+
use rustc_errors::ErrorGuaranteed;
55
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
66
use rustc_middle::mir::interpret::{
7-
read_target_uint, AllocId, Allocation, ConstValue, ErrorHandled, GlobalAlloc, Scalar,
7+
read_target_uint, AllocId, ConstAllocation, ConstValue, ErrorHandled, GlobalAlloc, Scalar,
88
};
99
use rustc_middle::ty::ConstKind;
1010
use rustc_span::DUMMY_SP;
@@ -54,7 +54,7 @@ pub(crate) fn check_constants(fx: &mut FunctionCx<'_, '_, '_>) -> bool {
5454
{
5555
all_constants_ok = false;
5656
match err {
57-
ErrorHandled::Reported(ErrorReported) | ErrorHandled::Linted => {
57+
ErrorHandled::Reported(ErrorGuaranteed) | ErrorHandled::Linted => {
5858
fx.tcx.sess.span_err(constant.span, "erroneous constant encountered");
5959
}
6060
ErrorHandled::TooGeneric => {
@@ -202,7 +202,7 @@ pub(crate) fn codegen_const_value<'tcx>(
202202
&mut fx.constants_cx,
203203
fx.module,
204204
alloc_id,
205-
alloc.mutability,
205+
alloc.inner().mutability,
206206
);
207207
let local_data_id =
208208
fx.module.declare_data_in_func(data_id, &mut fx.bcx.func);
@@ -257,11 +257,15 @@ pub(crate) fn codegen_const_value<'tcx>(
257257

258258
fn pointer_for_allocation<'tcx>(
259259
fx: &mut FunctionCx<'_, '_, 'tcx>,
260-
alloc: &'tcx Allocation,
260+
alloc: ConstAllocation<'tcx>,
261261
) -> crate::pointer::Pointer {
262262
let alloc_id = fx.tcx.create_memory_alloc(alloc);
263-
let data_id =
264-
data_id_for_alloc_id(&mut fx.constants_cx, &mut *fx.module, alloc_id, alloc.mutability);
263+
let data_id = data_id_for_alloc_id(
264+
&mut fx.constants_cx,
265+
&mut *fx.module,
266+
alloc_id,
267+
alloc.inner().mutability,
268+
);
265269

266270
let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func);
267271
if fx.clif_comments.enabled() {
@@ -361,7 +365,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
361365
let data_id = *cx.anon_allocs.entry(alloc_id).or_insert_with(|| {
362366
module
363367
.declare_anonymous_data(
364-
alloc.mutability == rustc_hir::Mutability::Mut,
368+
alloc.inner().mutability == rustc_hir::Mutability::Mut,
365369
false,
366370
)
367371
.unwrap()
@@ -386,6 +390,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
386390
}
387391

388392
let mut data_ctx = DataContext::new();
393+
let alloc = alloc.inner();
389394
data_ctx.set_align(alloc.align.bytes());
390395

391396
if let Some(section_name) = section_name {
@@ -429,7 +434,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
429434
continue;
430435
}
431436
GlobalAlloc::Memory(target_alloc) => {
432-
data_id_for_alloc_id(cx, module, alloc_id, target_alloc.mutability)
437+
data_id_for_alloc_id(cx, module, alloc_id, target_alloc.inner().mutability)
433438
}
434439
GlobalAlloc::Static(def_id) => {
435440
if tcx.codegen_fn_attrs(def_id).flags.contains(CodegenFnAttrFlags::THREAD_LOCAL)

src/intrinsics/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
10701070
};
10711071

10721072
raw_eq, (v lhs_ref, v rhs_ref) {
1073-
let size = fx.layout_of(substs.type_at(0)).layout.size;
1073+
let size = fx.layout_of(substs.type_at(0)).layout.size();
10741074
// FIXME add and use emit_small_memcmp
10751075
let is_eq_value =
10761076
if size == Size::ZERO {

src/intrinsics/simd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
159159
let idx_bytes = match idx_const {
160160
ConstValue::ByRef { alloc, offset } => {
161161
let size = Size::from_bytes(4 * ret_lane_count /* size_of([u32; ret_lane_count]) */);
162-
alloc.get_bytes(fx, alloc_range(offset, size)).unwrap()
162+
alloc.inner().get_bytes(fx, alloc_range(offset, size)).unwrap()
163163
}
164164
_ => unreachable!("{:?}", idx_const),
165165
};

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use std::cell::Cell;
2929

3030
use rustc_codegen_ssa::traits::CodegenBackend;
3131
use rustc_codegen_ssa::CodegenResults;
32-
use rustc_errors::ErrorReported;
32+
use rustc_errors::ErrorGuaranteed;
3333
use rustc_metadata::EncodedMetadata;
3434
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
3535
use rustc_session::config::OutputFilenames;
@@ -209,7 +209,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
209209
ongoing_codegen: Box<dyn Any>,
210210
_sess: &Session,
211211
_outputs: &OutputFilenames,
212-
) -> Result<(CodegenResults, FxHashMap<WorkProductId, WorkProduct>), ErrorReported> {
212+
) -> Result<(CodegenResults, FxHashMap<WorkProductId, WorkProduct>), ErrorGuaranteed> {
213213
Ok(*ongoing_codegen
214214
.downcast::<(CodegenResults, FxHashMap<WorkProductId, WorkProduct>)>()
215215
.unwrap())
@@ -220,7 +220,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
220220
sess: &Session,
221221
codegen_results: CodegenResults,
222222
outputs: &OutputFilenames,
223-
) -> Result<(), ErrorReported> {
223+
) -> Result<(), ErrorGuaranteed> {
224224
use rustc_codegen_ssa::back::link::link_binary;
225225

226226
link_binary::<crate::archive::ArArchiveBuilder<'_>>(sess, &codegen_results, outputs)

src/main_shim.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ pub(crate) fn maybe_create_entry_wrapper(
5151
// late-bound regions, since late-bound
5252
// regions must appear in the argument
5353
// listing.
54-
let main_ret_ty = tcx.erase_regions(main_ret_ty.no_bound_vars().unwrap());
54+
let main_ret_ty = tcx.normalize_erasing_regions(
55+
ty::ParamEnv::reveal_all(),
56+
main_ret_ty.no_bound_vars().unwrap(),
57+
);
5558

5659
let cmain_sig = Signature {
5760
params: vec![

0 commit comments

Comments
 (0)