Skip to content

Commit dcca262

Browse files
committed
Rename NestedMetaItem to MetaItemInner
1 parent c4f7176 commit dcca262

File tree

36 files changed

+139
-145
lines changed

36 files changed

+139
-145
lines changed

compiler/rustc_ast/src/ast.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ pub enum MetaItemKind {
511511
/// List meta item.
512512
///
513513
/// E.g., `#[derive(..)]`, where the field represents the `..`.
514-
List(ThinVec<NestedMetaItem>),
514+
List(ThinVec<MetaItemInner>),
515515

516516
/// Name value meta item.
517517
///
@@ -523,7 +523,7 @@ pub enum MetaItemKind {
523523
///
524524
/// E.g., each of `Clone`, `Copy` in `#[derive(Clone, Copy)]`.
525525
#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)]
526-
pub enum NestedMetaItem {
526+
pub enum MetaItemInner {
527527
/// A full MetaItem, for recursive meta items.
528528
MetaItem(MetaItem),
529529

compiler/rustc_ast/src/attr/mod.rs

+19-19
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use thin_vec::{ThinVec, thin_vec};
1111

1212
use crate::ast::{
1313
AttrArgs, AttrArgsEq, AttrId, AttrItem, AttrKind, AttrStyle, AttrVec, Attribute, DUMMY_NODE_ID,
14-
DelimArgs, Expr, ExprKind, LitKind, MetaItem, MetaItemKind, MetaItemLit, NestedMetaItem,
14+
DelimArgs, Expr, ExprKind, LitKind, MetaItem, MetaItemInner, MetaItemKind, MetaItemLit,
1515
NormalAttr, Path, PathSegment, Safety,
1616
};
1717
use crate::ptr::P;
@@ -136,7 +136,7 @@ impl Attribute {
136136
}
137137
}
138138

139-
pub fn meta_item_list(&self) -> Option<ThinVec<NestedMetaItem>> {
139+
pub fn meta_item_list(&self) -> Option<ThinVec<MetaItemInner>> {
140140
match &self.kind {
141141
AttrKind::Normal(normal) => normal.item.meta_item_list(),
142142
AttrKind::DocComment(..) => None,
@@ -223,7 +223,7 @@ impl AttrItem {
223223
self.args.span().map_or(self.path.span, |args_span| self.path.span.to(args_span))
224224
}
225225

226-
fn meta_item_list(&self) -> Option<ThinVec<NestedMetaItem>> {
226+
fn meta_item_list(&self) -> Option<ThinVec<MetaItemInner>> {
227227
match &self.args {
228228
AttrArgs::Delimited(args) if args.delim == Delimiter::Parenthesis => {
229229
MetaItemKind::list_from_tokens(args.tokens.clone())
@@ -285,7 +285,7 @@ impl MetaItem {
285285
matches!(self.kind, MetaItemKind::Word)
286286
}
287287

288-
pub fn meta_item_list(&self) -> Option<&[NestedMetaItem]> {
288+
pub fn meta_item_list(&self) -> Option<&[MetaItemInner]> {
289289
match &self.kind {
290290
MetaItemKind::List(l) => Some(&**l),
291291
_ => None,
@@ -393,11 +393,11 @@ impl MetaItem {
393393
}
394394

395395
impl MetaItemKind {
396-
fn list_from_tokens(tokens: TokenStream) -> Option<ThinVec<NestedMetaItem>> {
396+
fn list_from_tokens(tokens: TokenStream) -> Option<ThinVec<MetaItemInner>> {
397397
let mut tokens = tokens.trees().peekable();
398398
let mut result = ThinVec::new();
399399
while tokens.peek().is_some() {
400-
let item = NestedMetaItem::from_tokens(&mut tokens)?;
400+
let item = MetaItemInner::from_tokens(&mut tokens)?;
401401
result.push(item);
402402
match tokens.next() {
403403
None | Some(TokenTree::Token(Token { kind: token::Comma, .. }, _)) => {}
@@ -460,11 +460,11 @@ impl MetaItemKind {
460460
}
461461
}
462462

463-
impl NestedMetaItem {
463+
impl MetaItemInner {
464464
pub fn span(&self) -> Span {
465465
match self {
466-
NestedMetaItem::MetaItem(item) => item.span,
467-
NestedMetaItem::Lit(lit) => lit.span,
466+
MetaItemInner::MetaItem(item) => item.span,
467+
MetaItemInner::Lit(lit) => lit.span,
468468
}
469469
}
470470

@@ -488,7 +488,7 @@ impl NestedMetaItem {
488488
}
489489

490490
/// Gets a list of inner meta items from a list `MetaItem` type.
491-
pub fn meta_item_list(&self) -> Option<&[NestedMetaItem]> {
491+
pub fn meta_item_list(&self) -> Option<&[MetaItemInner]> {
492492
self.meta_item().and_then(|meta_item| meta_item.meta_item_list())
493493
}
494494

@@ -519,18 +519,18 @@ impl NestedMetaItem {
519519
self.meta_item().and_then(|meta_item| meta_item.value_str())
520520
}
521521

522-
/// Returns the `MetaItemLit` if `self` is a `NestedMetaItem::Literal`s.
522+
/// Returns the `MetaItemLit` if `self` is a `MetaItemInner::Literal`s.
523523
pub fn lit(&self) -> Option<&MetaItemLit> {
524524
match self {
525-
NestedMetaItem::Lit(lit) => Some(lit),
525+
MetaItemInner::Lit(lit) => Some(lit),
526526
_ => None,
527527
}
528528
}
529529

530-
/// Returns the `MetaItem` if `self` is a `NestedMetaItem::MetaItem`.
530+
/// Returns the `MetaItem` if `self` is a `MetaItemInner::MetaItem`.
531531
pub fn meta_item(&self) -> Option<&MetaItem> {
532532
match self {
533-
NestedMetaItem::MetaItem(item) => Some(item),
533+
MetaItemInner::MetaItem(item) => Some(item),
534534
_ => None,
535535
}
536536
}
@@ -540,22 +540,22 @@ impl NestedMetaItem {
540540
self.meta_item().is_some()
541541
}
542542

543-
fn from_tokens<'a, I>(tokens: &mut iter::Peekable<I>) -> Option<NestedMetaItem>
543+
fn from_tokens<'a, I>(tokens: &mut iter::Peekable<I>) -> Option<MetaItemInner>
544544
where
545545
I: Iterator<Item = &'a TokenTree>,
546546
{
547547
match tokens.peek() {
548548
Some(TokenTree::Token(token, _)) if let Some(lit) = MetaItemLit::from_token(token) => {
549549
tokens.next();
550-
return Some(NestedMetaItem::Lit(lit));
550+
return Some(MetaItemInner::Lit(lit));
551551
}
552552
Some(TokenTree::Delimited(.., Delimiter::Invisible, inner_tokens)) => {
553553
tokens.next();
554-
return NestedMetaItem::from_tokens(&mut inner_tokens.trees().peekable());
554+
return MetaItemInner::from_tokens(&mut inner_tokens.trees().peekable());
555555
}
556556
_ => {}
557557
}
558-
MetaItem::from_tokens(tokens).map(NestedMetaItem::MetaItem)
558+
MetaItem::from_tokens(tokens).map(MetaItemInner::MetaItem)
559559
}
560560
}
561561

@@ -666,6 +666,6 @@ pub fn contains_name(attrs: &[Attribute], name: Symbol) -> bool {
666666
find_by_name(attrs, name).is_some()
667667
}
668668

669-
pub fn list_contains_name(items: &[NestedMetaItem], name: Symbol) -> bool {
669+
pub fn list_contains_name(items: &[MetaItemInner], name: Symbol) -> bool {
670670
items.iter().any(|item| item.has_name(name))
671671
}

compiler/rustc_ast/src/mut_visit.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ pub trait MutVisitor: Sized {
8383
walk_crate(self, c)
8484
}
8585

86-
fn visit_meta_list_item(&mut self, list_item: &mut NestedMetaItem) {
86+
fn visit_meta_list_item(&mut self, list_item: &mut MetaItemInner) {
8787
walk_meta_list_item(self, list_item);
8888
}
8989

@@ -659,10 +659,10 @@ fn walk_macro_def<T: MutVisitor>(vis: &mut T, macro_def: &mut MacroDef) {
659659
visit_delim_args(vis, body);
660660
}
661661

662-
fn walk_meta_list_item<T: MutVisitor>(vis: &mut T, li: &mut NestedMetaItem) {
662+
fn walk_meta_list_item<T: MutVisitor>(vis: &mut T, li: &mut MetaItemInner) {
663663
match li {
664-
NestedMetaItem::MetaItem(mi) => vis.visit_meta_item(mi),
665-
NestedMetaItem::Lit(_lit) => {}
664+
MetaItemInner::MetaItem(mi) => vis.visit_meta_item(mi),
665+
MetaItemInner::Lit(_lit) => {}
666666
}
667667
}
668668

compiler/rustc_ast_pretty/src/pprust/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub fn vis_to_string(v: &ast::Visibility) -> String {
6767
State::new().vis_to_string(v)
6868
}
6969

70-
pub fn meta_list_item_to_string(li: &ast::NestedMetaItem) -> String {
70+
pub fn meta_list_item_to_string(li: &ast::MetaItemInner) -> String {
7171
State::new().meta_list_item_to_string(li)
7272
}
7373

compiler/rustc_ast_pretty/src/pprust/state.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2006,10 +2006,10 @@ impl<'a> State<'a> {
20062006
self.print_attribute_inline(attr, false)
20072007
}
20082008

2009-
fn print_meta_list_item(&mut self, item: &ast::NestedMetaItem) {
2009+
fn print_meta_list_item(&mut self, item: &ast::MetaItemInner) {
20102010
match item {
2011-
ast::NestedMetaItem::MetaItem(mi) => self.print_meta_item(mi),
2012-
ast::NestedMetaItem::Lit(lit) => self.print_meta_item_lit(lit),
2011+
ast::MetaItemInner::MetaItem(mi) => self.print_meta_item(mi),
2012+
ast::MetaItemInner::Lit(lit) => self.print_meta_item_lit(lit),
20132013
}
20142014
}
20152015

@@ -2054,7 +2054,7 @@ impl<'a> State<'a> {
20542054
Self::to_string(|s| s.print_path_segment(p, false))
20552055
}
20562056

2057-
pub(crate) fn meta_list_item_to_string(&self, li: &ast::NestedMetaItem) -> String {
2057+
pub(crate) fn meta_list_item_to_string(&self, li: &ast::MetaItemInner) -> String {
20582058
Self::to_string(|s| s.print_meta_list_item(li))
20592059
}
20602060

compiler/rustc_attr/src/builtin.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::num::NonZero;
44

55
use rustc_abi::Align;
66
use rustc_ast::{
7-
self as ast, Attribute, LitKind, MetaItem, MetaItemKind, MetaItemLit, NestedMetaItem, NodeId,
7+
self as ast, Attribute, LitKind, MetaItem, MetaItemInner, MetaItemKind, MetaItemLit, NodeId,
88
attr,
99
};
1010
use rustc_ast_pretty::pprust;
@@ -614,12 +614,12 @@ pub fn eval_condition(
614614
ast::MetaItemKind::List(mis) if cfg.name_or_empty() == sym::version => {
615615
try_gate_cfg(sym::version, cfg.span, sess, features);
616616
let (min_version, span) = match &mis[..] {
617-
[NestedMetaItem::Lit(MetaItemLit { kind: LitKind::Str(sym, ..), span, .. })] => {
617+
[MetaItemInner::Lit(MetaItemLit { kind: LitKind::Str(sym, ..), span, .. })] => {
618618
(sym, span)
619619
}
620620
[
621-
NestedMetaItem::Lit(MetaItemLit { span, .. })
622-
| NestedMetaItem::MetaItem(MetaItem { span, .. }),
621+
MetaItemInner::Lit(MetaItemLit { span, .. })
622+
| MetaItemInner::MetaItem(MetaItem { span, .. }),
623623
] => {
624624
dcx.emit_err(session_diagnostics::ExpectedVersionLiteral { span: *span });
625625
return false;
@@ -840,7 +840,7 @@ pub fn find_deprecation(
840840

841841
for meta in list {
842842
match meta {
843-
NestedMetaItem::MetaItem(mi) => match mi.name_or_empty() {
843+
MetaItemInner::MetaItem(mi) => match mi.name_or_empty() {
844844
sym::since => {
845845
if !get(mi, &mut since) {
846846
continue 'outer;
@@ -879,7 +879,7 @@ pub fn find_deprecation(
879879
continue 'outer;
880880
}
881881
},
882-
NestedMetaItem::Lit(lit) => {
882+
MetaItemInner::Lit(lit) => {
883883
sess.dcx().emit_err(session_diagnostics::UnsupportedLiteral {
884884
span: lit.span,
885885
reason: UnsupportedLiteralReason::DeprecatedKvPair,
@@ -1244,7 +1244,7 @@ pub fn parse_confusables(attr: &Attribute) -> Option<Vec<Symbol>> {
12441244
let mut candidates = Vec::new();
12451245

12461246
for meta in metas {
1247-
let NestedMetaItem::Lit(meta_lit) = meta else {
1247+
let MetaItemInner::Lit(meta_lit) = meta else {
12481248
return None;
12491249
};
12501250
candidates.push(meta_lit.symbol);

compiler/rustc_builtin_macros/src/derive.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use rustc_ast as ast;
2-
use rustc_ast::{GenericParamKind, ItemKind, MetaItemKind, NestedMetaItem, StmtKind};
2+
use rustc_ast::{GenericParamKind, ItemKind, MetaItemInner, MetaItemKind, StmtKind};
33
use rustc_expand::base::{
44
Annotatable, DeriveResolution, ExpandResult, ExtCtxt, Indeterminate, MultiItemModifier,
55
};
@@ -50,8 +50,8 @@ impl MultiItemModifier for Expander {
5050
MetaItemKind::List(list) => {
5151
list.iter()
5252
.filter_map(|nested_meta| match nested_meta {
53-
NestedMetaItem::MetaItem(meta) => Some(meta),
54-
NestedMetaItem::Lit(lit) => {
53+
MetaItemInner::MetaItem(meta) => Some(meta),
54+
MetaItemInner::Lit(lit) => {
5555
// Reject `#[derive("Debug")]`.
5656
report_unexpected_meta_item_lit(sess, lit);
5757
None

compiler/rustc_codegen_ssa/src/codegen_attrs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_ast::{MetaItemKind, NestedMetaItem, ast, attr};
1+
use rustc_ast::{MetaItemInner, MetaItemKind, ast, attr};
22
use rustc_attr::{InlineAttr, InstructionSetAttr, OptimizeAttr, list_contains_name};
33
use rustc_errors::codes::*;
44
use rustc_errors::{DiagMessage, SubdiagMessage, struct_span_code_err};
@@ -357,7 +357,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
357357
sym::instruction_set => {
358358
codegen_fn_attrs.instruction_set =
359359
attr.meta_item_list().and_then(|l| match &l[..] {
360-
[NestedMetaItem::MetaItem(set)] => {
360+
[MetaItemInner::MetaItem(set)] => {
361361
let segments =
362362
set.path.segments.iter().map(|x| x.ident.name).collect::<Vec<_>>();
363363
match segments.as_slice() {

compiler/rustc_expand/src/base.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use rustc_span::{DUMMY_SP, FileName, Span};
2929
use smallvec::{SmallVec, smallvec};
3030
use thin_vec::ThinVec;
3131

32-
use crate::base::ast::NestedMetaItem;
32+
use crate::base::ast::MetaItemInner;
3333
use crate::errors;
3434
use crate::expand::{self, AstFragment, Invocation};
3535
use crate::module::DirOwnership;
@@ -783,7 +783,7 @@ impl SyntaxExtension {
783783

784784
fn collapse_debuginfo_by_name(attr: &Attribute) -> Result<CollapseMacroDebuginfo, Span> {
785785
let list = attr.meta_item_list();
786-
let Some([NestedMetaItem::MetaItem(item)]) = list.as_deref() else {
786+
let Some([MetaItemInner::MetaItem(item)]) = list.as_deref() else {
787787
return Err(attr.span);
788788
};
789789
if !item.is_word() {

compiler/rustc_expand/src/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub struct StripUnconfigured<'a> {
3737
}
3838

3939
pub fn features(sess: &Session, krate_attrs: &[Attribute], crate_name: Symbol) -> Features {
40-
fn feature_list(attr: &Attribute) -> ThinVec<ast::NestedMetaItem> {
40+
fn feature_list(attr: &Attribute) -> ThinVec<ast::MetaItemInner> {
4141
if attr.has_name(sym::feature)
4242
&& let Some(list) = attr.meta_item_list()
4343
{

compiler/rustc_expand/src/expand.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_ast::tokenstream::TokenStream;
1111
use rustc_ast::visit::{self, AssocCtxt, Visitor, VisitorResult, try_visit, walk_list};
1212
use rustc_ast::{
1313
AssocItemKind, AstNodeWrapper, AttrArgs, AttrStyle, AttrVec, ExprKind, ForeignItemKind,
14-
HasAttrs, HasNodeId, Inline, ItemKind, MacStmtStyle, MetaItemKind, ModKind, NestedMetaItem,
14+
HasAttrs, HasNodeId, Inline, ItemKind, MacStmtStyle, MetaItemInner, MetaItemKind, ModKind,
1515
NodeId, PatKind, StmtKind, TyKind,
1616
};
1717
use rustc_ast_pretty::pprust;
@@ -1864,7 +1864,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
18641864
.filter(|a| a.has_name(sym::derive))
18651865
.flat_map(|a| a.meta_item_list().unwrap_or_default())
18661866
.filter_map(|nested_meta| match nested_meta {
1867-
NestedMetaItem::MetaItem(ast::MetaItem {
1867+
MetaItemInner::MetaItem(ast::MetaItem {
18681868
kind: MetaItemKind::Word,
18691869
path,
18701870
..

compiler/rustc_incremental/src/persist/dirty_clean.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
//! Errors are reported if we are in the suitable configuration but
2020
//! the required condition is not met.
2121
22-
use rustc_ast::{self as ast, Attribute, NestedMetaItem};
22+
use rustc_ast::{self as ast, Attribute, MetaItemInner};
2323
use rustc_data_structures::fx::FxHashSet;
2424
use rustc_data_structures::unord::UnordSet;
2525
use rustc_hir::def_id::LocalDefId;
@@ -307,7 +307,7 @@ impl<'tcx> DirtyCleanVisitor<'tcx> {
307307
(name, labels)
308308
}
309309

310-
fn resolve_labels(&self, item: &NestedMetaItem, value: Symbol) -> Labels {
310+
fn resolve_labels(&self, item: &MetaItemInner, value: Symbol) -> Labels {
311311
let mut out = Labels::default();
312312
for label in value.as_str().split(',') {
313313
let label = label.trim();
@@ -415,7 +415,7 @@ fn check_config(tcx: TyCtxt<'_>, attr: &Attribute) -> bool {
415415
}
416416
}
417417

418-
fn expect_associated_value(tcx: TyCtxt<'_>, item: &NestedMetaItem) -> Symbol {
418+
fn expect_associated_value(tcx: TyCtxt<'_>, item: &MetaItemInner) -> Symbol {
419419
if let Some(value) = item.value_str() {
420420
value
421421
} else if let Some(ident) = item.ident() {

compiler/rustc_lint/src/levels.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
669669

670670
let sp = li.span();
671671
let meta_item = match li {
672-
ast::NestedMetaItem::MetaItem(meta_item) if meta_item.is_word() => meta_item,
672+
ast::MetaItemInner::MetaItem(meta_item) if meta_item.is_word() => meta_item,
673673
_ => {
674674
let sub = if let Some(item) = li.meta_item()
675675
&& let ast::MetaItemKind::NameValue(_) = item.kind

compiler/rustc_metadata/src/native_libs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::ops::ControlFlow;
22
use std::path::{Path, PathBuf};
33

4-
use rustc_ast::{CRATE_NODE_ID, NestedMetaItem};
4+
use rustc_ast::{CRATE_NODE_ID, MetaItemInner};
55
use rustc_attr as attr;
66
use rustc_data_structures::fx::FxHashSet;
77
use rustc_middle::query::LocalCrate;
@@ -304,7 +304,7 @@ impl<'tcx> Collector<'tcx> {
304304
sess.dcx().emit_err(errors::LinkCfgForm { span: item.span() });
305305
continue;
306306
};
307-
let [NestedMetaItem::MetaItem(link_cfg)] = link_cfg else {
307+
let [MetaItemInner::MetaItem(link_cfg)] = link_cfg else {
308308
sess.dcx()
309309
.emit_err(errors::LinkCfgSinglePredicate { span: item.span() });
310310
continue;

0 commit comments

Comments
 (0)