about summary refs log tree commit diff
path: root/src/libsyntax/std_inject.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-03-19 10:56:08 +0000
committerbors <bors@rust-lang.org>2017-03-19 10:56:08 +0000
commit9c15de4fd59bee290848b5443c7e194fd5afb02c (patch)
treefb3ddd382a56f1f6ce7fcecdb9c45fcc6032b352 /src/libsyntax/std_inject.rs
parentbfc49b1092512aee4fe3d1348c3250fcdc8978d3 (diff)
parent85e02bdbfcfd0e38def7656a8295a5260640fd4a (diff)
downloadrust-9c15de4fd59bee290848b5443c7e194fd5afb02c.tar.gz
rust-9c15de4fd59bee290848b5443c7e194fd5afb02c.zip
Auto merge of #40346 - jseyfried:path_and_tokenstream_attr, r=nrc
`TokenStream`-based attributes, paths in attribute and derive macro invocations

This PR
 - refactors `Attribute` to use  `Path` and `TokenStream` instead of `MetaItem`.
 - supports macro invocation paths for attribute procedural macros.
   - e.g. `#[::foo::attr_macro] struct S;`, `#[cfg_attr(all(), foo::attr_macro)] struct S;`
 - supports macro invocation paths for derive procedural macros.
   - e.g. `#[derive(foo::Bar, super::Baz)] struct S;`
 - supports arbitrary tokens as arguments to attribute procedural macros.
   - e.g. `#[foo::attr_macro arbitrary + tokens] struct S;`
 - supports using arbitrary tokens in "inert attributes" with derive procedural macros.
   - e.g. `#[derive(Foo)] struct S(#[inert arbitrary + tokens] i32);`
where `#[proc_macro_derive(Foo, attributes(inert))]`

r? @nrc
Diffstat (limited to 'src/libsyntax/std_inject.rs')
-rw-r--r--src/libsyntax/std_inject.rs8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/libsyntax/std_inject.rs b/src/libsyntax/std_inject.rs
index 2192d203cdc..c541df9230a 100644
--- a/src/libsyntax/std_inject.rs
+++ b/src/libsyntax/std_inject.rs
@@ -15,6 +15,7 @@ use syntax_pos::{DUMMY_SP, Span};
 use codemap::{self, ExpnInfo, NameAndSpan, MacroAttribute};
 use parse::ParseSess;
 use ptr::P;
+use tokenstream::TokenStream;
 
 /// Craft a span that will be ignored by the stability lint's
 /// call to codemap's is_internal check.
@@ -70,11 +71,8 @@ pub fn maybe_inject_crates_ref(sess: &ParseSess,
     krate.module.items.insert(0, P(ast::Item {
         attrs: vec![ast::Attribute {
             style: ast::AttrStyle::Outer,
-            value: ast::MetaItem {
-                name: Symbol::intern("prelude_import"),
-                node: ast::MetaItemKind::Word,
-                span: span,
-            },
+            path: ast::Path::from_ident(span, ast::Ident::from_str("prelude_import")),
+            tokens: TokenStream::empty(),
             id: attr::mk_attr_id(),
             is_sugared_doc: false,
             span: span,