Skip to content

Commit

Permalink
Rename nested_meta to meta_item_inner
Browse files Browse the repository at this point in the history
  • Loading branch information
codemountains committed Oct 7, 2024
1 parent 6dfc4a0 commit fc64ff7
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 22 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
}
// Check unstable flavors of the `#[doc]` attribute.
if attr.has_name(sym::doc) {
for nested_meta in attr.meta_item_list().unwrap_or_default() {
for meta_item_inner in attr.meta_item_list().unwrap_or_default() {
macro_rules! gate_doc { ($($s:literal { $($name:ident => $feature:ident)* })*) => {
$($(if nested_meta.has_name(sym::$name) {
$($(if meta_item_inner.has_name(sym::$name) {
let msg = concat!("`#[doc(", stringify!($name), ")]` is ", $s);
gate!(self, $feature, attr.span, msg);
})*)*
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl MultiItemModifier for Expander {
let mut resolutions = match &meta_item.kind {
MetaItemKind::List(list) => {
list.iter()
.filter_map(|nested_meta| match nested_meta {
.filter_map(|meta_item_inner| match meta_item_inner {
MetaItemInner::MetaItem(meta) => Some(meta),
MetaItemInner::Lit(lit) => {
// Reject `#[derive("Debug")]`.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_expand/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1863,7 +1863,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
.iter()
.filter(|a| a.has_name(sym::derive))
.flat_map(|a| a.meta_item_list().unwrap_or_default())
.filter_map(|nested_meta| match nested_meta {
.filter_map(|meta_item_inner| match meta_item_inner {
MetaItemInner::MetaItem(ast::MetaItem {
kind: MetaItemKind::Word,
path,
Expand Down
16 changes: 9 additions & 7 deletions compiler/rustc_resolve/src/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1072,13 +1072,13 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
import_all = Some(meta.span);
break;
}
MetaItemKind::List(nested_metas) => {
for nested_meta in nested_metas {
match nested_meta.ident() {
Some(ident) if nested_meta.is_word() => {
MetaItemKind::List(meta_item_inners) => {
for meta_item_inner in meta_item_inners {
match meta_item_inner.ident() {
Some(ident) if meta_item_inner.is_word() => {
single_imports.push(ident)
}
_ => ill_formed(nested_meta.span()),
_ => ill_formed(meta_item_inner.span()),
}
}
}
Expand Down Expand Up @@ -1198,8 +1198,10 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
} else if attr::contains_name(&item.attrs, sym::proc_macro_attribute) {
return Some((MacroKind::Attr, item.ident, item.span));
} else if let Some(attr) = attr::find_by_name(&item.attrs, sym::proc_macro_derive) {
if let Some(nested_meta) = attr.meta_item_list().and_then(|list| list.get(0).cloned()) {
if let Some(ident) = nested_meta.ident() {
if let Some(meta_item_inner) =
attr.meta_item_list().and_then(|list| list.get(0).cloned())
{
if let Some(ident) = meta_item_inner.ident() {
return Some((MacroKind::Derive, ident, ident.span));
}
}
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_resolve/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ pub(crate) fn registered_tools(tcx: TyCtxt<'_>, (): ()) -> RegisteredTools {
let mut registered_tools = RegisteredTools::default();
let (_, pre_configured_attrs) = &*tcx.crate_for_resolver(()).borrow();
for attr in attr::filter_by_name(pre_configured_attrs, sym::register_tool) {
for nested_meta in attr.meta_item_list().unwrap_or_default() {
match nested_meta.ident() {
for meta_item_inner in attr.meta_item_list().unwrap_or_default() {
match meta_item_inner.ident() {
Some(ident) => {
if let Some(old_ident) = registered_tools.replace(ident) {
tcx.dcx().emit_err(errors::ToolWasAlreadyRegistered {
Expand All @@ -142,7 +142,7 @@ pub(crate) fn registered_tools(tcx: TyCtxt<'_>, (): ()) -> RegisteredTools {
}
None => {
tcx.dcx().emit_err(errors::ToolOnlyAcceptsIdentifiers {
span: nested_meta.span(),
span: meta_item_inner.span(),
tool: sym::register_tool,
});
}
Expand Down
6 changes: 3 additions & 3 deletions src/tools/rustfmt/src/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ fn format_derive(
let item_spans = attr.meta_item_list().map(|meta_item_list| {
meta_item_list
.into_iter()
.map(|nested_meta_item| nested_meta_item.span())
.map(|meta_item_inner| meta_item_inner.span())
})?;

let items = itemize_list(
Expand Down Expand Up @@ -536,7 +536,7 @@ pub(crate) trait MetaVisitor<'ast> {
list: &'ast [ast::MetaItemInner],
) {
for nm in list {
self.visit_nested_meta_item(nm);
self.visit_meta_item_inner(nm);
}
}

Expand All @@ -549,7 +549,7 @@ pub(crate) trait MetaVisitor<'ast> {
) {
}

fn visit_nested_meta_item(&mut self, nm: &'ast ast::MetaItemInner) {
fn visit_meta_item_inner(&mut self, nm: &'ast ast::MetaItemInner) {
match nm {
ast::MetaItemInner::MetaItem(ref meta_item) => self.visit_meta_item(meta_item),
ast::MetaItemInner::Lit(ref lit) => self.visit_meta_item_lit(lit),
Expand Down
5 changes: 2 additions & 3 deletions src/tools/rustfmt/src/overflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl<'a> OverflowableItem<'a> {
OverflowableItem::Expr(expr) => is_simple_expr(expr),
OverflowableItem::MacroArg(MacroArg::Keyword(..)) => true,
OverflowableItem::MacroArg(MacroArg::Expr(expr)) => is_simple_expr(expr),
OverflowableItem::MetaItemInner(nested_meta_item) => match nested_meta_item {
OverflowableItem::MetaItemInner(meta_item_inner) => match meta_item_inner {
ast::MetaItemInner::Lit(..) => true,
ast::MetaItemInner::MetaItem(ref meta_item) => {
matches!(meta_item.kind, ast::MetaItemKind::Word)
Expand Down Expand Up @@ -184,8 +184,7 @@ impl<'a> OverflowableItem<'a> {
MacroArg::Item(..) => len == 1,
MacroArg::Keyword(..) => false,
},
OverflowableItem::MetaItemInner(nested_meta_item) if len == 1 => match nested_meta_item
{
OverflowableItem::MetaItemInner(meta_item_inner) if len == 1 => match meta_item_inner {
ast::MetaItemInner::Lit(..) => false,
ast::MetaItemInner::MetaItem(..) => true,
},
Expand Down
4 changes: 2 additions & 2 deletions src/tools/rustfmt/src/skip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ fn get_skip_names(kind: &str, attrs: &[ast::Attribute]) -> Vec<String> {
}

if let Some(list) = attr.meta_item_list() {
for nested_meta_item in list {
if let Some(name) = nested_meta_item.ident() {
for meta_item_inner in list {
if let Some(name) = meta_item_inner.ident() {
skip_names.push(name.to_string());
}
}
Expand Down

0 comments on commit fc64ff7

Please sign in to comment.