From b093060c2a122ff1433bbb46aa603b99be5ef8f9 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 1 Oct 2015 18:03:34 +0200 Subject: [PATCH] Stop re-exporting AttrStyle's variants and rename them. --- src/librustc/metadata/decoder.rs | 2 +- src/librustc_front/attr.rs | 4 ++-- src/librustc_lint/unused.rs | 8 ++++---- src/libsyntax/ast.rs | 11 +++++------ src/libsyntax/attr.rs | 6 +++--- src/libsyntax/ext/build.rs | 2 +- src/libsyntax/ext/expand.rs | 2 +- src/libsyntax/ext/quote.rs | 2 +- src/libsyntax/parse/attr.rs | 12 ++++++------ src/libsyntax/parse/lexer/comments.rs | 4 ++-- src/libsyntax/print/pprust.rs | 8 ++++---- src/libsyntax/std_inject.rs | 2 +- 12 files changed, 31 insertions(+), 32 deletions(-) diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index 77863ee3c87a2..0dec3d423caae 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -1115,7 +1115,7 @@ fn get_attributes(md: rbml::Doc) -> Vec { 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, }, diff --git a/src/librustc_front/attr.rs b/src/librustc_front/attr.rs index 7041f29cffff8..9e1e3c0e293ac 100644 --- a/src/librustc_front/attr.rs +++ b/src/librustc_front/attr.rs @@ -180,7 +180,7 @@ pub fn mk_attr_id() -> AttrId { pub fn mk_attr_inner(id: AttrId, item: P) -> Attribute { dummy_spanned(Attribute_ { id: id, - style: hir::AttrInner, + style: hir::AttrStyle::Inner, value: item, is_sugared_doc: false, }) @@ -190,7 +190,7 @@ pub fn mk_attr_inner(id: AttrId, item: P) -> Attribute { pub fn mk_attr_outer(id: AttrId, item: P) -> Attribute { dummy_spanned(Attribute_ { id: id, - style: hir::AttrOuter, + style: hir::AttrStyle::Outer, value: item, is_sugared_doc: false, }) diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index 920ecab7527d7..79249d08db838 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -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); } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 45e1d00586327..50b947febc3eb 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -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::*; @@ -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, @@ -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)), _) => { @@ -1658,8 +1657,8 @@ pub type Attribute = Spanned; /// 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)] diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 7540c2ff831e9..5fe4220bd99ba 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -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)) @@ -203,7 +203,7 @@ pub fn mk_attr_id() -> AttrId { pub fn mk_attr_inner(id: AttrId, item: P) -> Attribute { dummy_spanned(Attribute_ { id: id, - style: ast::AttrInner, + style: ast::AttrStyle::Inner, value: item, is_sugared_doc: false, }) @@ -213,7 +213,7 @@ pub fn mk_attr_inner(id: AttrId, item: P) -> Attribute { pub fn mk_attr_outer(id: AttrId, item: P) -> Attribute { dummy_spanned(Attribute_ { id: id, - style: ast::AttrOuter, + style: ast::AttrStyle::Outer, value: item, is_sugared_doc: false, }) diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 5b35b870c305a..a20080dcbf00a 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -1079,7 +1079,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { fn attribute(&self, sp: Span, mi: P) -> ast::Attribute { respan(sp, ast::Attribute_ { id: attr::mk_attr_id(), - style: ast::AttrOuter, + style: ast::AttrStyle::Outer, value: mi, is_sugared_doc: false, }) diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 6173630175a1b..b15c51490a188 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -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 ..."); } diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index e9a5d9148241d..e5fd15559ecff 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -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 { diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index 015cf60f0cfdb..219360093d146 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -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); @@ -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))); @@ -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 { @@ -131,7 +131,7 @@ 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) => { @@ -139,7 +139,7 @@ impl<'a> ParserAttr for Parser<'a> { 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 { diff --git a/src/libsyntax/parse/lexer/comments.rs b/src/libsyntax/parse/lexer/comments.rs index 9033208fbdbdc..137996a35ee8f 100644 --- a/src/libsyntax/parse/lexer/comments.rs +++ b/src/libsyntax/parse/lexer/comments.rs @@ -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 } } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 49b6dbed27e8c..405fd9b8cc745 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -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; } @@ -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; } @@ -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(), "]") diff --git a/src/libsyntax/std_inject.rs b/src/libsyntax/std_inject.rs index d6974abd394f9..345adff23443a 100644 --- a/src/libsyntax/std_inject.rs +++ b/src/libsyntax/std_inject.rs @@ -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()),