about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorKevin Ballard <kevin@sb.org>2014-05-20 21:25:42 -0700
committerKevin Ballard <kevin@sb.org>2014-05-20 22:44:58 -0700
commit23ca66ecd2e10d0c6de2e3a657f58f6db35d0a9a (patch)
tree23080e165636b6b8845413e5eedf42b69bd1cba2 /src/libsyntax
parente546452727379f701f2104eb826141a29d4b39fd (diff)
downloadrust-23ca66ecd2e10d0c6de2e3a657f58f6db35d0a9a.tar.gz
rust-23ca66ecd2e10d0c6de2e3a657f58f6db35d0a9a.zip
Change std inject attributes to outer attributes
The #[phase(syntax,link)] attribute on `extern crate std` needs to be an
outer attribute so it can pretty-print properly.

Also add `#![no_std]` and `#[feature(phase)]` so compiling the
pretty-printed source will work.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/attr.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs
index cf5163af717..5a57c2d6cc6 100644
--- a/src/libsyntax/attr.rs
+++ b/src/libsyntax/attr.rs
@@ -126,7 +126,11 @@ impl AttributeMethods for Attribute {
                 InternedString::new("doc"),
                 token::intern_and_get_ident(strip_doc_comment_decoration(
                         comment.get()).as_slice()));
-            mk_attr(meta)
+            if self.node.style == ast::AttrOuter {
+                mk_attr_outer(meta)
+            } else {
+                mk_attr_inner(meta)
+            }
         } else {
             *self
         }
@@ -154,7 +158,8 @@ pub fn mk_word_item(name: InternedString) -> @MetaItem {
     @dummy_spanned(MetaWord(name))
 }
 
-pub fn mk_attr(item: @MetaItem) -> Attribute {
+/// Returns an inner attribute with the given value.
+pub fn mk_attr_inner(item: @MetaItem) -> Attribute {
     dummy_spanned(Attribute_ {
         style: ast::AttrInner,
         value: item,
@@ -162,6 +167,15 @@ pub fn mk_attr(item: @MetaItem) -> Attribute {
     })
 }
 
+/// Returns an outer attribute with the given value.
+pub fn mk_attr_outer(item: @MetaItem) -> Attribute {
+    dummy_spanned(Attribute_ {
+        style: ast::AttrOuter,
+        value: item,
+        is_sugared_doc: false,
+    })
+}
+
 pub fn mk_sugared_doc_attr(text: InternedString, lo: BytePos, hi: BytePos)
                            -> Attribute {
     let style = doc_comment_style(text.get());