Skip to content

Commit 81807c7

Browse files
committed
Use a const for all __rust_alloc_error_handler name references
1 parent 1e83852 commit 81807c7

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed

compiler/rustc_ast/src/expand/allocator.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub fn alloc_error_handler_name(alloc_error_handler_kind: AllocatorKind) -> &'st
2222
}
2323
}
2424

25+
pub const ALLOC_ERROR_HANDLER: &str = "__rust_alloc_error_handler";
2526
pub const NO_ALLOC_SHIM_IS_UNSTABLE: &str = "__rust_no_alloc_shim_is_unstable_v2";
2627

2728
pub enum AllocatorTy {

compiler/rustc_codegen_cranelift/src/allocator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
55
use rustc_ast::expand::allocator::{
6-
ALLOCATOR_METHODS, AllocatorKind, AllocatorTy, NO_ALLOC_SHIM_IS_UNSTABLE,
6+
ALLOC_ERROR_HANDLER, ALLOCATOR_METHODS, AllocatorKind, AllocatorTy, NO_ALLOC_SHIM_IS_UNSTABLE,
77
alloc_error_handler_name, default_fn_name, global_fn_name,
88
};
99
use rustc_codegen_ssa::base::allocator_kind_for_codegen;
@@ -80,7 +80,7 @@ fn codegen_inner(
8080
crate::common::create_wrapper_function(
8181
module,
8282
sig,
83-
&mangle_internal_symbol(tcx, "__rust_alloc_error_handler"),
83+
&mangle_internal_symbol(tcx, ALLOC_ERROR_HANDLER),
8484
&mangle_internal_symbol(tcx, alloc_error_handler_name(alloc_error_handler_kind)),
8585
);
8686

compiler/rustc_codegen_gcc/src/allocator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use gccjit::{Context, FunctionType, GlobalKind, ToRValue, Type};
22
#[cfg(feature = "master")]
33
use gccjit::{FnAttribute, VarAttribute};
44
use rustc_ast::expand::allocator::{
5-
ALLOCATOR_METHODS, AllocatorKind, AllocatorTy, NO_ALLOC_SHIM_IS_UNSTABLE,
5+
ALLOC_ERROR_HANDLER, ALLOCATOR_METHODS, AllocatorKind, AllocatorTy, NO_ALLOC_SHIM_IS_UNSTABLE,
66
alloc_error_handler_name, default_fn_name, global_fn_name,
77
};
88
use rustc_middle::bug;
@@ -65,7 +65,7 @@ pub(crate) unsafe fn codegen(
6565
create_wrapper_function(
6666
tcx,
6767
context,
68-
&mangle_internal_symbol(tcx, "__rust_alloc_error_handler"),
68+
&mangle_internal_symbol(tcx, ALLOC_ERROR_HANDLER),
6969
Some(&mangle_internal_symbol(tcx, alloc_error_handler_name(alloc_error_handler_kind))),
7070
&[usize, usize],
7171
None,

compiler/rustc_codegen_llvm/src/allocator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use libc::c_uint;
22
use rustc_ast::expand::allocator::{
3-
ALLOCATOR_METHODS, AllocatorKind, AllocatorTy, NO_ALLOC_SHIM_IS_UNSTABLE,
3+
ALLOC_ERROR_HANDLER, ALLOCATOR_METHODS, AllocatorKind, AllocatorTy, NO_ALLOC_SHIM_IS_UNSTABLE,
44
alloc_error_handler_name, default_fn_name, global_fn_name,
55
};
66
use rustc_codegen_ssa::traits::BaseTypeCodegenMethods as _;
@@ -65,7 +65,7 @@ pub(crate) unsafe fn codegen(
6565
create_wrapper_function(
6666
tcx,
6767
&cx,
68-
&mangle_internal_symbol(tcx, "__rust_alloc_error_handler"),
68+
&mangle_internal_symbol(tcx, ALLOC_ERROR_HANDLER),
6969
Some(&mangle_internal_symbol(tcx, alloc_error_handler_name(alloc_error_handler_kind))),
7070
&[usize, usize], // size, align
7171
None,

compiler/rustc_codegen_ssa/src/back/symbol_export.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
use std::collections::hash_map::Entry::*;
22

33
use rustc_abi::{CanonAbi, X86Call};
4-
use rustc_ast::expand::allocator::{ALLOCATOR_METHODS, NO_ALLOC_SHIM_IS_UNSTABLE, global_fn_name};
4+
use rustc_ast::expand::allocator::{
5+
ALLOC_ERROR_HANDLER, ALLOCATOR_METHODS, NO_ALLOC_SHIM_IS_UNSTABLE, global_fn_name,
6+
};
57
use rustc_data_structures::unord::UnordMap;
68
use rustc_hir::def::DefKind;
79
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LOCAL_CRATE, LocalDefId};
@@ -217,7 +219,7 @@ fn exported_symbols_provider_local<'tcx>(
217219
.iter()
218220
.map(|method| mangle_internal_symbol(tcx, global_fn_name(method.name).as_str()))
219221
.chain([
220-
mangle_internal_symbol(tcx, "__rust_alloc_error_handler"),
222+
mangle_internal_symbol(tcx, ALLOC_ERROR_HANDLER),
221223
mangle_internal_symbol(tcx, OomStrategy::SYMBOL),
222224
mangle_internal_symbol(tcx, NO_ALLOC_SHIM_IS_UNSTABLE),
223225
])

0 commit comments

Comments
 (0)