Skip to content

Commit a004ff5

Browse files
committed
Auto merge of #28793 - Ms2ger:AttrStyle, r=alexcrichton
2 parents 7643c4c + b093060 commit a004ff5

File tree

12 files changed

+31
-32
lines changed

12 files changed

+31
-32
lines changed

src/librustc/metadata/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,7 @@ fn get_attributes(md: rbml::Doc) -> Vec<ast::Attribute> {
11191119
codemap::Spanned {
11201120
node: ast::Attribute_ {
11211121
id: attr::mk_attr_id(),
1122-
style: ast::AttrOuter,
1122+
style: ast::AttrStyle::Outer,
11231123
value: meta_item,
11241124
is_sugared_doc: is_sugared_doc,
11251125
},

src/librustc_front/attr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ pub fn mk_attr_id() -> AttrId {
180180
pub fn mk_attr_inner(id: AttrId, item: P<MetaItem>) -> Attribute {
181181
dummy_spanned(Attribute_ {
182182
id: id,
183-
style: hir::AttrInner,
183+
style: hir::AttrStyle::Inner,
184184
value: item,
185185
is_sugared_doc: false,
186186
})
@@ -190,7 +190,7 @@ pub fn mk_attr_inner(id: AttrId, item: P<MetaItem>) -> Attribute {
190190
pub fn mk_attr_outer(id: AttrId, item: P<MetaItem>) -> Attribute {
191191
dummy_spanned(Attribute_ {
192192
id: id,
193-
style: hir::AttrOuter,
193+
style: hir::AttrStyle::Outer,
194194
value: item,
195195
is_sugared_doc: false,
196196
})

src/librustc_lint/unused.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,10 @@ impl LateLintPass for UnusedAttributes {
285285
}).is_some();
286286
if known_crate || plugin_crate {
287287
let msg = match attr.node.style {
288-
ast::AttrOuter => "crate-level attribute should be an inner \
289-
attribute: add an exclamation mark: #![foo]",
290-
ast::AttrInner => "crate-level attribute should be in the \
291-
root module",
288+
ast::AttrStyle::Outer => "crate-level attribute should be an inner \
289+
attribute: add an exclamation mark: #![foo]",
290+
ast::AttrStyle::Inner => "crate-level attribute should be in the \
291+
root module",
292292
};
293293
cx.span_lint(UNUSED_ATTRIBUTES, attr.span, msg);
294294
}

src/libsyntax/ast.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
// The Rust abstract syntax tree.
1212

13-
pub use self::AttrStyle::*;
1413
pub use self::BindingMode::*;
1514
pub use self::BinOp_::*;
1615
pub use self::BlockCheckMode::*;
@@ -1019,8 +1018,8 @@ impl TokenTree {
10191018
match *self {
10201019
TtToken(_, token::DocComment(name)) => {
10211020
match doc_comment_style(&name.as_str()) {
1022-
AttrOuter => 2,
1023-
AttrInner => 3
1021+
AttrStyle::Outer => 2,
1022+
AttrStyle::Inner => 3
10241023
}
10251024
}
10261025
TtToken(_, token::SpecialVarNt(..)) => 2,
@@ -1041,7 +1040,7 @@ impl TokenTree {
10411040
TtToken(sp, token::Pound)
10421041
}
10431042
(&TtToken(sp, token::DocComment(name)), 1)
1044-
if doc_comment_style(&name.as_str()) == AttrInner => {
1043+
if doc_comment_style(&name.as_str()) == AttrStyle::Inner => {
10451044
TtToken(sp, token::Not)
10461045
}
10471046
(&TtToken(sp, token::DocComment(name)), _) => {
@@ -1658,8 +1657,8 @@ pub type Attribute = Spanned<Attribute_>;
16581657
/// distinguished for pretty-printing.
16591658
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
16601659
pub enum AttrStyle {
1661-
AttrOuter,
1662-
AttrInner,
1660+
Outer,
1661+
Inner,
16631662
}
16641663

16651664
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]

src/libsyntax/attr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ impl AttributeMethods for Attribute {
156156
InternedString::new("doc"),
157157
token::intern_and_get_ident(&strip_doc_comment_decoration(
158158
&comment)));
159-
if self.node.style == ast::AttrOuter {
159+
if self.node.style == ast::AttrStyle::Outer {
160160
f(&mk_attr_outer(self.node.id, meta))
161161
} else {
162162
f(&mk_attr_inner(self.node.id, meta))
@@ -203,7 +203,7 @@ pub fn mk_attr_id() -> AttrId {
203203
pub fn mk_attr_inner(id: AttrId, item: P<MetaItem>) -> Attribute {
204204
dummy_spanned(Attribute_ {
205205
id: id,
206-
style: ast::AttrInner,
206+
style: ast::AttrStyle::Inner,
207207
value: item,
208208
is_sugared_doc: false,
209209
})
@@ -213,7 +213,7 @@ pub fn mk_attr_inner(id: AttrId, item: P<MetaItem>) -> Attribute {
213213
pub fn mk_attr_outer(id: AttrId, item: P<MetaItem>) -> Attribute {
214214
dummy_spanned(Attribute_ {
215215
id: id,
216-
style: ast::AttrOuter,
216+
style: ast::AttrStyle::Outer,
217217
value: item,
218218
is_sugared_doc: false,
219219
})

src/libsyntax/ext/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
10791079
fn attribute(&self, sp: Span, mi: P<ast::MetaItem>) -> ast::Attribute {
10801080
respan(sp, ast::Attribute_ {
10811081
id: attr::mk_attr_id(),
1082-
style: ast::AttrOuter,
1082+
style: ast::AttrStyle::Outer,
10831083
value: mi,
10841084
is_sugared_doc: false,
10851085
})

src/libsyntax/ext/expand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ fn contains_macro_use(fld: &mut MacroExpander, attrs: &[ast::Attribute]) -> bool
660660
if attr.check_name("macro_escape") {
661661
fld.cx.span_warn(attr.span, "macro_escape is a deprecated synonym for macro_use");
662662
is_use = true;
663-
if let ast::AttrInner = attr.node.style {
663+
if let ast::AttrStyle::Inner = attr.node.style {
664664
fld.cx.fileline_help(attr.span, "consider an outer attribute, \
665665
#[macro_use] mod ...");
666666
}

src/libsyntax/ext/quote.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ pub mod rt {
187187
let mut r = vec![];
188188
// FIXME: The spans could be better
189189
r.push(ast::TtToken(self.span, token::Pound));
190-
if self.node.style == ast::AttrInner {
190+
if self.node.style == ast::AttrStyle::Inner {
191191
r.push(ast::TtToken(self.span, token::Not));
192192
}
193193
r.push(ast::TtDelimited(self.span, Rc::new(ast::Delimited {

src/libsyntax/parse/attr.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl<'a> ParserAttr for Parser<'a> {
4444
self.span.lo,
4545
self.span.hi
4646
);
47-
if attr.node.style != ast::AttrOuter {
47+
if attr.node.style != ast::AttrStyle::Outer {
4848
panic!(self.fatal("expected outer comment"));
4949
}
5050
attrs.push(attr);
@@ -79,9 +79,9 @@ impl<'a> ParserAttr for Parser<'a> {
7979
self.fileline_help(span,
8080
"place inner attribute at the top of the module or block");
8181
}
82-
ast::AttrInner
82+
ast::AttrStyle::Inner
8383
} else {
84-
ast::AttrOuter
84+
ast::AttrStyle::Outer
8585
};
8686

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

107107
return Spanned {
@@ -131,15 +131,15 @@ impl<'a> ParserAttr for Parser<'a> {
131131
}
132132

133133
let attr = self.parse_attribute(true);
134-
assert!(attr.node.style == ast::AttrInner);
134+
assert!(attr.node.style == ast::AttrStyle::Inner);
135135
attrs.push(attr);
136136
}
137137
token::DocComment(s) => {
138138
// we need to get the position of this token before we bump.
139139
let Span { lo, hi, .. } = self.span;
140140
let str = self.id_to_interned_str(ast::Ident::with_empty_ctxt(s));
141141
let attr = attr::mk_sugared_doc_attr(attr::mk_attr_id(), str, lo, hi);
142-
if attr.node.style == ast::AttrInner {
142+
if attr.node.style == ast::AttrStyle::Inner {
143143
attrs.push(attr);
144144
panictry!(self.bump());
145145
} else {

src/libsyntax/parse/lexer/comments.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ pub fn is_doc_comment(s: &str) -> bool {
5252
pub fn doc_comment_style(comment: &str) -> ast::AttrStyle {
5353
assert!(is_doc_comment(comment));
5454
if comment.starts_with("//!") || comment.starts_with("/*!") {
55-
ast::AttrInner
55+
ast::AttrStyle::Inner
5656
} else {
57-
ast::AttrOuter
57+
ast::AttrStyle::Outer
5858
}
5959
}
6060

src/libsyntax/print/pprust.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ pub trait PrintState<'a> {
709709
let mut count = 0;
710710
for attr in attrs {
711711
match attr.node.style {
712-
ast::AttrInner => {
712+
ast::AttrStyle::Inner => {
713713
try!(self.print_attribute(attr));
714714
count += 1;
715715
}
@@ -727,7 +727,7 @@ pub trait PrintState<'a> {
727727
let mut count = 0;
728728
for attr in attrs {
729729
match attr.node.style {
730-
ast::AttrOuter => {
730+
ast::AttrStyle::Outer => {
731731
try!(self.print_attribute(attr));
732732
count += 1;
733733
}
@@ -747,8 +747,8 @@ pub trait PrintState<'a> {
747747
word(self.writer(), &attr.value_str().unwrap())
748748
} else {
749749
match attr.node.style {
750-
ast::AttrInner => try!(word(self.writer(), "#![")),
751-
ast::AttrOuter => try!(word(self.writer(), "#[")),
750+
ast::AttrStyle::Inner => try!(word(self.writer(), "#![")),
751+
ast::AttrStyle::Outer => try!(word(self.writer(), "#[")),
752752
}
753753
try!(self.print_meta_item(&*attr.meta()));
754754
word(self.writer(), "]")

src/libsyntax/std_inject.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl fold::Folder for PreludeInjector {
154154
span: self.span,
155155
node: ast::Attribute_ {
156156
id: attr::mk_attr_id(),
157-
style: ast::AttrOuter,
157+
style: ast::AttrStyle::Outer,
158158
value: P(ast::MetaItem {
159159
span: self.span,
160160
node: ast::MetaWord(special_idents::prelude_import.name.as_str()),

0 commit comments

Comments
 (0)