diff options
| author | Oliver 'ker' Schneider <git-spam-no-reply9815368754983@oli-obk.de> | 2016-02-09 12:05:20 +0100 |
|---|---|---|
| committer | Oliver Schneider <git-spam-no-reply9815368754983@oli-obk.de> | 2016-02-11 12:34:48 +0100 |
| commit | 14e09ad4686bb20a98acfd7d930386f6330d2b4d (patch) | |
| tree | f039e28bbba5283c4d7fbcf1aca8112e81f98a03 /src/libsyntax | |
| parent | e797e1961df00ec7725c47225dcf9b5a0e9fce64 (diff) | |
| download | rust-14e09ad4686bb20a98acfd7d930386f6330d2b4d.tar.gz rust-14e09ad4686bb20a98acfd7d930386f6330d2b4d.zip | |
[breaking-change] don't glob export ast::MetaItem_
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 30 | ||||
| -rw-r--r-- | src/libsyntax/attr.rs | 43 | ||||
| -rw-r--r-- | src/libsyntax/config.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/build.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/feature_gate.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/parse/attr.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/std_inject.rs | 2 |
10 files changed, 53 insertions, 54 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index b94c033e48a..a3a59b7898b 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -10,7 +10,6 @@ // The Rust abstract syntax tree. -pub use self::MetaItem_::*; pub use self::Mutability::*; pub use self::Pat_::*; pub use self::PathListItem_::*; @@ -476,31 +475,32 @@ pub struct Crate { pub exported_macros: Vec<MacroDef>, } -pub type MetaItem = Spanned<MetaItem_>; +pub type MetaItem = Spanned<MetaItemKind>; #[derive(Clone, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] -pub enum MetaItem_ { - MetaWord(InternedString), - MetaList(InternedString, Vec<P<MetaItem>>), - MetaNameValue(InternedString, Lit), +pub enum MetaItemKind { + Word(InternedString), + List(InternedString, Vec<P<MetaItem>>), + NameValue(InternedString, Lit), } -// can't be derived because the MetaList requires an unordered comparison -impl PartialEq for MetaItem_ { - fn eq(&self, other: &MetaItem_) -> bool { +// can't be derived because the MetaItemKind::List requires an unordered comparison +impl PartialEq for MetaItemKind { + fn eq(&self, other: &MetaItemKind) -> bool { + use self::MetaItemKind::*; match *self { - MetaWord(ref ns) => match *other { - MetaWord(ref no) => (*ns) == (*no), + Word(ref ns) => match *other { + Word(ref no) => (*ns) == (*no), _ => false }, - MetaNameValue(ref ns, ref vs) => match *other { - MetaNameValue(ref no, ref vo) => { + NameValue(ref ns, ref vs) => match *other { + NameValue(ref no, ref vo) => { (*ns) == (*no) && vs.node == vo.node } _ => false }, - MetaList(ref ns, ref miss) => match *other { - MetaList(ref no, ref miso) => { + List(ref ns, ref miss) => match *other { + List(ref no, ref miso) => { ns == no && miss.iter().all(|mi| miso.iter().any(|x| x.node == mi.node)) } diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index f9c41ee43dd..53ab4e1b6d5 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -15,7 +15,7 @@ pub use self::ReprAttr::*; pub use self::IntType::*; use ast; -use ast::{AttrId, Attribute, Attribute_, MetaItem, MetaWord, MetaNameValue, MetaList}; +use ast::{AttrId, Attribute, Attribute_, MetaItem, MetaItemKind}; use ast::{Stmt, StmtKind, DeclKind}; use ast::{Expr, Item, Local, Decl}; use codemap::{Span, Spanned, spanned, dummy_spanned}; @@ -66,7 +66,7 @@ pub trait AttrMetaMethods { /// `#[foo="bar"]` and `#[foo(bar)]` fn name(&self) -> InternedString; - /// Gets the string value if self is a MetaNameValue variant + /// Gets the string value if self is a MetaItemKind::NameValue variant /// containing a string, otherwise None. fn value_str(&self) -> Option<InternedString>; /// Gets a list of inner meta items from a list MetaItem type. @@ -96,15 +96,15 @@ impl AttrMetaMethods for Attribute { impl AttrMetaMethods for MetaItem { fn name(&self) -> InternedString { match self.node { - MetaWord(ref n) => (*n).clone(), - MetaNameValue(ref n, _) => (*n).clone(), - MetaList(ref n, _) => (*n).clone(), + MetaItemKind::Word(ref n) => (*n).clone(), + MetaItemKind::NameValue(ref n, _) => (*n).clone(), + MetaItemKind::List(ref n, _) => (*n).clone(), } } fn value_str(&self) -> Option<InternedString> { match self.node { - MetaNameValue(_, ref v) => { + MetaItemKind::NameValue(_, ref v) => { match v.node { ast::LitKind::Str(ref s, _) => Some((*s).clone()), _ => None, @@ -116,7 +116,7 @@ impl AttrMetaMethods for MetaItem { fn meta_item_list(&self) -> Option<&[P<MetaItem>]> { match self.node { - MetaList(_, ref l) => Some(&l[..]), + MetaItemKind::List(_, ref l) => Some(&l[..]), _ => None } } @@ -179,15 +179,15 @@ pub fn mk_name_value_item_str(name: InternedString, value: InternedString) pub fn mk_name_value_item(name: InternedString, value: ast::Lit) -> P<MetaItem> { - P(dummy_spanned(MetaNameValue(name, value))) + P(dummy_spanned(MetaItemKind::NameValue(name, value))) } pub fn mk_list_item(name: InternedString, items: Vec<P<MetaItem>>) -> P<MetaItem> { - P(dummy_spanned(MetaList(name, items))) + P(dummy_spanned(MetaItemKind::List(name, items))) } pub fn mk_word_item(name: InternedString) -> P<MetaItem> { - P(dummy_spanned(MetaWord(name))) + P(dummy_spanned(MetaItemKind::Word(name))) } thread_local! { static NEXT_ATTR_ID: Cell<usize> = Cell::new(0) } @@ -229,8 +229,7 @@ pub fn mk_sugared_doc_attr(id: AttrId, text: InternedString, lo: BytePos, let attr = Attribute_ { id: id, style: style, - value: P(spanned(lo, hi, MetaNameValue(InternedString::new("doc"), - lit))), + value: P(spanned(lo, hi, MetaItemKind::NameValue(InternedString::new("doc"), lit))), is_sugared_doc: true }; spanned(lo, hi, attr) @@ -286,7 +285,7 @@ pub fn sort_meta_items(items: Vec<P<MetaItem>>) -> Vec<P<MetaItem>> { v.into_iter().map(|(_, m)| m.map(|Spanned {node, span}| { Spanned { node: match node { - MetaList(n, mis) => MetaList(n, sort_meta_items(mis)), + MetaItemKind::List(n, mis) => MetaItemKind::List(n, sort_meta_items(mis)), _ => node }, span: span @@ -329,11 +328,11 @@ pub enum InlineAttr { pub fn find_inline_attr(diagnostic: Option<&Handler>, attrs: &[Attribute]) -> InlineAttr { attrs.iter().fold(InlineAttr::None, |ia,attr| { match attr.node.value.node { - MetaWord(ref n) if *n == "inline" => { + MetaItemKind::Word(ref n) if *n == "inline" => { mark_used(attr); InlineAttr::Hint } - MetaList(ref n, ref items) if *n == "inline" => { + MetaItemKind::List(ref n, ref items) if *n == "inline" => { mark_used(attr); if items.len() != 1 { diagnostic.map(|d|{ d.span_err(attr.span, "expected one argument"); }); @@ -365,11 +364,11 @@ pub fn cfg_matches<T: CfgDiag>(cfgs: &[P<MetaItem>], cfg: &ast::MetaItem, diag: &mut T) -> bool { match cfg.node { - ast::MetaList(ref pred, ref mis) if &pred[..] == "any" => + ast::MetaItemKind::List(ref pred, ref mis) if &pred[..] == "any" => mis.iter().any(|mi| cfg_matches(cfgs, &**mi, diag)), - ast::MetaList(ref pred, ref mis) if &pred[..] == "all" => + ast::MetaItemKind::List(ref pred, ref mis) if &pred[..] == "all" => mis.iter().all(|mi| cfg_matches(cfgs, &**mi, diag)), - ast::MetaList(ref pred, ref mis) if &pred[..] == "not" => { + ast::MetaItemKind::List(ref pred, ref mis) if &pred[..] == "not" => { if mis.len() != 1 { diag.emit_error(|diagnostic| { diagnostic.span_err(cfg.span, "expected 1 cfg-pattern"); @@ -378,14 +377,14 @@ pub fn cfg_matches<T: CfgDiag>(cfgs: &[P<MetaItem>], } !cfg_matches(cfgs, &*mis[0], diag) } - ast::MetaList(ref pred, _) => { + ast::MetaItemKind::List(ref pred, _) => { diag.emit_error(|diagnostic| { diagnostic.span_err(cfg.span, &format!("invalid predicate `{}`", pred)); }); false }, - ast::MetaWord(_) | ast::MetaNameValue(..) => { + ast::MetaItemKind::Word(_) | ast::MetaItemKind::NameValue(..) => { diag.flag_gated(|feature_gated_cfgs| { feature_gated_cfgs.extend( GatedCfg::gate(cfg).map(GatedCfgAttr::GatedCfg)); @@ -707,11 +706,11 @@ pub fn require_unique_names(diagnostic: &Handler, metas: &[P<MetaItem>]) { pub fn find_repr_attrs(diagnostic: &Handler, attr: &Attribute) -> Vec<ReprAttr> { let mut acc = Vec::new(); match attr.node.value.node { - ast::MetaList(ref s, ref items) if *s == "repr" => { + ast::MetaItemKind::List(ref s, ref items) if *s == "repr" => { mark_used(attr); for item in items { match item.node { - ast::MetaWord(ref word) => { + ast::MetaItemKind::Word(ref word) => { let hint = match &word[..] { // Can't use "extern" because it's not a lexical identifier. "C" => Some(ReprExtern), diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs index 57416bce3cb..09408f68dfd 100644 --- a/src/libsyntax/config.rs +++ b/src/libsyntax/config.rs @@ -270,7 +270,7 @@ fn in_cfg<T: CfgDiag>(cfg: &[P<ast::MetaItem>], diag: &mut T) -> bool { attrs.iter().all(|attr| { let mis = match attr.node.value.node { - ast::MetaList(_, ref mis) if is_cfg(&attr) => mis, + ast::MetaItemKind::List(_, ref mis) if is_cfg(&attr) => mis, _ => return true }; diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 256825eacf2..a807fbb93fb 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -1102,21 +1102,21 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } fn meta_word(&self, sp: Span, w: InternedString) -> P<ast::MetaItem> { - P(respan(sp, ast::MetaWord(w))) + P(respan(sp, ast::MetaItemKind::Word(w))) } fn meta_list(&self, sp: Span, name: InternedString, mis: Vec<P<ast::MetaItem>> ) -> P<ast::MetaItem> { - P(respan(sp, ast::MetaList(name, mis))) + P(respan(sp, ast::MetaItemKind::List(name, mis))) } fn meta_name_value(&self, sp: Span, name: InternedString, value: ast::LitKind) -> P<ast::MetaItem> { - P(respan(sp, ast::MetaNameValue(name, respan(sp, value)))) + P(respan(sp, ast::MetaItemKind::NameValue(name, respan(sp, value)))) } fn item_use(&self, sp: Span, diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 6b3e2501761..c53001e665e 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -348,7 +348,7 @@ fn contains_macro_use(fld: &mut MacroExpander, attrs: &[ast::Attribute]) -> bool if is_use { match attr.node.value.node { - ast::MetaWord(..) => (), + ast::MetaItemKind::Word(..) => (), _ => fld.cx.span_err(attr.span, "arguments to macro_use are not allowed here"), } return true; diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 6dc0da1eb09..b04f6b06639 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -1138,7 +1138,7 @@ fn check_crate_inner<F>(cm: &CodeMap, span_handler: &Handler, Some(list) => { for mi in list { let name = match mi.node { - ast::MetaWord(ref word) => (*word).clone(), + ast::MetaItemKind::Word(ref word) => (*word).clone(), _ => { span_handler.span_err(mi.span, "malformed feature, expected just \ diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 8bb915362e8..722a65fa526 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -556,11 +556,11 @@ pub fn noop_fold_mac<T: Folder>(Spanned {node, span}: Mac, fld: &mut T) -> Mac { pub fn noop_fold_meta_item<T: Folder>(mi: P<MetaItem>, fld: &mut T) -> P<MetaItem> { mi.map(|Spanned {node, span}| Spanned { node: match node { - MetaWord(id) => MetaWord(id), - MetaList(id, mis) => { - MetaList(id, mis.move_map(|e| fld.fold_meta_item(e))) + MetaItemKind::Word(id) => MetaItemKind::Word(id), + MetaItemKind::List(id, mis) => { + MetaItemKind::List(id, mis.move_map(|e| fld.fold_meta_item(e))) } - MetaNameValue(id, s) => MetaNameValue(id, s) + MetaItemKind::NameValue(id, s) => MetaItemKind::NameValue(id, s) }, span: fld.new_span(span) }) diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index 3f9f2ae44a3..505e543a3fb 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -182,16 +182,16 @@ impl<'a> Parser<'a> { } } let hi = self.span.hi; - Ok(P(spanned(lo, hi, ast::MetaNameValue(name, lit)))) + Ok(P(spanned(lo, hi, ast::MetaItemKind::NameValue(name, lit)))) } token::OpenDelim(token::Paren) => { let inner_items = try!(self.parse_meta_seq()); let hi = self.span.hi; - Ok(P(spanned(lo, hi, ast::MetaList(name, inner_items)))) + Ok(P(spanned(lo, hi, ast::MetaItemKind::List(name, inner_items)))) } _ => { let hi = self.last_span.hi; - Ok(P(spanned(lo, hi, ast::MetaWord(name)))) + Ok(P(spanned(lo, hi, ast::MetaItemKind::Word(name)))) } } } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 2c2414e54ea..8495853c2c9 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -766,15 +766,15 @@ pub trait PrintState<'a> { fn print_meta_item(&mut self, item: &ast::MetaItem) -> io::Result<()> { try!(self.ibox(INDENT_UNIT)); match item.node { - ast::MetaWord(ref name) => { + ast::MetaItemKind::Word(ref name) => { try!(word(self.writer(), &name)); } - ast::MetaNameValue(ref name, ref value) => { + ast::MetaItemKind::NameValue(ref name, ref value) => { try!(self.word_space(&name[..])); try!(self.word_space("=")); try!(self.print_literal(value)); } - ast::MetaList(ref name, ref items) => { + ast::MetaItemKind::List(ref name, ref items) => { try!(word(self.writer(), &name)); try!(self.popen()); try!(self.commasep(Consistent, diff --git a/src/libsyntax/std_inject.rs b/src/libsyntax/std_inject.rs index 828896d422c..996a2ee006e 100644 --- a/src/libsyntax/std_inject.rs +++ b/src/libsyntax/std_inject.rs @@ -157,7 +157,7 @@ impl fold::Folder for PreludeInjector { style: ast::AttrStyle::Outer, value: P(ast::MetaItem { span: self.span, - node: ast::MetaWord(special_idents::prelude_import.name.as_str()), + node: ast::MetaItemKind::Word(special_idents::prelude_import.name.as_str()), }), is_sugared_doc: false, }, |
