Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 74a6d1c

Browse files
committed
Turn #[allocator] into a built-in attribute and rename it to #[rustc_allocator]
1 parent 8049e61 commit 74a6d1c

File tree

8 files changed

+13
-65
lines changed

8 files changed

+13
-65
lines changed

src/liballoc/alloc.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ extern "Rust" {
1515
// them from the `#[global_allocator]` attribute if there is one, or uses the
1616
// default implementations in libstd (`__rdl_alloc` etc in `src/libstd/alloc.rs`)
1717
// otherwise.
18-
#[allocator]
18+
#[cfg_attr(bootstrap, allocator)]
19+
#[cfg_attr(not(bootstrap), rustc_allocator)]
1920
#[rustc_allocator_nounwind]
2021
fn __rust_alloc(size: usize, align: usize) -> *mut u8;
2122
#[rustc_allocator_nounwind]

src/liballoc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
#![feature(coerce_unsized)]
8080
#![feature(dispatch_from_dyn)]
8181
#![feature(core_intrinsics)]
82-
#![feature(custom_attribute)]
82+
#![cfg_attr(bootstrap, feature(custom_attribute))]
8383
#![feature(dropck_eyepatch)]
8484
#![feature(exact_size_is_empty)]
8585
#![feature(fmt_internals)]

src/librustc/hir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2574,7 +2574,7 @@ bitflags! {
25742574
/// `#[cold]`: a hint to LLVM that this function, when called, is never on
25752575
/// the hot path.
25762576
const COLD = 1 << 0;
2577-
/// `#[allocator]`: a hint to LLVM that the pointer returned from this
2577+
/// `#[rustc_allocator]`: a hint to LLVM that the pointer returned from this
25782578
/// function is never null.
25792579
const ALLOCATOR = 1 << 1;
25802580
/// `#[unwind]`: an indicator that this function may unwind despite what

src/librustc_typeck/collect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2445,7 +2445,7 @@ fn codegen_fn_attrs<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: DefId) -> Codegen
24452445
for attr in attrs.iter() {
24462446
if attr.check_name(sym::cold) {
24472447
codegen_fn_attrs.flags |= CodegenFnAttrFlags::COLD;
2448-
} else if attr.check_name(sym::allocator) {
2448+
} else if attr.check_name(sym::rustc_allocator) {
24492449
codegen_fn_attrs.flags |= CodegenFnAttrFlags::ALLOCATOR;
24502450
} else if attr.check_name(sym::unwind) {
24512451
codegen_fn_attrs.flags |= CodegenFnAttrFlags::UNWIND;

src/libsyntax/feature_gate.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,6 +1331,11 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
13311331
"internal implementation detail",
13321332
cfg_fn!(rustc_attrs))),
13331333

1334+
(sym::rustc_allocator, Whitelisted, template!(Word), Gated(Stability::Unstable,
1335+
sym::rustc_attrs,
1336+
"internal implementation detail",
1337+
cfg_fn!(rustc_attrs))),
1338+
13341339
// FIXME: #14408 whitelist docs since rustdoc looks at them
13351340
(
13361341
sym::doc,

src/libsyntax_pos/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ symbols! {
513513
rust_2018_preview,
514514
rust_begin_unwind,
515515
rustc,
516+
rustc_allocator,
516517
rustc_allocator_nounwind,
517518
rustc_allow_const_fn_ptr,
518519
rustc_args_required_const,

src/test/codegen/function-arguments.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// ignore-tidy-linelength
33

44
#![crate_type = "lib"]
5-
#![feature(custom_attribute)]
5+
#![feature(rustc_attrs)]
66

77
pub struct S {
88
_field: [i32; 8],
@@ -146,7 +146,7 @@ pub fn enum_id_2(x: Option<u8>) -> Option<u8> {
146146

147147
// CHECK: noalias i8* @allocator()
148148
#[no_mangle]
149-
#[allocator]
149+
#[rustc_allocator]
150150
pub fn allocator() -> *const i8 {
151151
std::ptr::null()
152152
}

src/test/run-pass/auxiliary/allocator-dummy.rs

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)