about summary refs log tree commit diff
path: root/src/libsyntax_ext/test.rs
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-07-25 23:21:00 +0200
committerGitHub <noreply@github.com>2019-07-25 23:21:00 +0200
commite1de70b04548b2e899fcf0da09c29600cc05325e (patch)
treea74148f96104c5972f121069a0cfcab089d8082e /src/libsyntax_ext/test.rs
parent6f0e57fb1dc3b30126e6ec6c9dd2ad0309da2c0c (diff)
parenta0c2c640d54fa1622c2fea4accae1025bf109c47 (diff)
downloadrust-e1de70b04548b2e899fcf0da09c29600cc05325e.tar.gz
rust-e1de70b04548b2e899fcf0da09c29600cc05325e.zip
Rollup merge of #62735 - petrochenkov:galloc, r=alexcrichton
Turn `#[global_allocator]` into a regular attribute macro

It was a 99% macro with exception of some diagnostic details.

As a result of the change, `#[global_allocator]` now works in nested modules and even in nameless blocks.

Fixes https://github.com/rust-lang/rust/issues/44113
Fixes https://github.com/rust-lang/rust/issues/58072
Diffstat (limited to 'src/libsyntax_ext/test.rs')
-rw-r--r--src/libsyntax_ext/test.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/libsyntax_ext/test.rs b/src/libsyntax_ext/test.rs
index f8755a1d1d7..d381c42f9ce 100644
--- a/src/libsyntax_ext/test.rs
+++ b/src/libsyntax_ext/test.rs
@@ -1,31 +1,34 @@
 /// The expansion from a test function to the appropriate test struct for libtest
 /// Ideally, this code would be in libtest but for efficiency and error messages it lives here.
 
+use syntax::ast;
+use syntax::attr::{self, check_builtin_macro_attribute};
 use syntax::ext::base::*;
 use syntax::ext::build::AstBuilder;
 use syntax::ext::hygiene::SyntaxContext;
-use syntax::attr;
-use syntax::ast;
 use syntax::print::pprust;
 use syntax::symbol::{Symbol, sym};
 use syntax_pos::Span;
+
 use std::iter;
 
 pub fn expand_test(
     cx: &mut ExtCtxt<'_>,
     attr_sp: Span,
-    _meta_item: &ast::MetaItem,
+    meta_item: &ast::MetaItem,
     item: Annotatable,
 ) -> Vec<Annotatable> {
+    check_builtin_macro_attribute(cx, meta_item, sym::test);
     expand_test_or_bench(cx, attr_sp, item, false)
 }
 
 pub fn expand_bench(
     cx: &mut ExtCtxt<'_>,
     attr_sp: Span,
-    _meta_item: &ast::MetaItem,
+    meta_item: &ast::MetaItem,
     item: Annotatable,
 ) -> Vec<Annotatable> {
+    check_builtin_macro_attribute(cx, meta_item, sym::bench);
     expand_test_or_bench(cx, attr_sp, item, true)
 }