From 23ca66ecd2e10d0c6de2e3a657f58f6db35d0a9a Mon Sep 17 00:00:00 2001 From: Kevin Ballard Date: Tue, 20 May 2014 21:25:42 -0700 Subject: 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. --- src/libsyntax/attr.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/libsyntax') 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()); -- cgit 1.4.1-3-g733a5