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.
This commit is contained in:
Kevin Ballard
2014-05-20 21:25:42 -07:00
parent e546452727
commit 23ca66ecd2
5 changed files with 48 additions and 28 deletions

View File

@@ -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());