Skip to content

Commit 145b057

Browse files
committed
Use global_fn_name instead of format!
1 parent 6ba7c5d commit 145b057

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

compiler/rustc_codegen_cranelift/src/allocator.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
use crate::prelude::*;
55

66
use rustc_ast::expand::allocator::{
7-
alloc_error_handler_name, default_fn_name, AllocatorKind, AllocatorTy, ALLOCATOR_METHODS,
7+
alloc_error_handler_name, default_fn_name, global_fn_name, AllocatorKind, AllocatorTy,
8+
ALLOCATOR_METHODS,
89
};
910
use rustc_codegen_ssa::base::allocator_kind_for_codegen;
1011
use rustc_session::config::OomStrategy;
@@ -68,7 +69,7 @@ fn codegen_inner(
6869
module,
6970
unwind_context,
7071
sig,
71-
&format!("__rust_{}", method.name),
72+
&global_fn_name(method.name),
7273
&default_fn_name(method.name),
7374
);
7475
}

compiler/rustc_codegen_gcc/src/allocator.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
use gccjit::FnAttribute;
33
use gccjit::{FunctionType, GlobalKind, ToRValue};
44
use rustc_ast::expand::allocator::{
5-
alloc_error_handler_name, default_fn_name, AllocatorKind, AllocatorTy, ALLOCATOR_METHODS,
5+
alloc_error_handler_name, default_fn_name, global_fn_name, AllocatorKind, AllocatorTy,
6+
ALLOCATOR_METHODS,
67
};
78
use rustc_middle::bug;
89
use rustc_middle::ty::TyCtxt;
@@ -46,7 +47,7 @@ pub(crate) unsafe fn codegen(tcx: TyCtxt<'_>, mods: &mut GccContext, _module_nam
4647
panic!("invalid allocator output")
4748
}
4849
};
49-
let name = format!("__rust_{}", method.name);
50+
let name = global_fn_name(method.name);
5051

5152
let args: Vec<_> = types.iter().enumerate()
5253
.map(|(index, typ)| context.new_parameter(None, *typ, &format!("param{}", index)))

compiler/rustc_codegen_llvm/src/allocator.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use crate::attributes;
22
use libc::c_uint;
33
use rustc_ast::expand::allocator::{
4-
alloc_error_handler_name, default_fn_name, AllocatorKind, AllocatorTy, ALLOCATOR_METHODS,
4+
alloc_error_handler_name, default_fn_name, global_fn_name, AllocatorKind, AllocatorTy,
5+
ALLOCATOR_METHODS,
56
};
67
use rustc_middle::bug;
78
use rustc_middle::ty::TyCtxt;
@@ -59,7 +60,7 @@ pub(crate) unsafe fn codegen(
5960
args.len() as c_uint,
6061
False,
6162
);
62-
let name = format!("__rust_{}", method.name);
63+
let name = global_fn_name(method.name);
6364
let llfn =
6465
llvm::LLVMRustGetOrInsertFunction(llmod, name.as_ptr().cast(), name.len(), ty);
6566

0 commit comments

Comments
 (0)