Skip to content

Commit 3812117

Browse files
committed
Rename MetaItem.node to MetaItem.kind
1 parent b474867 commit 3812117

File tree

19 files changed

+50
-50
lines changed

19 files changed

+50
-50
lines changed

src/librustc/ich/impls_syntax.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ impl_stable_hash_for!(enum ::syntax::ast::NestedMetaItem {
361361

362362
impl_stable_hash_for!(struct ::syntax::ast::MetaItem {
363363
path,
364-
node,
364+
kind,
365365
span
366366
});
367367

src/librustc/lint/levels.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ impl<'a> LintLevelsBuilder<'a> {
218218
let mut reason = None;
219219
let tail_li = &metas[metas.len()-1];
220220
if let Some(item) = tail_li.meta_item() {
221-
match item.node {
221+
match item.kind {
222222
ast::MetaItemKind::Word => {} // actual lint names handled later
223223
ast::MetaItemKind::NameValue(ref name_value) => {
224224
if item.path == sym::reason {
@@ -264,7 +264,7 @@ impl<'a> LintLevelsBuilder<'a> {
264264
let mut err = bad_attr(sp);
265265
let mut add_label = true;
266266
if let Some(item) = li.meta_item() {
267-
if let ast::MetaItemKind::NameValue(_) = item.node {
267+
if let ast::MetaItemKind::NameValue(_) = item.kind {
268268
if item.path == sym::reason {
269269
err.span_label(sp, "reason in lint attribute must come last");
270270
add_label = false;

src/librustc/middle/lib_features.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl LibFeatureCollector<'tcx> {
5959
attr.check_name(**stab_attr)
6060
}) {
6161
let meta_item = attr.meta();
62-
if let Some(MetaItem { node: MetaItemKind::List(ref metas), .. }) = meta_item {
62+
if let Some(MetaItem { kind: MetaItemKind::List(ref metas), .. }) = meta_item {
6363
let mut feature = None;
6464
let mut since = None;
6565
for meta in metas {

src/librustc/session/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1879,7 +1879,7 @@ pub fn parse_cfgspecs(cfgspecs: Vec<String>) -> FxHashSet<(String, Option<String
18791879
if meta_item.path.segments.len() != 1 {
18801880
error!("argument key must be an identifier");
18811881
}
1882-
match &meta_item.node {
1882+
match &meta_item.kind {
18831883
MetaItemKind::List(..) => {
18841884
error!(r#"expected `key` or `key="value"`"#);
18851885
}

src/librustc_driver/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ impl RustcDefaultCalls {
700700
let mut cfgs = sess.parse_sess.config.iter().filter_map(|&(name, ref value)| {
701701
let gated_cfg = GatedCfg::gate(&ast::MetaItem {
702702
path: ast::Path::from_ident(ast::Ident::with_dummy_span(name)),
703-
node: ast::MetaItemKind::Word,
703+
kind: ast::MetaItemKind::Word,
704704
span: DUMMY_SP,
705705
});
706706

src/librustc_interface/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<c
556556
sym::bin
557557
];
558558

559-
if let ast::MetaItemKind::NameValue(spanned) = a.meta().unwrap().node {
559+
if let ast::MetaItemKind::NameValue(spanned) = a.meta().unwrap().kind {
560560
let span = spanned.span;
561561
let lev_candidate = find_best_match_for_name(
562562
crate_types.iter(),

src/librustc_resolve/build_reduced_graph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
944944
}
945945
let ill_formed = |span| span_err!(self.r.session, span, E0466, "bad macro import");
946946
match attr.meta() {
947-
Some(meta) => match meta.node {
947+
Some(meta) => match meta.kind {
948948
MetaItemKind::Word => {
949949
import_all = Some(meta.span);
950950
break;

src/librustc_typeck/collect.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2653,7 +2653,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs {
26532653
if attr.path != sym::inline {
26542654
return ia;
26552655
}
2656-
match attr.meta().map(|i| i.node) {
2656+
match attr.meta().map(|i| i.kind) {
26572657
Some(MetaItemKind::Word) => {
26582658
mark_used(attr);
26592659
InlineAttr::Hint
@@ -2694,7 +2694,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs {
26942694
return ia;
26952695
}
26962696
let err = |sp, s| span_err!(tcx.sess.diagnostic(), sp, E0722, "{}", s);
2697-
match attr.meta().map(|i| i.node) {
2697+
match attr.meta().map(|i| i.kind) {
26982698
Some(MetaItemKind::Word) => {
26992699
err(attr.span, "expected one argument");
27002700
ia

src/librustdoc/clean/cfg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl Cfg {
6868
span: cfg.span
6969
}),
7070
};
71-
match cfg.node {
71+
match cfg.kind {
7272
MetaItemKind::Word => Ok(Cfg::Cfg(name, None)),
7373
MetaItemKind::NameValue(ref lit) => match lit.kind {
7474
LitKind::Str(value, _) => Ok(Cfg::Cfg(name, Some(value))),

src/librustdoc/clean/cfg/tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn name_value_cfg(name: &str, value: &str) -> Cfg {
1717
fn dummy_meta_item_word(name: &str) -> MetaItem {
1818
MetaItem {
1919
path: Path::from_ident(Ident::from_str(name)),
20-
node: MetaItemKind::Word,
20+
kind: MetaItemKind::Word,
2121
span: DUMMY_SP,
2222
}
2323
}
@@ -26,7 +26,7 @@ macro_rules! dummy_meta_item_list {
2626
($name:ident, [$($list:ident),* $(,)?]) => {
2727
MetaItem {
2828
path: Path::from_ident(Ident::from_str(stringify!($name))),
29-
node: MetaItemKind::List(vec![
29+
kind: MetaItemKind::List(vec![
3030
$(
3131
NestedMetaItem::MetaItem(
3232
dummy_meta_item_word(stringify!($list)),

src/librustdoc/clean/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -778,11 +778,11 @@ impl Attributes {
778778
fn extract_cfg(mi: &ast::MetaItem) -> Option<&ast::MetaItem> {
779779
use syntax::ast::NestedMetaItem::MetaItem;
780780

781-
if let ast::MetaItemKind::List(ref nmis) = mi.node {
781+
if let ast::MetaItemKind::List(ref nmis) = mi.kind {
782782
if nmis.len() == 1 {
783783
if let MetaItem(ref cfg_mi) = nmis[0] {
784784
if cfg_mi.check_name(sym::cfg) {
785-
if let ast::MetaItemKind::List(ref cfg_nmis) = cfg_mi.node {
785+
if let ast::MetaItemKind::List(ref cfg_nmis) = cfg_mi.kind {
786786
if cfg_nmis.len() == 1 {
787787
if let MetaItem(ref content_mi) = cfg_nmis[0] {
788788
return Some(content_mi);

src/libsyntax/ast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ pub enum NestedMetaItem {
472472
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
473473
pub struct MetaItem {
474474
pub path: Path,
475-
pub node: MetaItemKind,
475+
pub kind: MetaItemKind,
476476
pub span: Span,
477477
}
478478

src/libsyntax/attr/builtin.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ pub fn find_unwind_attr(diagnostic: Option<&Handler>, attrs: &[Attribute]) -> Op
106106
attrs.iter().fold(None, |ia, attr| {
107107
if attr.check_name(sym::unwind) {
108108
if let Some(meta) = attr.meta() {
109-
if let MetaItemKind::List(items) = meta.node {
109+
if let MetaItemKind::List(items) = meta.kind {
110110
if items.len() == 1 {
111111
if items[0].check_name(sym::allowed) {
112112
return Some(UnwindAttr::Allowed);
@@ -239,7 +239,7 @@ fn find_stability_generic<'a, I>(sess: &ParseSess,
239239
allow_const_fn_ptr = true;
240240
}
241241
// attributes with data
242-
else if let Some(MetaItem { node: MetaItemKind::List(ref metas), .. }) = meta {
242+
else if let Some(MetaItem { kind: MetaItemKind::List(ref metas), .. }) = meta {
243243
let meta = meta.as_ref().unwrap();
244244
let get = |meta: &MetaItem, item: &mut Option<Symbol>| {
245245
if item.is_some() {
@@ -534,7 +534,7 @@ pub fn cfg_matches(cfg: &ast::MetaItem, sess: &ParseSess, features: Option<&Feat
534534
if cfg.path.segments.len() != 1 {
535535
return error(cfg.path.span, "`cfg` predicate key must be an identifier");
536536
}
537-
match &cfg.node {
537+
match &cfg.kind {
538538
MetaItemKind::List(..) => {
539539
error(cfg.span, "unexpected parentheses after `cfg` predicate key")
540540
}
@@ -563,7 +563,7 @@ pub fn eval_condition<F>(cfg: &ast::MetaItem, sess: &ParseSess, eval: &mut F)
563563
-> bool
564564
where F: FnMut(&ast::MetaItem) -> bool
565565
{
566-
match cfg.node {
566+
match cfg.kind {
567567
ast::MetaItemKind::List(ref mis) => {
568568
for mi in mis.iter() {
569569
if !mi.is_meta_item() {
@@ -642,7 +642,7 @@ fn find_deprecation_generic<'a, I>(sess: &ParseSess,
642642
}
643643

644644
let meta = attr.meta().unwrap();
645-
depr = match &meta.node {
645+
depr = match &meta.kind {
646646
MetaItemKind::Word => Some(Deprecation { since: None, note: None }),
647647
MetaItemKind::NameValue(..) => {
648648
meta.value_str().map(|note| {
@@ -830,7 +830,7 @@ pub fn find_repr_attrs(sess: &ParseSess, attr: &Attribute) -> Vec<ReprAttr> {
830830
} else {
831831
if let Some(meta_item) = item.meta_item() {
832832
if meta_item.check_name(sym::align) {
833-
if let MetaItemKind::NameValue(ref value) = meta_item.node {
833+
if let MetaItemKind::NameValue(ref value) = meta_item.kind {
834834
recognised = true;
835835
let mut err = struct_span_err!(diagnostic, item.span(), E0693,
836836
"incorrect `repr(align)` attribute format");
@@ -941,7 +941,7 @@ crate fn check_builtin_attribute(
941941
name == sym::test || name == sym::bench;
942942

943943
match attr.parse_meta(sess) {
944-
Ok(meta) => if !should_skip(name) && !template.compatible(&meta.node) {
944+
Ok(meta) => if !should_skip(name) && !template.compatible(&meta.kind) {
945945
let error_msg = format!("malformed `{}` attribute input", name);
946946
let mut msg = "attribute must be of the form ".to_owned();
947947
let mut suggestions = vec![];

src/libsyntax/attr/mod.rs

+18-18
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ impl Attribute {
174174

175175
pub fn meta_item_list(&self) -> Option<Vec<NestedMetaItem>> {
176176
match self.meta() {
177-
Some(MetaItem { node: MetaItemKind::List(list), .. }) => Some(list),
177+
Some(MetaItem { kind: MetaItemKind::List(list), .. }) => Some(list),
178178
_ => None
179179
}
180180
}
@@ -210,14 +210,14 @@ impl MetaItem {
210210
// #[attribute(name = "value")]
211211
// ^^^^^^^^^^^^^^
212212
pub fn name_value_literal(&self) -> Option<&Lit> {
213-
match &self.node {
213+
match &self.kind {
214214
MetaItemKind::NameValue(v) => Some(v),
215215
_ => None,
216216
}
217217
}
218218

219219
pub fn value_str(&self) -> Option<Symbol> {
220-
match self.node {
220+
match self.kind {
221221
MetaItemKind::NameValue(ref v) => {
222222
match v.kind {
223223
LitKind::Str(ref s, _) => Some(*s),
@@ -229,14 +229,14 @@ impl MetaItem {
229229
}
230230

231231
pub fn meta_item_list(&self) -> Option<&[NestedMetaItem]> {
232-
match self.node {
232+
match self.kind {
233233
MetaItemKind::List(ref l) => Some(&l[..]),
234234
_ => None
235235
}
236236
}
237237

238238
pub fn is_word(&self) -> bool {
239-
match self.node {
239+
match self.kind {
240240
MetaItemKind::Word => true,
241241
_ => false,
242242
}
@@ -261,11 +261,11 @@ impl Attribute {
261261
let mut tokens = self.tokens.trees().peekable();
262262
Some(MetaItem {
263263
path: self.path.clone(),
264-
node: if let Some(node) = MetaItemKind::from_tokens(&mut tokens) {
264+
kind: if let Some(kind) = MetaItemKind::from_tokens(&mut tokens) {
265265
if tokens.peek().is_some() {
266266
return None;
267267
}
268-
node
268+
kind
269269
} else {
270270
return None;
271271
},
@@ -314,7 +314,7 @@ impl Attribute {
314314
pub fn parse_meta<'a>(&self, sess: &'a ParseSess) -> PResult<'a, MetaItem> {
315315
Ok(MetaItem {
316316
path: self.path.clone(),
317-
node: self.parse(sess, |parser| parser.parse_meta_item_kind())?,
317+
kind: self.parse(sess, |parser| parser.parse_meta_item_kind())?,
318318
span: self.span,
319319
})
320320
}
@@ -336,7 +336,7 @@ impl Attribute {
336336
id: self.id,
337337
style: self.style,
338338
path: meta.path,
339-
tokens: meta.node.tokens(meta.span),
339+
tokens: meta.kind.tokens(meta.span),
340340
is_sugared_doc: true,
341341
span: self.span,
342342
})
@@ -356,15 +356,15 @@ pub fn mk_name_value_item_str(ident: Ident, str: Symbol, str_span: Span) -> Meta
356356
pub fn mk_name_value_item(ident: Ident, lit_kind: LitKind, lit_span: Span) -> MetaItem {
357357
let lit = Lit::from_lit_kind(lit_kind, lit_span);
358358
let span = ident.span.to(lit_span);
359-
MetaItem { path: Path::from_ident(ident), span, node: MetaItemKind::NameValue(lit) }
359+
MetaItem { path: Path::from_ident(ident), span, kind: MetaItemKind::NameValue(lit) }
360360
}
361361

362362
pub fn mk_list_item(ident: Ident, items: Vec<NestedMetaItem>) -> MetaItem {
363-
MetaItem { path: Path::from_ident(ident), span: ident.span, node: MetaItemKind::List(items) }
363+
MetaItem { path: Path::from_ident(ident), span: ident.span, kind: MetaItemKind::List(items) }
364364
}
365365

366366
pub fn mk_word_item(ident: Ident) -> MetaItem {
367-
MetaItem { path: Path::from_ident(ident), span: ident.span, node: MetaItemKind::Word }
367+
MetaItem { path: Path::from_ident(ident), span: ident.span, kind: MetaItemKind::Word }
368368
}
369369

370370
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) ->
395395

396396
/// Returns an inner attribute with the given value and span.
397397
pub fn mk_attr_inner(item: MetaItem) -> Attribute {
398-
mk_attr(AttrStyle::Inner, item.path, item.node.tokens(item.span), item.span)
398+
mk_attr(AttrStyle::Inner, item.path, item.kind.tokens(item.span), item.span)
399399
}
400400

401401
/// Returns an outer attribute with the given value and span.
402402
pub fn mk_attr_outer(item: MetaItem) -> Attribute {
403-
mk_attr(AttrStyle::Outer, item.path, item.node.tokens(item.span), item.span)
403+
mk_attr(AttrStyle::Outer, item.path, item.kind.tokens(item.span), item.span)
404404
}
405405

406406
pub fn mk_sugared_doc_attr(text: Symbol, span: Span) -> Attribute {
@@ -483,7 +483,7 @@ impl MetaItem {
483483
idents.push(TokenTree::Token(Token::from_ast_ident(segment.ident)).into());
484484
last_pos = segment.ident.span.hi();
485485
}
486-
self.node.tokens(self.span).append_to_tree_and_joint_vec(&mut idents);
486+
self.kind.tokens(self.span).append_to_tree_and_joint_vec(&mut idents);
487487
TokenStream::new(idents)
488488
}
489489

@@ -531,14 +531,14 @@ impl MetaItem {
531531
_ => return None,
532532
};
533533
let list_closing_paren_pos = tokens.peek().map(|tt| tt.span().hi());
534-
let node = MetaItemKind::from_tokens(tokens)?;
535-
let hi = match node {
534+
let kind = MetaItemKind::from_tokens(tokens)?;
535+
let hi = match kind {
536536
MetaItemKind::NameValue(ref lit) => lit.span.hi(),
537537
MetaItemKind::List(..) => list_closing_paren_pos.unwrap_or(path.span.hi()),
538538
_ => path.span.hi(),
539539
};
540540
let span = path.span.with_hi(hi);
541-
Some(MetaItem { path, node, span })
541+
Some(MetaItem { path, kind, span })
542542
}
543543
}
544544

src/libsyntax/ext/expand.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
659659
if !item.derive_allowed() {
660660
return fragment_kind.dummy(span);
661661
}
662-
let meta = ast::MetaItem { node: ast::MetaItemKind::Word, span, path };
662+
let meta = ast::MetaItem { kind: ast::MetaItemKind::Word, span, path };
663663
let items = expander.expand(self.cx, span, &meta, item);
664664
fragment_kind.expect_from_annotatables(items)
665665
}
@@ -1534,7 +1534,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
15341534
id: at.id,
15351535
style: at.style,
15361536
path: meta.path,
1537-
tokens: meta.node.tokens(meta.span),
1537+
tokens: meta.kind.tokens(meta.span),
15381538
is_sugared_doc: false,
15391539
};
15401540
} else {

src/libsyntax/mut_visit.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,8 @@ pub fn noop_visit_meta_list_item<T: MutVisitor>(li: &mut NestedMetaItem, vis: &m
576576
}
577577

578578
pub fn noop_visit_meta_item<T: MutVisitor>(mi: &mut MetaItem, vis: &mut T) {
579-
let MetaItem { path: _, node, span } = mi;
580-
match node {
579+
let MetaItem { path: _, kind, span } = mi;
580+
match kind {
581581
MetaItemKind::Word => {}
582582
MetaItemKind::List(mis) => visit_vec(mis, |mi| vis.visit_meta_list_item(mi)),
583583
MetaItemKind::NameValue(_s) => {}

src/libsyntax/parse/attr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ impl<'a> Parser<'a> {
179179
};
180180
Ok(if let Some(meta) = meta {
181181
self.bump();
182-
(meta.path, meta.node.tokens(meta.span))
182+
(meta.path, meta.kind.tokens(meta.span))
183183
} else {
184184
let path = self.parse_path(PathStyle::Mod)?;
185185
let tokens = if self.check(&token::OpenDelim(DelimToken::Paren)) ||
@@ -281,9 +281,9 @@ impl<'a> Parser<'a> {
281281

282282
let lo = self.token.span;
283283
let path = self.parse_path(PathStyle::Mod)?;
284-
let node = self.parse_meta_item_kind()?;
284+
let kind = self.parse_meta_item_kind()?;
285285
let span = lo.to(self.prev_span);
286-
Ok(ast::MetaItem { path, node, span })
286+
Ok(ast::MetaItem { path, kind, span })
287287
}
288288

289289
crate fn parse_meta_item_kind(&mut self) -> PResult<'a, ast::MetaItemKind> {

src/libsyntax/parse/parser/path.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl<'a> Parser<'a> {
114114
pub fn parse_path_allowing_meta(&mut self, style: PathStyle) -> PResult<'a, Path> {
115115
let meta_ident = match self.token.kind {
116116
token::Interpolated(ref nt) => match **nt {
117-
token::NtMeta(ref meta) => match meta.node {
117+
token::NtMeta(ref meta) => match meta.kind {
118118
ast::MetaItemKind::Word => Some(meta.path.clone()),
119119
_ => None,
120120
},

0 commit comments

Comments
 (0)