Stop re-exporting AttrStyle's variants and rename them.

This commit is contained in:
Ms2ger 2015-10-01 18:03:34 +02:00
parent 24202c6431
commit b093060c2a
12 changed files with 31 additions and 32 deletions

View file

@ -1115,7 +1115,7 @@ fn get_attributes(md: rbml::Doc) -> Vec<ast::Attribute> {
codemap::Spanned { codemap::Spanned {
node: ast::Attribute_ { node: ast::Attribute_ {
id: attr::mk_attr_id(), id: attr::mk_attr_id(),
style: ast::AttrOuter, style: ast::AttrStyle::Outer,
value: meta_item, value: meta_item,
is_sugared_doc: is_sugared_doc, is_sugared_doc: is_sugared_doc,
}, },

View file

@ -180,7 +180,7 @@ pub fn mk_attr_id() -> AttrId {
pub fn mk_attr_inner(id: AttrId, item: P<MetaItem>) -> Attribute { pub fn mk_attr_inner(id: AttrId, item: P<MetaItem>) -> Attribute {
dummy_spanned(Attribute_ { dummy_spanned(Attribute_ {
id: id, id: id,
style: hir::AttrInner, style: hir::AttrStyle::Inner,
value: item, value: item,
is_sugared_doc: false, is_sugared_doc: false,
}) })
@ -190,7 +190,7 @@ pub fn mk_attr_inner(id: AttrId, item: P<MetaItem>) -> Attribute {
pub fn mk_attr_outer(id: AttrId, item: P<MetaItem>) -> Attribute { pub fn mk_attr_outer(id: AttrId, item: P<MetaItem>) -> Attribute {
dummy_spanned(Attribute_ { dummy_spanned(Attribute_ {
id: id, id: id,
style: hir::AttrOuter, style: hir::AttrStyle::Outer,
value: item, value: item,
is_sugared_doc: false, is_sugared_doc: false,
}) })

View file

@ -285,9 +285,9 @@ impl LateLintPass for UnusedAttributes {
}).is_some(); }).is_some();
if known_crate || plugin_crate { if known_crate || plugin_crate {
let msg = match attr.node.style { let msg = match attr.node.style {
ast::AttrOuter => "crate-level attribute should be an inner \ ast::AttrStyle::Outer => "crate-level attribute should be an inner \
attribute: add an exclamation mark: #![foo]", attribute: add an exclamation mark: #![foo]",
ast::AttrInner => "crate-level attribute should be in the \ ast::AttrStyle::Inner => "crate-level attribute should be in the \
root module", root module",
}; };
cx.span_lint(UNUSED_ATTRIBUTES, attr.span, msg); cx.span_lint(UNUSED_ATTRIBUTES, attr.span, msg);

View file

@ -10,7 +10,6 @@
// The Rust abstract syntax tree. // The Rust abstract syntax tree.
pub use self::AttrStyle::*;
pub use self::BindingMode::*; pub use self::BindingMode::*;
pub use self::BinOp_::*; pub use self::BinOp_::*;
pub use self::BlockCheckMode::*; pub use self::BlockCheckMode::*;
@ -1019,8 +1018,8 @@ impl TokenTree {
match *self { match *self {
TtToken(_, token::DocComment(name)) => { TtToken(_, token::DocComment(name)) => {
match doc_comment_style(&name.as_str()) { match doc_comment_style(&name.as_str()) {
AttrOuter => 2, AttrStyle::Outer => 2,
AttrInner => 3 AttrStyle::Inner => 3
} }
} }
TtToken(_, token::SpecialVarNt(..)) => 2, TtToken(_, token::SpecialVarNt(..)) => 2,
@ -1041,7 +1040,7 @@ impl TokenTree {
TtToken(sp, token::Pound) TtToken(sp, token::Pound)
} }
(&TtToken(sp, token::DocComment(name)), 1) (&TtToken(sp, token::DocComment(name)), 1)
if doc_comment_style(&name.as_str()) == AttrInner => { if doc_comment_style(&name.as_str()) == AttrStyle::Inner => {
TtToken(sp, token::Not) TtToken(sp, token::Not)
} }
(&TtToken(sp, token::DocComment(name)), _) => { (&TtToken(sp, token::DocComment(name)), _) => {
@ -1658,8 +1657,8 @@ pub type Attribute = Spanned<Attribute_>;
/// distinguished for pretty-printing. /// distinguished for pretty-printing.
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
pub enum AttrStyle { pub enum AttrStyle {
AttrOuter, Outer,
AttrInner, Inner,
} }
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]

View file

@ -156,7 +156,7 @@ impl AttributeMethods for Attribute {
InternedString::new("doc"), InternedString::new("doc"),
token::intern_and_get_ident(&strip_doc_comment_decoration( token::intern_and_get_ident(&strip_doc_comment_decoration(
&comment))); &comment)));
if self.node.style == ast::AttrOuter { if self.node.style == ast::AttrStyle::Outer {
f(&mk_attr_outer(self.node.id, meta)) f(&mk_attr_outer(self.node.id, meta))
} else { } else {
f(&mk_attr_inner(self.node.id, meta)) f(&mk_attr_inner(self.node.id, meta))
@ -203,7 +203,7 @@ pub fn mk_attr_id() -> AttrId {
pub fn mk_attr_inner(id: AttrId, item: P<MetaItem>) -> Attribute { pub fn mk_attr_inner(id: AttrId, item: P<MetaItem>) -> Attribute {
dummy_spanned(Attribute_ { dummy_spanned(Attribute_ {
id: id, id: id,
style: ast::AttrInner, style: ast::AttrStyle::Inner,
value: item, value: item,
is_sugared_doc: false, is_sugared_doc: false,
}) })
@ -213,7 +213,7 @@ pub fn mk_attr_inner(id: AttrId, item: P<MetaItem>) -> Attribute {
pub fn mk_attr_outer(id: AttrId, item: P<MetaItem>) -> Attribute { pub fn mk_attr_outer(id: AttrId, item: P<MetaItem>) -> Attribute {
dummy_spanned(Attribute_ { dummy_spanned(Attribute_ {
id: id, id: id,
style: ast::AttrOuter, style: ast::AttrStyle::Outer,
value: item, value: item,
is_sugared_doc: false, is_sugared_doc: false,
}) })

View file

@ -1079,7 +1079,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
fn attribute(&self, sp: Span, mi: P<ast::MetaItem>) -> ast::Attribute { fn attribute(&self, sp: Span, mi: P<ast::MetaItem>) -> ast::Attribute {
respan(sp, ast::Attribute_ { respan(sp, ast::Attribute_ {
id: attr::mk_attr_id(), id: attr::mk_attr_id(),
style: ast::AttrOuter, style: ast::AttrStyle::Outer,
value: mi, value: mi,
is_sugared_doc: false, is_sugared_doc: false,
}) })

View file

@ -660,7 +660,7 @@ fn contains_macro_use(fld: &mut MacroExpander, attrs: &[ast::Attribute]) -> bool
if attr.check_name("macro_escape") { if attr.check_name("macro_escape") {
fld.cx.span_warn(attr.span, "macro_escape is a deprecated synonym for macro_use"); fld.cx.span_warn(attr.span, "macro_escape is a deprecated synonym for macro_use");
is_use = true; is_use = true;
if let ast::AttrInner = attr.node.style { if let ast::AttrStyle::Inner = attr.node.style {
fld.cx.fileline_help(attr.span, "consider an outer attribute, \ fld.cx.fileline_help(attr.span, "consider an outer attribute, \
#[macro_use] mod ..."); #[macro_use] mod ...");
} }

View file

@ -187,7 +187,7 @@ pub mod rt {
let mut r = vec![]; let mut r = vec![];
// FIXME: The spans could be better // FIXME: The spans could be better
r.push(ast::TtToken(self.span, token::Pound)); r.push(ast::TtToken(self.span, token::Pound));
if self.node.style == ast::AttrInner { if self.node.style == ast::AttrStyle::Inner {
r.push(ast::TtToken(self.span, token::Not)); r.push(ast::TtToken(self.span, token::Not));
} }
r.push(ast::TtDelimited(self.span, Rc::new(ast::Delimited { r.push(ast::TtDelimited(self.span, Rc::new(ast::Delimited {

View file

@ -44,7 +44,7 @@ impl<'a> ParserAttr for Parser<'a> {
self.span.lo, self.span.lo,
self.span.hi self.span.hi
); );
if attr.node.style != ast::AttrOuter { if attr.node.style != ast::AttrStyle::Outer {
panic!(self.fatal("expected outer comment")); panic!(self.fatal("expected outer comment"));
} }
attrs.push(attr); attrs.push(attr);
@ -79,9 +79,9 @@ impl<'a> ParserAttr for Parser<'a> {
self.fileline_help(span, self.fileline_help(span,
"place inner attribute at the top of the module or block"); "place inner attribute at the top of the module or block");
} }
ast::AttrInner ast::AttrStyle::Inner
} else { } else {
ast::AttrOuter ast::AttrStyle::Outer
}; };
panictry!(self.expect(&token::OpenDelim(token::Bracket))); panictry!(self.expect(&token::OpenDelim(token::Bracket)));
@ -101,7 +101,7 @@ impl<'a> ParserAttr for Parser<'a> {
panictry!(self.bump()); panictry!(self.bump());
self.span_warn(span, "this inner attribute syntax is deprecated. \ self.span_warn(span, "this inner attribute syntax is deprecated. \
The new syntax is `#![foo]`, with a bang and no semicolon"); The new syntax is `#![foo]`, with a bang and no semicolon");
style = ast::AttrInner; style = ast::AttrStyle::Inner;
} }
return Spanned { return Spanned {
@ -131,7 +131,7 @@ impl<'a> ParserAttr for Parser<'a> {
} }
let attr = self.parse_attribute(true); let attr = self.parse_attribute(true);
assert!(attr.node.style == ast::AttrInner); assert!(attr.node.style == ast::AttrStyle::Inner);
attrs.push(attr); attrs.push(attr);
} }
token::DocComment(s) => { token::DocComment(s) => {
@ -139,7 +139,7 @@ impl<'a> ParserAttr for Parser<'a> {
let Span { lo, hi, .. } = self.span; let Span { lo, hi, .. } = self.span;
let str = self.id_to_interned_str(ast::Ident::with_empty_ctxt(s)); let str = self.id_to_interned_str(ast::Ident::with_empty_ctxt(s));
let attr = attr::mk_sugared_doc_attr(attr::mk_attr_id(), str, lo, hi); let attr = attr::mk_sugared_doc_attr(attr::mk_attr_id(), str, lo, hi);
if attr.node.style == ast::AttrInner { if attr.node.style == ast::AttrStyle::Inner {
attrs.push(attr); attrs.push(attr);
panictry!(self.bump()); panictry!(self.bump());
} else { } else {

View file

@ -52,9 +52,9 @@ pub fn is_doc_comment(s: &str) -> bool {
pub fn doc_comment_style(comment: &str) -> ast::AttrStyle { pub fn doc_comment_style(comment: &str) -> ast::AttrStyle {
assert!(is_doc_comment(comment)); assert!(is_doc_comment(comment));
if comment.starts_with("//!") || comment.starts_with("/*!") { if comment.starts_with("//!") || comment.starts_with("/*!") {
ast::AttrInner ast::AttrStyle::Inner
} else { } else {
ast::AttrOuter ast::AttrStyle::Outer
} }
} }

View file

@ -709,7 +709,7 @@ pub trait PrintState<'a> {
let mut count = 0; let mut count = 0;
for attr in attrs { for attr in attrs {
match attr.node.style { match attr.node.style {
ast::AttrInner => { ast::AttrStyle::Inner => {
try!(self.print_attribute(attr)); try!(self.print_attribute(attr));
count += 1; count += 1;
} }
@ -727,7 +727,7 @@ pub trait PrintState<'a> {
let mut count = 0; let mut count = 0;
for attr in attrs { for attr in attrs {
match attr.node.style { match attr.node.style {
ast::AttrOuter => { ast::AttrStyle::Outer => {
try!(self.print_attribute(attr)); try!(self.print_attribute(attr));
count += 1; count += 1;
} }
@ -747,8 +747,8 @@ pub trait PrintState<'a> {
word(self.writer(), &attr.value_str().unwrap()) word(self.writer(), &attr.value_str().unwrap())
} else { } else {
match attr.node.style { match attr.node.style {
ast::AttrInner => try!(word(self.writer(), "#![")), ast::AttrStyle::Inner => try!(word(self.writer(), "#![")),
ast::AttrOuter => try!(word(self.writer(), "#[")), ast::AttrStyle::Outer => try!(word(self.writer(), "#[")),
} }
try!(self.print_meta_item(&*attr.meta())); try!(self.print_meta_item(&*attr.meta()));
word(self.writer(), "]") word(self.writer(), "]")

View file

@ -154,7 +154,7 @@ impl fold::Folder for PreludeInjector {
span: self.span, span: self.span,
node: ast::Attribute_ { node: ast::Attribute_ {
id: attr::mk_attr_id(), id: attr::mk_attr_id(),
style: ast::AttrOuter, style: ast::AttrStyle::Outer,
value: P(ast::MetaItem { value: P(ast::MetaItem {
span: self.span, span: self.span,
node: ast::MetaWord(special_idents::prelude_import.name.as_str()), node: ast::MetaWord(special_idents::prelude_import.name.as_str()),