about summary refs log tree commit diff
path: root/compiler/rustc_ast/src/expand/allocator.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_ast/src/expand/allocator.rs')
-rw-r--r--compiler/rustc_ast/src/expand/allocator.rs22
1 files changed, 15 insertions, 7 deletions
diff --git a/compiler/rustc_ast/src/expand/allocator.rs b/compiler/rustc_ast/src/expand/allocator.rs
index 35939496348..e87f6e820a1 100644
--- a/compiler/rustc_ast/src/expand/allocator.rs
+++ b/compiler/rustc_ast/src/expand/allocator.rs
@@ -1,20 +1,28 @@
 use rustc_span::symbol::{sym, Symbol};
 
-#[derive(Clone, Debug, Copy, HashStable_Generic)]
+#[derive(Clone, Debug, Copy, Eq, PartialEq, HashStable_Generic)]
 pub enum AllocatorKind {
     Global,
     Default,
 }
 
-impl AllocatorKind {
-    pub fn fn_name(&self, base: Symbol) -> String {
-        match *self {
-            AllocatorKind::Global => format!("__rg_{base}"),
-            AllocatorKind::Default => format!("__rdl_{base}"),
-        }
+pub fn global_fn_name(base: Symbol) -> String {
+    format!("__rust_{base}")
+}
+
+pub fn default_fn_name(base: Symbol) -> String {
+    format!("__rdl_{base}")
+}
+
+pub fn alloc_error_handler_name(alloc_error_handler_kind: AllocatorKind) -> &'static str {
+    match alloc_error_handler_kind {
+        AllocatorKind::Global => "__rg_oom",
+        AllocatorKind::Default => "__rdl_oom",
     }
 }
 
+pub const NO_ALLOC_SHIM_IS_UNSTABLE: &str = "__rust_no_alloc_shim_is_unstable";
+
 pub enum AllocatorTy {
     Layout,
     Ptr,