Skip to content

Commit 36c1bbb

Browse files
committed
Remove exchange_malloc lang item.
1 parent 10603a7 commit 36c1bbb

File tree

7 files changed

+3
-30
lines changed

7 files changed

+3
-30
lines changed

compiler/rustc_codegen_cranelift/example/mini_core.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -619,11 +619,6 @@ impl<T: ?Sized> Deref for Box<T> {
619619
}
620620
}
621621

622-
#[lang = "exchange_malloc"]
623-
unsafe fn allocate(size: usize, _align: usize) -> *mut u8 {
624-
libc::malloc(size)
625-
}
626-
627622
#[lang = "drop"]
628623
pub trait Drop {
629624
fn drop(&mut self);

compiler/rustc_codegen_gcc/example/mini_core.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -628,11 +628,6 @@ impl<T: ?Sized, A: Allocator> Deref for Box<T, A> {
628628
}
629629
}
630630

631-
#[lang = "exchange_malloc"]
632-
unsafe fn allocate(size: usize, _align: usize) -> *mut u8 {
633-
libc::malloc(size)
634-
}
635-
636631
#[lang = "drop"]
637632
pub trait Drop {
638633
fn drop(&mut self);

compiler/rustc_const_eval/src/check_consts/check.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -852,9 +852,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
852852
}
853853

854854
// This can be called on stable via the `vec!` macro.
855-
if tcx.is_lang_item(callee, LangItem::ExchangeMalloc)
856-
|| tcx.is_diagnostic_item(sym::box_new, callee)
857-
{
855+
if tcx.is_diagnostic_item(sym::box_new, callee) {
858856
self.check_op(ops::HeapAllocation);
859857
// Allow this call, skip all the checks below.
860858
return;

compiler/rustc_hir/src/lang_items.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,6 @@ language_item_table! {
330330
FormatPlaceholder, sym::format_placeholder, format_placeholder, Target::Struct, GenericRequirement::None;
331331
FormatUnsafeArg, sym::format_unsafe_arg, format_unsafe_arg, Target::Struct, GenericRequirement::None;
332332

333-
ExchangeMalloc, sym::exchange_malloc, exchange_malloc_fn, Target::Fn, GenericRequirement::None;
334333
DropInPlace, sym::drop_in_place, drop_in_place_fn, Target::Fn, GenericRequirement::Minimum(1);
335334
AllocLayout, sym::alloc_layout, alloc_layout, Target::Struct, GenericRequirement::None;
336335

compiler/rustc_span/src/symbol.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,6 @@ symbols! {
944944
exact_div,
945945
except,
946946
exception_handling: "exception-handling",
947-
exchange_malloc,
948947
exclusive_range_pattern,
949948
exhaustive_integer_patterns,
950949
exhaustive_patterns,

library/alloc/src/alloc.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -342,19 +342,6 @@ unsafe impl Allocator for Global {
342342
}
343343
}
344344

345-
/// The allocator for `Box`.
346-
#[cfg(not(no_global_oom_handling))]
347-
#[lang = "exchange_malloc"]
348-
#[inline]
349-
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
350-
unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 {
351-
let layout = unsafe { Layout::from_size_align_unchecked(size, align) };
352-
match Global.allocate(layout) {
353-
Ok(ptr) => ptr.as_mut_ptr(),
354-
Err(_) => handle_alloc_error(layout),
355-
}
356-
}
357-
358345
// # Allocation error handler
359346

360347
#[cfg(not(no_global_oom_handling))]

src/doc/rustc-dev-guide/src/lang-items.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ Features provided by lang items include:
2323
`core::marker`; lang item `phantom_data`.
2424

2525
Lang items are loaded lazily by the compiler; e.g. if one never uses `Box`
26-
then there is no need to define functions for `exchange_malloc` and
27-
`box_free`. `rustc` will emit an error when an item is needed but not found
26+
then there is no need to define struct `global_alloc_ty`.
27+
`rustc` will emit an error when an item is needed but not found
2828
in the current crate or any that it depends on.
2929

3030
Most lang items are defined by the `core` library, but if you're trying to build an

0 commit comments

Comments
 (0)