Skip to content

Commit 670ee7e

Browse files
committed
Sync from rust 3153584
2 parents ef4512b + 86daae2 commit 670ee7e

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/allocator.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use crate::prelude::*;
55

66
use rustc_ast::expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS};
7+
use rustc_session::config::OomStrategy;
78

89
/// Returns whether an allocator shim was created
910
pub(crate) fn codegen(
@@ -18,7 +19,13 @@ pub(crate) fn codegen(
1819
if any_dynamic_crate {
1920
false
2021
} else if let Some(kind) = tcx.allocator_kind(()) {
21-
codegen_inner(module, unwind_context, kind, tcx.lang_items().oom().is_some());
22+
codegen_inner(
23+
module,
24+
unwind_context,
25+
kind,
26+
tcx.lang_items().oom().is_some(),
27+
tcx.sess.opts.debugging_opts.oom,
28+
);
2229
true
2330
} else {
2431
false
@@ -30,6 +37,7 @@ fn codegen_inner(
3037
unwind_context: &mut UnwindContext,
3138
kind: AllocatorKind,
3239
has_alloc_error_handler: bool,
40+
oom_strategy: OomStrategy,
3341
) {
3442
let usize_ty = module.target_config().pointer_type();
3543

@@ -129,4 +137,11 @@ fn codegen_inner(
129137
}
130138
module.define_function(func_id, &mut ctx).unwrap();
131139
unwind_context.add_function(func_id, &ctx, module.isa());
140+
141+
let data_id = module.declare_data(OomStrategy::SYMBOL, Linkage::Export, false, false).unwrap();
142+
let mut data_ctx = DataContext::new();
143+
data_ctx.set_align(1);
144+
let val = oom_strategy.should_panic();
145+
data_ctx.define(Box::new([val]));
146+
module.define_data(data_id, &data_ctx).unwrap();
132147
}

src/constant.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Handling of `static`s, `const`s and promoted allocations
22
33
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
4-
use rustc_errors::ErrorGuaranteed;
54
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
65
use rustc_middle::mir::interpret::{
76
read_target_uint, AllocId, ConstAllocation, ConstValue, ErrorHandled, GlobalAlloc, Scalar,
@@ -54,7 +53,7 @@ pub(crate) fn check_constants(fx: &mut FunctionCx<'_, '_, '_>) -> bool {
5453
{
5554
all_constants_ok = false;
5655
match err {
57-
ErrorHandled::Reported(ErrorGuaranteed) | ErrorHandled::Linted => {
56+
ErrorHandled::Reported(_) | ErrorHandled::Linted => {
5857
fx.tcx.sess.span_err(constant.span, "erroneous constant encountered");
5958
}
6059
ErrorHandled::TooGeneric => {

0 commit comments

Comments
 (0)