[breaking-change] don't glob export ast::MetaItem_
This commit is contained in:
parent
e797e1961d
commit
14e09ad468
22 changed files with 83 additions and 84 deletions
|
@ -374,7 +374,7 @@ pub fn gather_attr(attr: &ast::Attribute)
|
||||||
|
|
||||||
let meta = &attr.node.value;
|
let meta = &attr.node.value;
|
||||||
let metas = match meta.node {
|
let metas = match meta.node {
|
||||||
ast::MetaList(_, ref metas) => metas,
|
ast::MetaItemKind::List(_, ref metas) => metas,
|
||||||
_ => {
|
_ => {
|
||||||
out.push(Err(meta.span));
|
out.push(Err(meta.span));
|
||||||
return out;
|
return out;
|
||||||
|
@ -383,7 +383,7 @@ pub fn gather_attr(attr: &ast::Attribute)
|
||||||
|
|
||||||
for meta in metas {
|
for meta in metas {
|
||||||
out.push(match meta.node {
|
out.push(match meta.node {
|
||||||
ast::MetaWord(ref lint_name) => Ok((lint_name.clone(), level, meta.span)),
|
ast::MetaItemKind::Word(ref lint_name) => Ok((lint_name.clone(), level, meta.span)),
|
||||||
_ => Err(meta.span),
|
_ => Err(meta.span),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -560,18 +560,18 @@ impl RustcDefaultCalls {
|
||||||
PrintRequest::Cfg => {
|
PrintRequest::Cfg => {
|
||||||
for cfg in config::build_configuration(sess) {
|
for cfg in config::build_configuration(sess) {
|
||||||
match cfg.node {
|
match cfg.node {
|
||||||
ast::MetaWord(ref word) => println!("{}", word),
|
ast::MetaItemKind::Word(ref word) => println!("{}", word),
|
||||||
ast::MetaNameValue(ref name, ref value) => {
|
ast::MetaItemKind::NameValue(ref name, ref value) => {
|
||||||
println!("{}=\"{}\"", name, match value.node {
|
println!("{}=\"{}\"", name, match value.node {
|
||||||
ast::LitKind::Str(ref s, _) => s,
|
ast::LitKind::Str(ref s, _) => s,
|
||||||
_ => continue,
|
_ => continue,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Right now there are not and should not be any
|
// Right now there are not and should not be any
|
||||||
// MetaList items in the configuration returned by
|
// MetaItemKind::List items in the configuration returned by
|
||||||
// `build_configuration`.
|
// `build_configuration`.
|
||||||
ast::MetaList(..) => {
|
ast::MetaItemKind::List(..) => {
|
||||||
panic!("MetaList encountered in default cfg")
|
panic!("MetaItemKind::List encountered in default cfg")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
use hir::*;
|
use hir::*;
|
||||||
use syntax::ast::{Name, NodeId, DUMMY_NODE_ID, Attribute, Attribute_, MetaItem};
|
use syntax::ast::{Name, NodeId, DUMMY_NODE_ID, Attribute, Attribute_, MetaItem};
|
||||||
use syntax::ast::{MetaWord, MetaList, MetaNameValue};
|
use syntax::ast::MetaItemKind;
|
||||||
use syntax::attr::ThinAttributesExt;
|
use syntax::attr::ThinAttributesExt;
|
||||||
use hir;
|
use hir;
|
||||||
use syntax::codemap::{respan, Span, Spanned};
|
use syntax::codemap::{respan, Span, Spanned};
|
||||||
|
@ -522,11 +522,11 @@ pub fn noop_fold_meta_item<T: Folder>(mi: P<MetaItem>, fld: &mut T) -> P<MetaIte
|
||||||
mi.map(|Spanned { node, span }| {
|
mi.map(|Spanned { node, span }| {
|
||||||
Spanned {
|
Spanned {
|
||||||
node: match node {
|
node: match node {
|
||||||
MetaWord(id) => MetaWord(id),
|
MetaItemKind::Word(id) => MetaItemKind::Word(id),
|
||||||
MetaList(id, mis) => {
|
MetaItemKind::List(id, mis) => {
|
||||||
MetaList(id, mis.move_map(|e| fld.fold_meta_item(e)))
|
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),
|
span: fld.new_span(span),
|
||||||
}
|
}
|
||||||
|
|
|
@ -308,7 +308,7 @@ impl MissingDoc {
|
||||||
|
|
||||||
let has_doc = attrs.iter().any(|a| {
|
let has_doc = attrs.iter().any(|a| {
|
||||||
match a.node.value.node {
|
match a.node.value.node {
|
||||||
ast::MetaNameValue(ref name, _) if *name == "doc" => true,
|
ast::MetaItemKind::NameValue(ref name, _) if *name == "doc" => true,
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1170,7 +1170,7 @@ fn get_meta_items(md: rbml::Doc) -> Vec<P<ast::MetaItem>> {
|
||||||
let vd = reader::get_doc(meta_item_doc, tag_meta_item_value);
|
let vd = reader::get_doc(meta_item_doc, tag_meta_item_value);
|
||||||
let n = token::intern_and_get_ident(nd.as_str_slice());
|
let n = token::intern_and_get_ident(nd.as_str_slice());
|
||||||
let v = token::intern_and_get_ident(vd.as_str_slice());
|
let v = token::intern_and_get_ident(vd.as_str_slice());
|
||||||
// FIXME (#623): Should be able to decode MetaNameValue variants,
|
// FIXME (#623): Should be able to decode MetaItemKind::NameValue variants,
|
||||||
// but currently the encoder just drops them
|
// but currently the encoder just drops them
|
||||||
attr::mk_name_value_item_str(n, v)
|
attr::mk_name_value_item_str(n, v)
|
||||||
})).chain(reader::tagged_docs(md, tag_meta_item_list).map(|meta_item_doc| {
|
})).chain(reader::tagged_docs(md, tag_meta_item_list).map(|meta_item_doc| {
|
||||||
|
|
|
@ -1541,12 +1541,12 @@ fn encode_item_index(rbml_w: &mut Encoder, index: IndexData) {
|
||||||
|
|
||||||
fn encode_meta_item(rbml_w: &mut Encoder, mi: &ast::MetaItem) {
|
fn encode_meta_item(rbml_w: &mut Encoder, mi: &ast::MetaItem) {
|
||||||
match mi.node {
|
match mi.node {
|
||||||
ast::MetaWord(ref name) => {
|
ast::MetaItemKind::Word(ref name) => {
|
||||||
rbml_w.start_tag(tag_meta_item_word);
|
rbml_w.start_tag(tag_meta_item_word);
|
||||||
rbml_w.wr_tagged_str(tag_meta_item_name, name);
|
rbml_w.wr_tagged_str(tag_meta_item_name, name);
|
||||||
rbml_w.end_tag();
|
rbml_w.end_tag();
|
||||||
}
|
}
|
||||||
ast::MetaNameValue(ref name, ref value) => {
|
ast::MetaItemKind::NameValue(ref name, ref value) => {
|
||||||
match value.node {
|
match value.node {
|
||||||
ast::LitKind::Str(ref value, _) => {
|
ast::LitKind::Str(ref value, _) => {
|
||||||
rbml_w.start_tag(tag_meta_item_name_value);
|
rbml_w.start_tag(tag_meta_item_name_value);
|
||||||
|
@ -1557,7 +1557,7 @@ fn encode_meta_item(rbml_w: &mut Encoder, mi: &ast::MetaItem) {
|
||||||
_ => {/* FIXME (#623): encode other variants */ }
|
_ => {/* FIXME (#623): encode other variants */ }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast::MetaList(ref name, ref items) => {
|
ast::MetaItemKind::List(ref name, ref items) => {
|
||||||
rbml_w.start_tag(tag_meta_item_list);
|
rbml_w.start_tag(tag_meta_item_list);
|
||||||
rbml_w.wr_tagged_str(tag_meta_item_name, name);
|
rbml_w.wr_tagged_str(tag_meta_item_name, name);
|
||||||
for inner_item in items {
|
for inner_item in items {
|
||||||
|
|
|
@ -95,7 +95,7 @@ impl<'a, 'v> Visitor<'v> for MacroLoader<'a> {
|
||||||
}
|
}
|
||||||
if let (Some(sel), Some(names)) = (import.as_mut(), names) {
|
if let (Some(sel), Some(names)) = (import.as_mut(), names) {
|
||||||
for attr in names {
|
for attr in names {
|
||||||
if let ast::MetaWord(ref name) = attr.node {
|
if let ast::MetaItemKind::Word(ref name) = attr.node {
|
||||||
sel.insert(name.clone(), attr.span);
|
sel.insert(name.clone(), attr.span);
|
||||||
} else {
|
} else {
|
||||||
span_err!(self.sess, attr.span, E0466, "bad macro import");
|
span_err!(self.sess, attr.span, E0466, "bad macro import");
|
||||||
|
@ -113,7 +113,7 @@ impl<'a, 'v> Visitor<'v> for MacroLoader<'a> {
|
||||||
};
|
};
|
||||||
|
|
||||||
for attr in names {
|
for attr in names {
|
||||||
if let ast::MetaWord(ref name) = attr.node {
|
if let ast::MetaItemKind::Word(ref name) = attr.node {
|
||||||
reexport.insert(name.clone(), attr.span);
|
reexport.insert(name.clone(), attr.span);
|
||||||
} else {
|
} else {
|
||||||
call_bad_macro_reexport(self.sess, attr.span);
|
call_bad_macro_reexport(self.sess, attr.span);
|
||||||
|
|
|
@ -96,7 +96,7 @@ impl<'a, 'tcx> IfThisChanged<'a, 'tcx> {
|
||||||
let mut id = None;
|
let mut id = None;
|
||||||
for meta_item in attr.meta_item_list().unwrap_or_default() {
|
for meta_item in attr.meta_item_list().unwrap_or_default() {
|
||||||
match meta_item.node {
|
match meta_item.node {
|
||||||
ast::MetaWord(ref s) if id.is_none() => id = Some(s.clone()),
|
ast::MetaItemKind::Word(ref s) if id.is_none() => id = Some(s.clone()),
|
||||||
_ => {
|
_ => {
|
||||||
self.tcx.sess.span_err(
|
self.tcx.sess.span_err(
|
||||||
meta_item.span,
|
meta_item.span,
|
||||||
|
@ -113,9 +113,9 @@ impl<'a, 'tcx> IfThisChanged<'a, 'tcx> {
|
||||||
let mut id = None;
|
let mut id = None;
|
||||||
for meta_item in attr.meta_item_list().unwrap_or_default() {
|
for meta_item in attr.meta_item_list().unwrap_or_default() {
|
||||||
match meta_item.node {
|
match meta_item.node {
|
||||||
ast::MetaWord(ref s) if dep_node_interned.is_none() =>
|
ast::MetaItemKind::Word(ref s) if dep_node_interned.is_none() =>
|
||||||
dep_node_interned = Some(s.clone()),
|
dep_node_interned = Some(s.clone()),
|
||||||
ast::MetaWord(ref s) if id.is_none() =>
|
ast::MetaItemKind::Word(ref s) if id.is_none() =>
|
||||||
id = Some(s.clone()),
|
id = Some(s.clone()),
|
||||||
_ => {
|
_ => {
|
||||||
self.tcx.sess.span_err(
|
self.tcx.sess.span_err(
|
||||||
|
|
|
@ -48,7 +48,7 @@ pub fn contains_nodebug_attribute(attributes: &[ast::Attribute]) -> bool {
|
||||||
attributes.iter().any(|attr| {
|
attributes.iter().any(|attr| {
|
||||||
let meta_item: &ast::MetaItem = &*attr.node.value;
|
let meta_item: &ast::MetaItem = &*attr.node.value;
|
||||||
match meta_item.node {
|
match meta_item.node {
|
||||||
ast::MetaWord(ref value) => &value[..] == "no_debug",
|
ast::MetaItemKind::Word(ref value) => &value[..] == "no_debug",
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -451,11 +451,11 @@ pub enum Attribute {
|
||||||
impl Clean<Attribute> for ast::MetaItem {
|
impl Clean<Attribute> for ast::MetaItem {
|
||||||
fn clean(&self, cx: &DocContext) -> Attribute {
|
fn clean(&self, cx: &DocContext) -> Attribute {
|
||||||
match self.node {
|
match self.node {
|
||||||
ast::MetaWord(ref s) => Word(s.to_string()),
|
ast::MetaItemKind::Word(ref s) => Word(s.to_string()),
|
||||||
ast::MetaList(ref s, ref l) => {
|
ast::MetaItemKind::List(ref s, ref l) => {
|
||||||
List(s.to_string(), l.clean(cx))
|
List(s.to_string(), l.clean(cx))
|
||||||
}
|
}
|
||||||
ast::MetaNameValue(ref s, ref v) => {
|
ast::MetaItemKind::NameValue(ref s, ref v) => {
|
||||||
NameValue(s.to_string(), lit_to_string(v))
|
NameValue(s.to_string(), lit_to_string(v))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
// The Rust abstract syntax tree.
|
// The Rust abstract syntax tree.
|
||||||
|
|
||||||
pub use self::MetaItem_::*;
|
|
||||||
pub use self::Mutability::*;
|
pub use self::Mutability::*;
|
||||||
pub use self::Pat_::*;
|
pub use self::Pat_::*;
|
||||||
pub use self::PathListItem_::*;
|
pub use self::PathListItem_::*;
|
||||||
|
@ -476,31 +475,32 @@ pub struct Crate {
|
||||||
pub exported_macros: Vec<MacroDef>,
|
pub exported_macros: Vec<MacroDef>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type MetaItem = Spanned<MetaItem_>;
|
pub type MetaItem = Spanned<MetaItemKind>;
|
||||||
|
|
||||||
#[derive(Clone, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
#[derive(Clone, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||||
pub enum MetaItem_ {
|
pub enum MetaItemKind {
|
||||||
MetaWord(InternedString),
|
Word(InternedString),
|
||||||
MetaList(InternedString, Vec<P<MetaItem>>),
|
List(InternedString, Vec<P<MetaItem>>),
|
||||||
MetaNameValue(InternedString, Lit),
|
NameValue(InternedString, Lit),
|
||||||
}
|
}
|
||||||
|
|
||||||
// can't be derived because the MetaList requires an unordered comparison
|
// can't be derived because the MetaItemKind::List requires an unordered comparison
|
||||||
impl PartialEq for MetaItem_ {
|
impl PartialEq for MetaItemKind {
|
||||||
fn eq(&self, other: &MetaItem_) -> bool {
|
fn eq(&self, other: &MetaItemKind) -> bool {
|
||||||
|
use self::MetaItemKind::*;
|
||||||
match *self {
|
match *self {
|
||||||
MetaWord(ref ns) => match *other {
|
Word(ref ns) => match *other {
|
||||||
MetaWord(ref no) => (*ns) == (*no),
|
Word(ref no) => (*ns) == (*no),
|
||||||
_ => false
|
_ => false
|
||||||
},
|
},
|
||||||
MetaNameValue(ref ns, ref vs) => match *other {
|
NameValue(ref ns, ref vs) => match *other {
|
||||||
MetaNameValue(ref no, ref vo) => {
|
NameValue(ref no, ref vo) => {
|
||||||
(*ns) == (*no) && vs.node == vo.node
|
(*ns) == (*no) && vs.node == vo.node
|
||||||
}
|
}
|
||||||
_ => false
|
_ => false
|
||||||
},
|
},
|
||||||
MetaList(ref ns, ref miss) => match *other {
|
List(ref ns, ref miss) => match *other {
|
||||||
MetaList(ref no, ref miso) => {
|
List(ref no, ref miso) => {
|
||||||
ns == no &&
|
ns == no &&
|
||||||
miss.iter().all(|mi| miso.iter().any(|x| x.node == mi.node))
|
miss.iter().all(|mi| miso.iter().any(|x| x.node == mi.node))
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ pub use self::ReprAttr::*;
|
||||||
pub use self::IntType::*;
|
pub use self::IntType::*;
|
||||||
|
|
||||||
use ast;
|
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::{Stmt, StmtKind, DeclKind};
|
||||||
use ast::{Expr, Item, Local, Decl};
|
use ast::{Expr, Item, Local, Decl};
|
||||||
use codemap::{Span, Spanned, spanned, dummy_spanned};
|
use codemap::{Span, Spanned, spanned, dummy_spanned};
|
||||||
|
@ -66,7 +66,7 @@ pub trait AttrMetaMethods {
|
||||||
/// `#[foo="bar"]` and `#[foo(bar)]`
|
/// `#[foo="bar"]` and `#[foo(bar)]`
|
||||||
fn name(&self) -> InternedString;
|
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.
|
/// containing a string, otherwise None.
|
||||||
fn value_str(&self) -> Option<InternedString>;
|
fn value_str(&self) -> Option<InternedString>;
|
||||||
/// Gets a list of inner meta items from a list MetaItem type.
|
/// Gets a list of inner meta items from a list MetaItem type.
|
||||||
|
@ -96,15 +96,15 @@ impl AttrMetaMethods for Attribute {
|
||||||
impl AttrMetaMethods for MetaItem {
|
impl AttrMetaMethods for MetaItem {
|
||||||
fn name(&self) -> InternedString {
|
fn name(&self) -> InternedString {
|
||||||
match self.node {
|
match self.node {
|
||||||
MetaWord(ref n) => (*n).clone(),
|
MetaItemKind::Word(ref n) => (*n).clone(),
|
||||||
MetaNameValue(ref n, _) => (*n).clone(),
|
MetaItemKind::NameValue(ref n, _) => (*n).clone(),
|
||||||
MetaList(ref n, _) => (*n).clone(),
|
MetaItemKind::List(ref n, _) => (*n).clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn value_str(&self) -> Option<InternedString> {
|
fn value_str(&self) -> Option<InternedString> {
|
||||||
match self.node {
|
match self.node {
|
||||||
MetaNameValue(_, ref v) => {
|
MetaItemKind::NameValue(_, ref v) => {
|
||||||
match v.node {
|
match v.node {
|
||||||
ast::LitKind::Str(ref s, _) => Some((*s).clone()),
|
ast::LitKind::Str(ref s, _) => Some((*s).clone()),
|
||||||
_ => None,
|
_ => None,
|
||||||
|
@ -116,7 +116,7 @@ impl AttrMetaMethods for MetaItem {
|
||||||
|
|
||||||
fn meta_item_list(&self) -> Option<&[P<MetaItem>]> {
|
fn meta_item_list(&self) -> Option<&[P<MetaItem>]> {
|
||||||
match self.node {
|
match self.node {
|
||||||
MetaList(_, ref l) => Some(&l[..]),
|
MetaItemKind::List(_, ref l) => Some(&l[..]),
|
||||||
_ => None
|
_ => 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)
|
pub fn mk_name_value_item(name: InternedString, value: ast::Lit)
|
||||||
-> P<MetaItem> {
|
-> 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> {
|
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> {
|
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) }
|
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_ {
|
let attr = Attribute_ {
|
||||||
id: id,
|
id: id,
|
||||||
style: style,
|
style: style,
|
||||||
value: P(spanned(lo, hi, MetaNameValue(InternedString::new("doc"),
|
value: P(spanned(lo, hi, MetaItemKind::NameValue(InternedString::new("doc"), lit))),
|
||||||
lit))),
|
|
||||||
is_sugared_doc: true
|
is_sugared_doc: true
|
||||||
};
|
};
|
||||||
spanned(lo, hi, attr)
|
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}| {
|
v.into_iter().map(|(_, m)| m.map(|Spanned {node, span}| {
|
||||||
Spanned {
|
Spanned {
|
||||||
node: match node {
|
node: match node {
|
||||||
MetaList(n, mis) => MetaList(n, sort_meta_items(mis)),
|
MetaItemKind::List(n, mis) => MetaItemKind::List(n, sort_meta_items(mis)),
|
||||||
_ => node
|
_ => node
|
||||||
},
|
},
|
||||||
span: span
|
span: span
|
||||||
|
@ -329,11 +328,11 @@ pub enum InlineAttr {
|
||||||
pub fn find_inline_attr(diagnostic: Option<&Handler>, attrs: &[Attribute]) -> InlineAttr {
|
pub fn find_inline_attr(diagnostic: Option<&Handler>, attrs: &[Attribute]) -> InlineAttr {
|
||||||
attrs.iter().fold(InlineAttr::None, |ia,attr| {
|
attrs.iter().fold(InlineAttr::None, |ia,attr| {
|
||||||
match attr.node.value.node {
|
match attr.node.value.node {
|
||||||
MetaWord(ref n) if *n == "inline" => {
|
MetaItemKind::Word(ref n) if *n == "inline" => {
|
||||||
mark_used(attr);
|
mark_used(attr);
|
||||||
InlineAttr::Hint
|
InlineAttr::Hint
|
||||||
}
|
}
|
||||||
MetaList(ref n, ref items) if *n == "inline" => {
|
MetaItemKind::List(ref n, ref items) if *n == "inline" => {
|
||||||
mark_used(attr);
|
mark_used(attr);
|
||||||
if items.len() != 1 {
|
if items.len() != 1 {
|
||||||
diagnostic.map(|d|{ d.span_err(attr.span, "expected one argument"); });
|
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,
|
cfg: &ast::MetaItem,
|
||||||
diag: &mut T) -> bool {
|
diag: &mut T) -> bool {
|
||||||
match cfg.node {
|
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)),
|
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)),
|
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 {
|
if mis.len() != 1 {
|
||||||
diag.emit_error(|diagnostic| {
|
diag.emit_error(|diagnostic| {
|
||||||
diagnostic.span_err(cfg.span, "expected 1 cfg-pattern");
|
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)
|
!cfg_matches(cfgs, &*mis[0], diag)
|
||||||
}
|
}
|
||||||
ast::MetaList(ref pred, _) => {
|
ast::MetaItemKind::List(ref pred, _) => {
|
||||||
diag.emit_error(|diagnostic| {
|
diag.emit_error(|diagnostic| {
|
||||||
diagnostic.span_err(cfg.span,
|
diagnostic.span_err(cfg.span,
|
||||||
&format!("invalid predicate `{}`", pred));
|
&format!("invalid predicate `{}`", pred));
|
||||||
});
|
});
|
||||||
false
|
false
|
||||||
},
|
},
|
||||||
ast::MetaWord(_) | ast::MetaNameValue(..) => {
|
ast::MetaItemKind::Word(_) | ast::MetaItemKind::NameValue(..) => {
|
||||||
diag.flag_gated(|feature_gated_cfgs| {
|
diag.flag_gated(|feature_gated_cfgs| {
|
||||||
feature_gated_cfgs.extend(
|
feature_gated_cfgs.extend(
|
||||||
GatedCfg::gate(cfg).map(GatedCfgAttr::GatedCfg));
|
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> {
|
pub fn find_repr_attrs(diagnostic: &Handler, attr: &Attribute) -> Vec<ReprAttr> {
|
||||||
let mut acc = Vec::new();
|
let mut acc = Vec::new();
|
||||||
match attr.node.value.node {
|
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);
|
mark_used(attr);
|
||||||
for item in items {
|
for item in items {
|
||||||
match item.node {
|
match item.node {
|
||||||
ast::MetaWord(ref word) => {
|
ast::MetaItemKind::Word(ref word) => {
|
||||||
let hint = match &word[..] {
|
let hint = match &word[..] {
|
||||||
// Can't use "extern" because it's not a lexical identifier.
|
// Can't use "extern" because it's not a lexical identifier.
|
||||||
"C" => Some(ReprExtern),
|
"C" => Some(ReprExtern),
|
||||||
|
|
|
@ -270,7 +270,7 @@ fn in_cfg<T: CfgDiag>(cfg: &[P<ast::MetaItem>],
|
||||||
diag: &mut T) -> bool {
|
diag: &mut T) -> bool {
|
||||||
attrs.iter().all(|attr| {
|
attrs.iter().all(|attr| {
|
||||||
let mis = match attr.node.value.node {
|
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
|
_ => return true
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1102,21 +1102,21 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn meta_word(&self, sp: Span, w: InternedString) -> P<ast::MetaItem> {
|
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,
|
fn meta_list(&self,
|
||||||
sp: Span,
|
sp: Span,
|
||||||
name: InternedString,
|
name: InternedString,
|
||||||
mis: Vec<P<ast::MetaItem>> )
|
mis: Vec<P<ast::MetaItem>> )
|
||||||
-> 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,
|
fn meta_name_value(&self,
|
||||||
sp: Span,
|
sp: Span,
|
||||||
name: InternedString,
|
name: InternedString,
|
||||||
value: ast::LitKind)
|
value: ast::LitKind)
|
||||||
-> P<ast::MetaItem> {
|
-> 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,
|
fn item_use(&self, sp: Span,
|
||||||
|
|
|
@ -348,7 +348,7 @@ fn contains_macro_use(fld: &mut MacroExpander, attrs: &[ast::Attribute]) -> bool
|
||||||
|
|
||||||
if is_use {
|
if is_use {
|
||||||
match attr.node.value.node {
|
match attr.node.value.node {
|
||||||
ast::MetaWord(..) => (),
|
ast::MetaItemKind::Word(..) => (),
|
||||||
_ => fld.cx.span_err(attr.span, "arguments to macro_use are not allowed here"),
|
_ => fld.cx.span_err(attr.span, "arguments to macro_use are not allowed here"),
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1138,7 +1138,7 @@ fn check_crate_inner<F>(cm: &CodeMap, span_handler: &Handler,
|
||||||
Some(list) => {
|
Some(list) => {
|
||||||
for mi in list {
|
for mi in list {
|
||||||
let name = match mi.node {
|
let name = match mi.node {
|
||||||
ast::MetaWord(ref word) => (*word).clone(),
|
ast::MetaItemKind::Word(ref word) => (*word).clone(),
|
||||||
_ => {
|
_ => {
|
||||||
span_handler.span_err(mi.span,
|
span_handler.span_err(mi.span,
|
||||||
"malformed feature, expected just \
|
"malformed feature, expected just \
|
||||||
|
|
|
@ -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> {
|
pub fn noop_fold_meta_item<T: Folder>(mi: P<MetaItem>, fld: &mut T) -> P<MetaItem> {
|
||||||
mi.map(|Spanned {node, span}| Spanned {
|
mi.map(|Spanned {node, span}| Spanned {
|
||||||
node: match node {
|
node: match node {
|
||||||
MetaWord(id) => MetaWord(id),
|
MetaItemKind::Word(id) => MetaItemKind::Word(id),
|
||||||
MetaList(id, mis) => {
|
MetaItemKind::List(id, mis) => {
|
||||||
MetaList(id, mis.move_map(|e| fld.fold_meta_item(e)))
|
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)
|
span: fld.new_span(span)
|
||||||
})
|
})
|
||||||
|
|
|
@ -182,16 +182,16 @@ impl<'a> Parser<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let hi = self.span.hi;
|
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) => {
|
token::OpenDelim(token::Paren) => {
|
||||||
let inner_items = try!(self.parse_meta_seq());
|
let inner_items = try!(self.parse_meta_seq());
|
||||||
let hi = self.span.hi;
|
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;
|
let hi = self.last_span.hi;
|
||||||
Ok(P(spanned(lo, hi, ast::MetaWord(name))))
|
Ok(P(spanned(lo, hi, ast::MetaItemKind::Word(name))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -766,15 +766,15 @@ pub trait PrintState<'a> {
|
||||||
fn print_meta_item(&mut self, item: &ast::MetaItem) -> io::Result<()> {
|
fn print_meta_item(&mut self, item: &ast::MetaItem) -> io::Result<()> {
|
||||||
try!(self.ibox(INDENT_UNIT));
|
try!(self.ibox(INDENT_UNIT));
|
||||||
match item.node {
|
match item.node {
|
||||||
ast::MetaWord(ref name) => {
|
ast::MetaItemKind::Word(ref name) => {
|
||||||
try!(word(self.writer(), &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(&name[..]));
|
||||||
try!(self.word_space("="));
|
try!(self.word_space("="));
|
||||||
try!(self.print_literal(value));
|
try!(self.print_literal(value));
|
||||||
}
|
}
|
||||||
ast::MetaList(ref name, ref items) => {
|
ast::MetaItemKind::List(ref name, ref items) => {
|
||||||
try!(word(self.writer(), &name));
|
try!(word(self.writer(), &name));
|
||||||
try!(self.popen());
|
try!(self.popen());
|
||||||
try!(self.commasep(Consistent,
|
try!(self.commasep(Consistent,
|
||||||
|
|
|
@ -157,7 +157,7 @@ impl fold::Folder for PreludeInjector {
|
||||||
style: ast::AttrStyle::Outer,
|
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::MetaItemKind::Word(special_idents::prelude_import.name.as_str()),
|
||||||
}),
|
}),
|
||||||
is_sugared_doc: false,
|
is_sugared_doc: false,
|
||||||
},
|
},
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
//! FIXME (#2810): hygiene. Search for "__" strings (in other files too). We also assume "extra" is
|
//! FIXME (#2810): hygiene. Search for "__" strings (in other files too). We also assume "extra" is
|
||||||
//! the standard library, and "std" is the core library.
|
//! the standard library, and "std" is the core library.
|
||||||
|
|
||||||
use syntax::ast::{MetaItem, MetaWord};
|
use syntax::ast::{MetaItem, MetaItemKind};
|
||||||
use syntax::attr::AttrMetaMethods;
|
use syntax::attr::AttrMetaMethods;
|
||||||
use syntax::ext::base::{ExtCtxt, SyntaxEnv, Annotatable};
|
use syntax::ext::base::{ExtCtxt, SyntaxEnv, Annotatable};
|
||||||
use syntax::ext::base::{MultiDecorator, MultiItemDecorator, MultiModifier};
|
use syntax::ext::base::{MultiDecorator, MultiItemDecorator, MultiModifier};
|
||||||
|
@ -94,7 +94,7 @@ fn expand_derive(cx: &mut ExtCtxt,
|
||||||
|
|
||||||
for titem in traits.iter().rev() {
|
for titem in traits.iter().rev() {
|
||||||
let tname = match titem.node {
|
let tname = match titem.node {
|
||||||
MetaWord(ref tname) => tname,
|
MetaItemKind::Word(ref tname) => tname,
|
||||||
_ => {
|
_ => {
|
||||||
cx.span_err(titem.span, "malformed `derive` entry");
|
cx.span_err(titem.span, "malformed `derive` entry");
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -101,8 +101,8 @@ fn expand_duplicate(cx: &mut ExtCtxt,
|
||||||
push: &mut FnMut(Annotatable))
|
push: &mut FnMut(Annotatable))
|
||||||
{
|
{
|
||||||
let copy_name = match mi.node {
|
let copy_name = match mi.node {
|
||||||
ast::MetaItem_::MetaList(_, ref xs) => {
|
ast::MetaItemKind::List(_, ref xs) => {
|
||||||
if let ast::MetaItem_::MetaWord(ref w) = xs[0].node {
|
if let ast::MetaItemKind::Word(ref w) = xs[0].node {
|
||||||
token::str_to_ident(&w)
|
token::str_to_ident(&w)
|
||||||
} else {
|
} else {
|
||||||
cx.span_err(mi.span, "Expected word");
|
cx.span_err(mi.span, "Expected word");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue