Skip to content

Commit

Permalink
Auto merge of #28793 - Ms2ger:AttrStyle, r=alexcrichton
Browse files Browse the repository at this point in the history
  • Loading branch information
bors committed Oct 2, 2015
2 parents 7643c4c + b093060 commit a004ff5
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/librustc/metadata/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ fn get_attributes(md: rbml::Doc) -> Vec<ast::Attribute> {
codemap::Spanned {
node: ast::Attribute_ {
id: attr::mk_attr_id(),
style: ast::AttrOuter,
style: ast::AttrStyle::Outer,
value: meta_item,
is_sugared_doc: is_sugared_doc,
},
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_front/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ pub fn mk_attr_id() -> AttrId {
pub fn mk_attr_inner(id: AttrId, item: P<MetaItem>) -> Attribute {
dummy_spanned(Attribute_ {
id: id,
style: hir::AttrInner,
style: hir::AttrStyle::Inner,
value: item,
is_sugared_doc: false,
})
Expand All @@ -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 {
dummy_spanned(Attribute_ {
id: id,
style: hir::AttrOuter,
style: hir::AttrStyle::Outer,
value: item,
is_sugared_doc: false,
})
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_lint/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,10 @@ impl LateLintPass for UnusedAttributes {
}).is_some();
if known_crate || plugin_crate {
let msg = match attr.node.style {
ast::AttrOuter => "crate-level attribute should be an inner \
attribute: add an exclamation mark: #![foo]",
ast::AttrInner => "crate-level attribute should be in the \
root module",
ast::AttrStyle::Outer => "crate-level attribute should be an inner \
attribute: add an exclamation mark: #![foo]",
ast::AttrStyle::Inner => "crate-level attribute should be in the \
root module",
};
cx.span_lint(UNUSED_ATTRIBUTES, attr.span, msg);
}
Expand Down
11 changes: 5 additions & 6 deletions src/libsyntax/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

// The Rust abstract syntax tree.

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

#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
Expand Down
6 changes: 3 additions & 3 deletions src/libsyntax/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl AttributeMethods for Attribute {
InternedString::new("doc"),
token::intern_and_get_ident(&strip_doc_comment_decoration(
&comment)));
if self.node.style == ast::AttrOuter {
if self.node.style == ast::AttrStyle::Outer {
f(&mk_attr_outer(self.node.id, meta))
} else {
f(&mk_attr_inner(self.node.id, meta))
Expand Down Expand Up @@ -203,7 +203,7 @@ pub fn mk_attr_id() -> AttrId {
pub fn mk_attr_inner(id: AttrId, item: P<MetaItem>) -> Attribute {
dummy_spanned(Attribute_ {
id: id,
style: ast::AttrInner,
style: ast::AttrStyle::Inner,
value: item,
is_sugared_doc: false,
})
Expand All @@ -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 {
dummy_spanned(Attribute_ {
id: id,
style: ast::AttrOuter,
style: ast::AttrStyle::Outer,
value: item,
is_sugared_doc: false,
})
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/ext/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
fn attribute(&self, sp: Span, mi: P<ast::MetaItem>) -> ast::Attribute {
respan(sp, ast::Attribute_ {
id: attr::mk_attr_id(),
style: ast::AttrOuter,
style: ast::AttrStyle::Outer,
value: mi,
is_sugared_doc: false,
})
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/ext/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ fn contains_macro_use(fld: &mut MacroExpander, attrs: &[ast::Attribute]) -> bool
if attr.check_name("macro_escape") {
fld.cx.span_warn(attr.span, "macro_escape is a deprecated synonym for macro_use");
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, \
#[macro_use] mod ...");
}
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/ext/quote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ pub mod rt {
let mut r = vec![];
// FIXME: The spans could be better
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::TtDelimited(self.span, Rc::new(ast::Delimited {
Expand Down
12 changes: 6 additions & 6 deletions src/libsyntax/parse/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl<'a> ParserAttr for Parser<'a> {
self.span.lo,
self.span.hi
);
if attr.node.style != ast::AttrOuter {
if attr.node.style != ast::AttrStyle::Outer {
panic!(self.fatal("expected outer comment"));
}
attrs.push(attr);
Expand Down Expand Up @@ -79,9 +79,9 @@ impl<'a> ParserAttr for Parser<'a> {
self.fileline_help(span,
"place inner attribute at the top of the module or block");
}
ast::AttrInner
ast::AttrStyle::Inner
} else {
ast::AttrOuter
ast::AttrStyle::Outer
};

panictry!(self.expect(&token::OpenDelim(token::Bracket)));
Expand All @@ -101,7 +101,7 @@ impl<'a> ParserAttr for Parser<'a> {
panictry!(self.bump());
self.span_warn(span, "this inner attribute syntax is deprecated. \
The new syntax is `#![foo]`, with a bang and no semicolon");
style = ast::AttrInner;
style = ast::AttrStyle::Inner;
}

return Spanned {
Expand Down Expand Up @@ -131,15 +131,15 @@ impl<'a> ParserAttr for Parser<'a> {
}

let attr = self.parse_attribute(true);
assert!(attr.node.style == ast::AttrInner);
assert!(attr.node.style == ast::AttrStyle::Inner);
attrs.push(attr);
}
token::DocComment(s) => {
// we need to get the position of this token before we bump.
let Span { lo, hi, .. } = self.span;
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);
if attr.node.style == ast::AttrInner {
if attr.node.style == ast::AttrStyle::Inner {
attrs.push(attr);
panictry!(self.bump());
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/parse/lexer/comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ pub fn is_doc_comment(s: &str) -> bool {
pub fn doc_comment_style(comment: &str) -> ast::AttrStyle {
assert!(is_doc_comment(comment));
if comment.starts_with("//!") || comment.starts_with("/*!") {
ast::AttrInner
ast::AttrStyle::Inner
} else {
ast::AttrOuter
ast::AttrStyle::Outer
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/libsyntax/print/pprust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ pub trait PrintState<'a> {
let mut count = 0;
for attr in attrs {
match attr.node.style {
ast::AttrInner => {
ast::AttrStyle::Inner => {
try!(self.print_attribute(attr));
count += 1;
}
Expand All @@ -727,7 +727,7 @@ pub trait PrintState<'a> {
let mut count = 0;
for attr in attrs {
match attr.node.style {
ast::AttrOuter => {
ast::AttrStyle::Outer => {
try!(self.print_attribute(attr));
count += 1;
}
Expand All @@ -747,8 +747,8 @@ pub trait PrintState<'a> {
word(self.writer(), &attr.value_str().unwrap())
} else {
match attr.node.style {
ast::AttrInner => try!(word(self.writer(), "#![")),
ast::AttrOuter => try!(word(self.writer(), "#[")),
ast::AttrStyle::Inner => try!(word(self.writer(), "#![")),
ast::AttrStyle::Outer => try!(word(self.writer(), "#[")),
}
try!(self.print_meta_item(&*attr.meta()));
word(self.writer(), "]")
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/std_inject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl fold::Folder for PreludeInjector {
span: self.span,
node: ast::Attribute_ {
id: attr::mk_attr_id(),
style: ast::AttrOuter,
style: ast::AttrStyle::Outer,
value: P(ast::MetaItem {
span: self.span,
node: ast::MetaWord(special_idents::prelude_import.name.as_str()),
Expand Down

0 comments on commit a004ff5

Please sign in to comment.