about summary refs log tree commit diff
path: root/src/libsyntax_ext/global_allocator.rs
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-07-19 02:10:36 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-07-24 12:29:45 +0300
commit76b1ffaf6c70abd3fa4da2e694dc709116258098 (patch)
tree86f34d3ebbe34aa49072a1447c8adcfc0623a2ce /src/libsyntax_ext/global_allocator.rs
parent433024147ae1e9795fe7e94cb1810a17fd37fa51 (diff)
downloadrust-76b1ffaf6c70abd3fa4da2e694dc709116258098.tar.gz
rust-76b1ffaf6c70abd3fa4da2e694dc709116258098.zip
syntax_ext: Reuse built-in attribute template checking for macro attributes
Diffstat (limited to 'src/libsyntax_ext/global_allocator.rs')
-rw-r--r--src/libsyntax_ext/global_allocator.rs19
1 files changed, 5 insertions, 14 deletions
diff --git a/src/libsyntax_ext/global_allocator.rs b/src/libsyntax_ext/global_allocator.rs
index 785636abb12..196db3d7baa 100644
--- a/src/libsyntax_ext/global_allocator.rs
+++ b/src/libsyntax_ext/global_allocator.rs
@@ -1,31 +1,22 @@
-use errors::Applicability;
-use syntax::ast::{self, Arg, Attribute, Expr, FnHeader, Generics, Ident, Item};
 use syntax::ast::{ItemKind, Mutability, Ty, TyKind, Unsafety, VisibilityKind};
-use syntax::source_map::respan;
+use syntax::ast::{self, Arg, Attribute, Expr, FnHeader, Generics, Ident, Item};
+use syntax::attr::check_builtin_macro_attribute;
 use syntax::ext::allocator::{AllocatorKind, AllocatorMethod, AllocatorTy, ALLOCATOR_METHODS};
 use syntax::ext::base::{Annotatable, ExtCtxt};
 use syntax::ext::build::AstBuilder;
 use syntax::ext::hygiene::SyntaxContext;
 use syntax::ptr::P;
+use syntax::source_map::respan;
 use syntax::symbol::{kw, sym};
 use syntax_pos::Span;
 
 pub fn expand(
     ecx: &mut ExtCtxt<'_>,
-    span: Span,
+    _span: Span,
     meta_item: &ast::MetaItem,
     item: Annotatable,
 ) -> Vec<Annotatable> {
-    if !meta_item.is_word() {
-        let msg = format!("malformed `{}` attribute input", meta_item.path);
-        ecx.parse_sess.span_diagnostic.struct_span_err(span, &msg)
-            .span_suggestion(
-                span,
-                "must be of the form",
-                format!("`#[{}]`", meta_item.path),
-                Applicability::MachineApplicable
-            ).emit();
-    }
+    check_builtin_macro_attribute(ecx, meta_item, sym::global_allocator);
 
     let not_static = |item: Annotatable| {
         ecx.parse_sess.span_diagnostic.span_err(item.span(), "allocators must be statics");