Skip to content

Commit

Permalink
Turn #[allocator] into a built-in attribute and rename it to `#[rus…
Browse files Browse the repository at this point in the history
…tc_allocator]`
  • Loading branch information
petrochenkov committed Jun 8, 2019
1 parent 8049e61 commit 74a6d1c
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 65 deletions.
3 changes: 2 additions & 1 deletion src/liballoc/alloc.rs
Expand Up @@ -15,7 +15,8 @@ extern "Rust" {
// them from the `#[global_allocator]` attribute if there is one, or uses the
// default implementations in libstd (`__rdl_alloc` etc in `src/libstd/alloc.rs`)
// otherwise.
#[allocator]
#[cfg_attr(bootstrap, allocator)]
#[cfg_attr(not(bootstrap), rustc_allocator)]
#[rustc_allocator_nounwind]
fn __rust_alloc(size: usize, align: usize) -> *mut u8;
#[rustc_allocator_nounwind]
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/lib.rs
Expand Up @@ -79,7 +79,7 @@
#![feature(coerce_unsized)]
#![feature(dispatch_from_dyn)]
#![feature(core_intrinsics)]
#![feature(custom_attribute)]
#![cfg_attr(bootstrap, feature(custom_attribute))]
#![feature(dropck_eyepatch)]
#![feature(exact_size_is_empty)]
#![feature(fmt_internals)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/mod.rs
Expand Up @@ -2574,7 +2574,7 @@ bitflags! {
/// `#[cold]`: a hint to LLVM that this function, when called, is never on
/// the hot path.
const COLD = 1 << 0;
/// `#[allocator]`: a hint to LLVM that the pointer returned from this
/// `#[rustc_allocator]`: a hint to LLVM that the pointer returned from this
/// function is never null.
const ALLOCATOR = 1 << 1;
/// `#[unwind]`: an indicator that this function may unwind despite what
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/collect.rs
Expand Up @@ -2445,7 +2445,7 @@ fn codegen_fn_attrs<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: DefId) -> Codegen
for attr in attrs.iter() {
if attr.check_name(sym::cold) {
codegen_fn_attrs.flags |= CodegenFnAttrFlags::COLD;
} else if attr.check_name(sym::allocator) {
} else if attr.check_name(sym::rustc_allocator) {
codegen_fn_attrs.flags |= CodegenFnAttrFlags::ALLOCATOR;
} else if attr.check_name(sym::unwind) {
codegen_fn_attrs.flags |= CodegenFnAttrFlags::UNWIND;
Expand Down
5 changes: 5 additions & 0 deletions src/libsyntax/feature_gate.rs
Expand Up @@ -1331,6 +1331,11 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
"internal implementation detail",
cfg_fn!(rustc_attrs))),

(sym::rustc_allocator, Whitelisted, template!(Word), Gated(Stability::Unstable,
sym::rustc_attrs,
"internal implementation detail",
cfg_fn!(rustc_attrs))),

// FIXME: #14408 whitelist docs since rustdoc looks at them
(
sym::doc,
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax_pos/symbol.rs
Expand Up @@ -513,6 +513,7 @@ symbols! {
rust_2018_preview,
rust_begin_unwind,
rustc,
rustc_allocator,
rustc_allocator_nounwind,
rustc_allow_const_fn_ptr,
rustc_args_required_const,
Expand Down
4 changes: 2 additions & 2 deletions src/test/codegen/function-arguments.rs
Expand Up @@ -2,7 +2,7 @@
// ignore-tidy-linelength

#![crate_type = "lib"]
#![feature(custom_attribute)]
#![feature(rustc_attrs)]

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

// CHECK: noalias i8* @allocator()
#[no_mangle]
#[allocator]
#[rustc_allocator]
pub fn allocator() -> *const i8 {
std::ptr::null()
}
59 changes: 0 additions & 59 deletions src/test/run-pass/auxiliary/allocator-dummy.rs

This file was deleted.

0 comments on commit 74a6d1c

Please sign in to comment.