diff options
| author | varkor <github@varkor.com> | 2019-09-26 18:04:05 +0100 |
|---|---|---|
| committer | varkor <github@varkor.com> | 2019-09-26 18:21:48 +0100 |
| commit | 38121173e27d304366c6fd422318e1e424941b7c (patch) | |
| tree | 9016704208a96e5da5e8918388f512ba5f03a638 /src/libsyntax/attr | |
| parent | b4748679611c97c09cfb7096917d7830c410a4ad (diff) | |
| download | rust-38121173e27d304366c6fd422318e1e424941b7c.tar.gz rust-38121173e27d304366c6fd422318e1e424941b7c.zip | |
Rename `MetaItem.node` to `MetaItem.kind`
Diffstat (limited to 'src/libsyntax/attr')
| -rw-r--r-- | src/libsyntax/attr/builtin.rs | 14 | ||||
| -rw-r--r-- | src/libsyntax/attr/mod.rs | 36 |
2 files changed, 25 insertions, 25 deletions
diff --git a/src/libsyntax/attr/builtin.rs b/src/libsyntax/attr/builtin.rs index ca314642d62..2a8e6b2cc95 100644 --- a/src/libsyntax/attr/builtin.rs +++ b/src/libsyntax/attr/builtin.rs @@ -106,7 +106,7 @@ pub fn find_unwind_attr(diagnostic: Option<&Handler>, attrs: &[Attribute]) -> Op attrs.iter().fold(None, |ia, attr| { if attr.check_name(sym::unwind) { if let Some(meta) = attr.meta() { - if let MetaItemKind::List(items) = meta.node { + if let MetaItemKind::List(items) = meta.kind { if items.len() == 1 { if items[0].check_name(sym::allowed) { return Some(UnwindAttr::Allowed); @@ -239,7 +239,7 @@ fn find_stability_generic<'a, I>(sess: &ParseSess, allow_const_fn_ptr = true; } // attributes with data - else if let Some(MetaItem { node: MetaItemKind::List(ref metas), .. }) = meta { + else if let Some(MetaItem { kind: MetaItemKind::List(ref metas), .. }) = meta { let meta = meta.as_ref().unwrap(); let get = |meta: &MetaItem, item: &mut Option<Symbol>| { if item.is_some() { @@ -534,7 +534,7 @@ pub fn cfg_matches(cfg: &ast::MetaItem, sess: &ParseSess, features: Option<&Feat if cfg.path.segments.len() != 1 { return error(cfg.path.span, "`cfg` predicate key must be an identifier"); } - match &cfg.node { + match &cfg.kind { MetaItemKind::List(..) => { error(cfg.span, "unexpected parentheses after `cfg` predicate key") } @@ -563,7 +563,7 @@ pub fn eval_condition<F>(cfg: &ast::MetaItem, sess: &ParseSess, eval: &mut F) -> bool where F: FnMut(&ast::MetaItem) -> bool { - match cfg.node { + match cfg.kind { ast::MetaItemKind::List(ref mis) => { for mi in mis.iter() { if !mi.is_meta_item() { @@ -642,7 +642,7 @@ fn find_deprecation_generic<'a, I>(sess: &ParseSess, } let meta = attr.meta().unwrap(); - depr = match &meta.node { + depr = match &meta.kind { MetaItemKind::Word => Some(Deprecation { since: None, note: None }), MetaItemKind::NameValue(..) => { meta.value_str().map(|note| { @@ -830,7 +830,7 @@ pub fn find_repr_attrs(sess: &ParseSess, attr: &Attribute) -> Vec<ReprAttr> { } else { if let Some(meta_item) = item.meta_item() { if meta_item.check_name(sym::align) { - if let MetaItemKind::NameValue(ref value) = meta_item.node { + if let MetaItemKind::NameValue(ref value) = meta_item.kind { recognised = true; let mut err = struct_span_err!(diagnostic, item.span(), E0693, "incorrect `repr(align)` attribute format"); @@ -941,7 +941,7 @@ crate fn check_builtin_attribute( name == sym::test || name == sym::bench; match attr.parse_meta(sess) { - Ok(meta) => if !should_skip(name) && !template.compatible(&meta.node) { + Ok(meta) => if !should_skip(name) && !template.compatible(&meta.kind) { let error_msg = format!("malformed `{}` attribute input", name); let mut msg = "attribute must be of the form ".to_owned(); let mut suggestions = vec![]; diff --git a/src/libsyntax/attr/mod.rs b/src/libsyntax/attr/mod.rs index 91bd0f29762..122cb7fb12b 100644 --- a/src/libsyntax/attr/mod.rs +++ b/src/libsyntax/attr/mod.rs @@ -174,7 +174,7 @@ impl Attribute { pub fn meta_item_list(&self) -> Option<Vec<NestedMetaItem>> { match self.meta() { - Some(MetaItem { node: MetaItemKind::List(list), .. }) => Some(list), + Some(MetaItem { kind: MetaItemKind::List(list), .. }) => Some(list), _ => None } } @@ -210,14 +210,14 @@ impl MetaItem { // #[attribute(name = "value")] // ^^^^^^^^^^^^^^ pub fn name_value_literal(&self) -> Option<&Lit> { - match &self.node { + match &self.kind { MetaItemKind::NameValue(v) => Some(v), _ => None, } } pub fn value_str(&self) -> Option<Symbol> { - match self.node { + match self.kind { MetaItemKind::NameValue(ref v) => { match v.kind { LitKind::Str(ref s, _) => Some(*s), @@ -229,14 +229,14 @@ impl MetaItem { } pub fn meta_item_list(&self) -> Option<&[NestedMetaItem]> { - match self.node { + match self.kind { MetaItemKind::List(ref l) => Some(&l[..]), _ => None } } pub fn is_word(&self) -> bool { - match self.node { + match self.kind { MetaItemKind::Word => true, _ => false, } @@ -261,11 +261,11 @@ impl Attribute { let mut tokens = self.tokens.trees().peekable(); Some(MetaItem { path: self.path.clone(), - node: if let Some(node) = MetaItemKind::from_tokens(&mut tokens) { + kind: if let Some(kind) = MetaItemKind::from_tokens(&mut tokens) { if tokens.peek().is_some() { return None; } - node + kind } else { return None; }, @@ -314,7 +314,7 @@ impl Attribute { pub fn parse_meta<'a>(&self, sess: &'a ParseSess) -> PResult<'a, MetaItem> { Ok(MetaItem { path: self.path.clone(), - node: self.parse(sess, |parser| parser.parse_meta_item_kind())?, + kind: self.parse(sess, |parser| parser.parse_meta_item_kind())?, span: self.span, }) } @@ -336,7 +336,7 @@ impl Attribute { id: self.id, style: self.style, path: meta.path, - tokens: meta.node.tokens(meta.span), + tokens: meta.kind.tokens(meta.span), is_sugared_doc: true, span: self.span, }) @@ -356,15 +356,15 @@ pub fn mk_name_value_item_str(ident: Ident, str: Symbol, str_span: Span) -> Meta pub fn mk_name_value_item(ident: Ident, lit_kind: LitKind, lit_span: Span) -> MetaItem { let lit = Lit::from_lit_kind(lit_kind, lit_span); let span = ident.span.to(lit_span); - MetaItem { path: Path::from_ident(ident), span, node: MetaItemKind::NameValue(lit) } + MetaItem { path: Path::from_ident(ident), span, kind: MetaItemKind::NameValue(lit) } } pub fn mk_list_item(ident: Ident, items: Vec<NestedMetaItem>) -> MetaItem { - MetaItem { path: Path::from_ident(ident), span: ident.span, node: MetaItemKind::List(items) } + MetaItem { path: Path::from_ident(ident), span: ident.span, kind: MetaItemKind::List(items) } } pub fn mk_word_item(ident: Ident) -> MetaItem { - MetaItem { path: Path::from_ident(ident), span: ident.span, node: MetaItemKind::Word } + MetaItem { path: Path::from_ident(ident), span: ident.span, kind: MetaItemKind::Word } } pub fn mk_nested_word_item(ident: Ident) -> NestedMetaItem { @@ -395,12 +395,12 @@ pub fn mk_attr(style: AttrStyle, path: Path, tokens: TokenStream, span: Span) -> /// Returns an inner attribute with the given value and span. pub fn mk_attr_inner(item: MetaItem) -> Attribute { - mk_attr(AttrStyle::Inner, item.path, item.node.tokens(item.span), item.span) + mk_attr(AttrStyle::Inner, item.path, item.kind.tokens(item.span), item.span) } /// Returns an outer attribute with the given value and span. pub fn mk_attr_outer(item: MetaItem) -> Attribute { - mk_attr(AttrStyle::Outer, item.path, item.node.tokens(item.span), item.span) + mk_attr(AttrStyle::Outer, item.path, item.kind.tokens(item.span), item.span) } pub fn mk_sugared_doc_attr(text: Symbol, span: Span) -> Attribute { @@ -483,7 +483,7 @@ impl MetaItem { idents.push(TokenTree::Token(Token::from_ast_ident(segment.ident)).into()); last_pos = segment.ident.span.hi(); } - self.node.tokens(self.span).append_to_tree_and_joint_vec(&mut idents); + self.kind.tokens(self.span).append_to_tree_and_joint_vec(&mut idents); TokenStream::new(idents) } @@ -531,14 +531,14 @@ impl MetaItem { _ => return None, }; let list_closing_paren_pos = tokens.peek().map(|tt| tt.span().hi()); - let node = MetaItemKind::from_tokens(tokens)?; - let hi = match node { + let kind = MetaItemKind::from_tokens(tokens)?; + let hi = match kind { MetaItemKind::NameValue(ref lit) => lit.span.hi(), MetaItemKind::List(..) => list_closing_paren_pos.unwrap_or(path.span.hi()), _ => path.span.hi(), }; let span = path.span.with_hi(hi); - Some(MetaItem { path, node, span }) + Some(MetaItem { path, kind, span }) } } |
