Skip to content

Commit 6dfc4a0

Browse files
committed
Rename NestedMetaItem to MetaItemInner
1 parent 68301a6 commit 6dfc4a0

File tree

39 files changed

+167
-173
lines changed

39 files changed

+167
-173
lines changed

Diff for: 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

Diff for: compiler/rustc_ast/src/attr/mod.rs

+24-24
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,28 +519,28 @@ 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` or if it's
531-
/// `NestedMetaItem::Lit(MetaItemLit { kind: LitKind::Bool(_), .. })`.
532-
pub fn meta_item_or_bool(&self) -> Option<&NestedMetaItem> {
530+
/// Returns the `MetaItem` if `self` is a `MetaItemInner::MetaItem` or if it's
531+
/// `MetaItemInner::Lit(MetaItemLit { kind: LitKind::Bool(_), .. })`.
532+
pub fn meta_item_or_bool(&self) -> Option<&MetaItemInner> {
533533
match self {
534-
NestedMetaItem::MetaItem(_item) => Some(self),
535-
NestedMetaItem::Lit(MetaItemLit { kind: LitKind::Bool(_), .. }) => Some(self),
534+
MetaItemInner::MetaItem(_item) => Some(self),
535+
MetaItemInner::Lit(MetaItemLit { kind: LitKind::Bool(_), .. }) => Some(self),
536536
_ => None,
537537
}
538538
}
539539

540-
/// Returns the `MetaItem` if `self` is a `NestedMetaItem::MetaItem`.
540+
/// Returns the `MetaItem` if `self` is a `MetaItemInner::MetaItem`.
541541
pub fn meta_item(&self) -> Option<&MetaItem> {
542542
match self {
543-
NestedMetaItem::MetaItem(item) => Some(item),
543+
MetaItemInner::MetaItem(item) => Some(item),
544544
_ => None,
545545
}
546546
}
@@ -550,22 +550,22 @@ impl NestedMetaItem {
550550
self.meta_item().is_some()
551551
}
552552

553-
fn from_tokens<'a, I>(tokens: &mut iter::Peekable<I>) -> Option<NestedMetaItem>
553+
fn from_tokens<'a, I>(tokens: &mut iter::Peekable<I>) -> Option<MetaItemInner>
554554
where
555555
I: Iterator<Item = &'a TokenTree>,
556556
{
557557
match tokens.peek() {
558558
Some(TokenTree::Token(token, _)) if let Some(lit) = MetaItemLit::from_token(token) => {
559559
tokens.next();
560-
return Some(NestedMetaItem::Lit(lit));
560+
return Some(MetaItemInner::Lit(lit));
561561
}
562562
Some(TokenTree::Delimited(.., Delimiter::Invisible, inner_tokens)) => {
563563
tokens.next();
564-
return NestedMetaItem::from_tokens(&mut inner_tokens.trees().peekable());
564+
return MetaItemInner::from_tokens(&mut inner_tokens.trees().peekable());
565565
}
566566
_ => {}
567567
}
568-
MetaItem::from_tokens(tokens).map(NestedMetaItem::MetaItem)
568+
MetaItem::from_tokens(tokens).map(MetaItemInner::MetaItem)
569569
}
570570
}
571571

@@ -676,6 +676,6 @@ pub fn contains_name(attrs: &[Attribute], name: Symbol) -> bool {
676676
find_by_name(attrs, name).is_some()
677677
}
678678

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

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: compiler/rustc_attr/src/builtin.rs

+12-12
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;
@@ -534,7 +534,7 @@ pub struct Condition {
534534

535535
/// Tests if a cfg-pattern matches the cfg set
536536
pub fn cfg_matches(
537-
cfg: &ast::NestedMetaItem,
537+
cfg: &ast::MetaItemInner,
538538
sess: &Session,
539539
lint_node_id: NodeId,
540540
features: Option<&Features>,
@@ -605,16 +605,16 @@ pub fn parse_version(s: Symbol) -> Option<RustcVersion> {
605605
/// Evaluate a cfg-like condition (with `any` and `all`), using `eval` to
606606
/// evaluate individual items.
607607
pub fn eval_condition(
608-
cfg: &ast::NestedMetaItem,
608+
cfg: &ast::MetaItemInner,
609609
sess: &Session,
610610
features: Option<&Features>,
611611
eval: &mut impl FnMut(Condition) -> bool,
612612
) -> bool {
613613
let dcx = sess.dcx();
614614

615615
let cfg = match cfg {
616-
ast::NestedMetaItem::MetaItem(meta_item) => meta_item,
617-
ast::NestedMetaItem::Lit(MetaItemLit { kind: LitKind::Bool(b), .. }) => {
616+
ast::MetaItemInner::MetaItem(meta_item) => meta_item,
617+
ast::MetaItemInner::Lit(MetaItemLit { kind: LitKind::Bool(b), .. }) => {
618618
if let Some(features) = features {
619619
// we can't use `try_gate_cfg` as symbols don't differentiate between `r#true`
620620
// and `true`, and we want to keep the former working without feature gate
@@ -646,12 +646,12 @@ pub fn eval_condition(
646646
ast::MetaItemKind::List(mis) if cfg.name_or_empty() == sym::version => {
647647
try_gate_cfg(sym::version, cfg.span, sess, features);
648648
let (min_version, span) = match &mis[..] {
649-
[NestedMetaItem::Lit(MetaItemLit { kind: LitKind::Str(sym, ..), span, .. })] => {
649+
[MetaItemInner::Lit(MetaItemLit { kind: LitKind::Str(sym, ..), span, .. })] => {
650650
(sym, span)
651651
}
652652
[
653-
NestedMetaItem::Lit(MetaItemLit { span, .. })
654-
| NestedMetaItem::MetaItem(MetaItem { span, .. }),
653+
MetaItemInner::Lit(MetaItemLit { span, .. })
654+
| MetaItemInner::MetaItem(MetaItem { span, .. }),
655655
] => {
656656
dcx.emit_err(session_diagnostics::ExpectedVersionLiteral { span: *span });
657657
return false;
@@ -729,7 +729,7 @@ pub fn eval_condition(
729729
}
730730

731731
res & eval_condition(
732-
&ast::NestedMetaItem::MetaItem(mi),
732+
&ast::MetaItemInner::MetaItem(mi),
733733
sess,
734734
features,
735735
eval,
@@ -873,7 +873,7 @@ pub fn find_deprecation(
873873

874874
for meta in list {
875875
match meta {
876-
NestedMetaItem::MetaItem(mi) => match mi.name_or_empty() {
876+
MetaItemInner::MetaItem(mi) => match mi.name_or_empty() {
877877
sym::since => {
878878
if !get(mi, &mut since) {
879879
continue 'outer;
@@ -912,7 +912,7 @@ pub fn find_deprecation(
912912
continue 'outer;
913913
}
914914
},
915-
NestedMetaItem::Lit(lit) => {
915+
MetaItemInner::Lit(lit) => {
916916
sess.dcx().emit_err(session_diagnostics::UnsupportedLiteral {
917917
span: lit.span,
918918
reason: UnsupportedLiteralReason::DeprecatedKvPair,
@@ -1277,7 +1277,7 @@ pub fn parse_confusables(attr: &Attribute) -> Option<Vec<Symbol>> {
12771277
let mut candidates = Vec::new();
12781278

12791279
for meta in metas {
1280-
let NestedMetaItem::Lit(meta_lit) = meta else {
1280+
let MetaItemInner::Lit(meta_lit) = meta else {
12811281
return None;
12821282
};
12831283
candidates.push(meta_lit.symbol);

Diff for: compiler/rustc_builtin_macros/src/cfg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fn parse_cfg<'a>(
3939
cx: &ExtCtxt<'a>,
4040
span: Span,
4141
tts: TokenStream,
42-
) -> PResult<'a, ast::NestedMetaItem> {
42+
) -> PResult<'a, ast::MetaItemInner> {
4343
let mut p = cx.new_parser_from_tts(tts);
4444

4545
if p.token == token::Eof {

Diff for: 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

Diff for: 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() {

Diff for: compiler/rustc_codegen_ssa/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ pub struct NativeLib {
156156
pub kind: NativeLibKind,
157157
pub name: Symbol,
158158
pub filename: Option<Symbol>,
159-
pub cfg: Option<ast::NestedMetaItem>,
159+
pub cfg: Option<ast::MetaItemInner>,
160160
pub verbatim: bool,
161161
pub dll_imports: Vec<cstore::DllImport>,
162162
}

Diff for: 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() {

0 commit comments

Comments
 (0)