Sync mut_visit
function names with immut visit
ones (s/noop_visit/walk/)
This commit is contained in:
parent
6f85f20520
commit
754bdef793
9 changed files with 226 additions and 235 deletions
|
@ -1036,7 +1036,7 @@ pub(crate) fn ensure_complete_parse<'a>(
|
|||
}
|
||||
}
|
||||
|
||||
/// Wraps a call to `noop_visit_*` / `noop_flat_map_*`
|
||||
/// Wraps a call to `walk_*` / `walk_flat_map_*`
|
||||
/// for an AST node that supports attributes
|
||||
/// (see the `Annotatable` enum)
|
||||
/// This method assigns a `NodeId`, and sets that `NodeId`
|
||||
|
@ -1056,7 +1056,7 @@ pub(crate) fn ensure_complete_parse<'a>(
|
|||
/// * `id` is a mutable reference to the `NodeId` field
|
||||
/// of the current AST node.
|
||||
/// * `closure` is a closure that executes the
|
||||
/// `noop_visit_*` / `noop_flat_map_*` method
|
||||
/// `walk_*` / `walk_flat_map_*` method
|
||||
/// for the current AST node.
|
||||
macro_rules! assign_id {
|
||||
($self:ident, $id:expr, $closure:expr) => {{
|
||||
|
@ -1090,10 +1090,10 @@ trait InvocationCollectorNode: HasAttrs + HasNodeId + Sized {
|
|||
fn descr() -> &'static str {
|
||||
unreachable!()
|
||||
}
|
||||
fn noop_flat_map<V: MutVisitor>(self, _visitor: &mut V) -> Self::OutputTy {
|
||||
fn walk_flat_map<V: MutVisitor>(self, _visitor: &mut V) -> Self::OutputTy {
|
||||
unreachable!()
|
||||
}
|
||||
fn noop_visit<V: MutVisitor>(&mut self, _visitor: &mut V) {
|
||||
fn walk<V: MutVisitor>(&mut self, _visitor: &mut V) {
|
||||
unreachable!()
|
||||
}
|
||||
fn is_mac_call(&self) -> bool {
|
||||
|
@ -1117,12 +1117,12 @@ trait InvocationCollectorNode: HasAttrs + HasNodeId + Sized {
|
|||
fn pre_flat_map_node_collect_attr(_cfg: &StripUnconfigured<'_>, _attr: &ast::Attribute) {}
|
||||
fn post_flat_map_node_collect_bang(_output: &mut Self::OutputTy, _add_semicolon: AddSemicolon) {
|
||||
}
|
||||
fn wrap_flat_map_node_noop_flat_map(
|
||||
fn wrap_flat_map_node_walk_flat_map(
|
||||
node: Self,
|
||||
collector: &mut InvocationCollector<'_, '_>,
|
||||
noop_flat_map: impl FnOnce(Self, &mut InvocationCollector<'_, '_>) -> Self::OutputTy,
|
||||
walk_flat_map: impl FnOnce(Self, &mut InvocationCollector<'_, '_>) -> Self::OutputTy,
|
||||
) -> Result<Self::OutputTy, Self> {
|
||||
Ok(noop_flat_map(node, collector))
|
||||
Ok(walk_flat_map(node, collector))
|
||||
}
|
||||
fn expand_cfg_false(
|
||||
&mut self,
|
||||
|
@ -1148,8 +1148,8 @@ impl InvocationCollectorNode for P<ast::Item> {
|
|||
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
|
||||
fragment.make_items()
|
||||
}
|
||||
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
|
||||
noop_flat_map_item(self, None, visitor)
|
||||
fn walk_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
|
||||
walk_flat_map_item(self, None, visitor)
|
||||
}
|
||||
fn is_mac_call(&self) -> bool {
|
||||
matches!(self.kind, ItemKind::MacCall(..))
|
||||
|
@ -1176,13 +1176,13 @@ impl InvocationCollectorNode for P<ast::Item> {
|
|||
fn flatten_outputs(items: impl Iterator<Item = Self::OutputTy>) -> Self::OutputTy {
|
||||
items.flatten().collect()
|
||||
}
|
||||
fn wrap_flat_map_node_noop_flat_map(
|
||||
fn wrap_flat_map_node_walk_flat_map(
|
||||
mut node: Self,
|
||||
collector: &mut InvocationCollector<'_, '_>,
|
||||
noop_flat_map: impl FnOnce(Self, &mut InvocationCollector<'_, '_>) -> Self::OutputTy,
|
||||
walk_flat_map: impl FnOnce(Self, &mut InvocationCollector<'_, '_>) -> Self::OutputTy,
|
||||
) -> Result<Self::OutputTy, Self> {
|
||||
if !matches!(node.kind, ItemKind::Mod(..)) {
|
||||
return Ok(noop_flat_map(node, collector));
|
||||
return Ok(walk_flat_map(node, collector));
|
||||
}
|
||||
|
||||
// Work around borrow checker not seeing through `P`'s deref.
|
||||
|
@ -1252,7 +1252,7 @@ impl InvocationCollectorNode for P<ast::Item> {
|
|||
let orig_dir_ownership =
|
||||
mem::replace(&mut ecx.current_expansion.dir_ownership, dir_ownership);
|
||||
|
||||
let res = Ok(noop_flat_map(node, collector));
|
||||
let res = Ok(walk_flat_map(node, collector));
|
||||
|
||||
collector.cx.current_expansion.dir_ownership = orig_dir_ownership;
|
||||
collector.cx.current_expansion.module = orig_module;
|
||||
|
@ -1292,8 +1292,8 @@ impl InvocationCollectorNode for AstNodeWrapper<P<ast::AssocItem>, TraitItemTag>
|
|||
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
|
||||
fragment.make_trait_items()
|
||||
}
|
||||
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
|
||||
noop_flat_map_item(self.wrapped, Some(AssocCtxt::Trait), visitor)
|
||||
fn walk_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
|
||||
walk_flat_map_item(self.wrapped, Some(AssocCtxt::Trait), visitor)
|
||||
}
|
||||
fn is_mac_call(&self) -> bool {
|
||||
matches!(self.wrapped.kind, AssocItemKind::MacCall(..))
|
||||
|
@ -1333,8 +1333,8 @@ impl InvocationCollectorNode for AstNodeWrapper<P<ast::AssocItem>, ImplItemTag>
|
|||
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
|
||||
fragment.make_impl_items()
|
||||
}
|
||||
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
|
||||
noop_flat_map_item(self.wrapped, Some(AssocCtxt::Impl), visitor)
|
||||
fn walk_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
|
||||
walk_flat_map_item(self.wrapped, Some(AssocCtxt::Impl), visitor)
|
||||
}
|
||||
fn is_mac_call(&self) -> bool {
|
||||
matches!(self.wrapped.kind, AssocItemKind::MacCall(..))
|
||||
|
@ -1371,8 +1371,8 @@ impl InvocationCollectorNode for P<ast::ForeignItem> {
|
|||
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
|
||||
fragment.make_foreign_items()
|
||||
}
|
||||
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
|
||||
noop_flat_map_item(self, None, visitor)
|
||||
fn walk_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
|
||||
walk_flat_map_item(self, None, visitor)
|
||||
}
|
||||
fn is_mac_call(&self) -> bool {
|
||||
matches!(self.kind, ForeignItemKind::MacCall(..))
|
||||
|
@ -1394,8 +1394,8 @@ impl InvocationCollectorNode for ast::Variant {
|
|||
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
|
||||
fragment.make_variants()
|
||||
}
|
||||
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
|
||||
noop_flat_map_variant(self, visitor)
|
||||
fn walk_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
|
||||
walk_flat_map_variant(self, visitor)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1407,8 +1407,8 @@ impl InvocationCollectorNode for ast::FieldDef {
|
|||
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
|
||||
fragment.make_field_defs()
|
||||
}
|
||||
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
|
||||
noop_flat_map_field_def(self, visitor)
|
||||
fn walk_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
|
||||
walk_flat_map_field_def(self, visitor)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1420,8 +1420,8 @@ impl InvocationCollectorNode for ast::PatField {
|
|||
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
|
||||
fragment.make_pat_fields()
|
||||
}
|
||||
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
|
||||
noop_flat_map_pat_field(self, visitor)
|
||||
fn walk_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
|
||||
walk_flat_map_pat_field(self, visitor)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1433,8 +1433,8 @@ impl InvocationCollectorNode for ast::ExprField {
|
|||
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
|
||||
fragment.make_expr_fields()
|
||||
}
|
||||
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
|
||||
noop_flat_map_expr_field(self, visitor)
|
||||
fn walk_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
|
||||
walk_flat_map_expr_field(self, visitor)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1446,8 +1446,8 @@ impl InvocationCollectorNode for ast::Param {
|
|||
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
|
||||
fragment.make_params()
|
||||
}
|
||||
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
|
||||
noop_flat_map_param(self, visitor)
|
||||
fn walk_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
|
||||
walk_flat_map_param(self, visitor)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1459,8 +1459,8 @@ impl InvocationCollectorNode for ast::GenericParam {
|
|||
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
|
||||
fragment.make_generic_params()
|
||||
}
|
||||
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
|
||||
noop_flat_map_generic_param(self, visitor)
|
||||
fn walk_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
|
||||
walk_flat_map_generic_param(self, visitor)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1472,8 +1472,8 @@ impl InvocationCollectorNode for ast::Arm {
|
|||
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
|
||||
fragment.make_arms()
|
||||
}
|
||||
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
|
||||
noop_flat_map_arm(self, visitor)
|
||||
fn walk_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
|
||||
walk_flat_map_arm(self, visitor)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1486,8 +1486,8 @@ impl InvocationCollectorNode for ast::Stmt {
|
|||
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
|
||||
fragment.make_stmts()
|
||||
}
|
||||
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
|
||||
noop_flat_map_stmt(self, visitor)
|
||||
fn walk_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
|
||||
walk_flat_map_stmt(self, visitor)
|
||||
}
|
||||
fn is_mac_call(&self) -> bool {
|
||||
match &self.kind {
|
||||
|
@ -1560,8 +1560,8 @@ impl InvocationCollectorNode for ast::Crate {
|
|||
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
|
||||
fragment.make_crate()
|
||||
}
|
||||
fn noop_visit<V: MutVisitor>(&mut self, visitor: &mut V) {
|
||||
noop_visit_crate(self, visitor)
|
||||
fn walk<V: MutVisitor>(&mut self, visitor: &mut V) {
|
||||
walk_crate(self, visitor)
|
||||
}
|
||||
fn expand_cfg_false(
|
||||
&mut self,
|
||||
|
@ -1586,8 +1586,8 @@ impl InvocationCollectorNode for P<ast::Ty> {
|
|||
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
|
||||
fragment.make_ty()
|
||||
}
|
||||
fn noop_visit<V: MutVisitor>(&mut self, visitor: &mut V) {
|
||||
noop_visit_ty(self, visitor)
|
||||
fn walk<V: MutVisitor>(&mut self, visitor: &mut V) {
|
||||
walk_ty(self, visitor)
|
||||
}
|
||||
fn is_mac_call(&self) -> bool {
|
||||
matches!(self.kind, ast::TyKind::MacCall(..))
|
||||
|
@ -1610,8 +1610,8 @@ impl InvocationCollectorNode for P<ast::Pat> {
|
|||
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
|
||||
fragment.make_pat()
|
||||
}
|
||||
fn noop_visit<V: MutVisitor>(&mut self, visitor: &mut V) {
|
||||
noop_visit_pat(self, visitor)
|
||||
fn walk<V: MutVisitor>(&mut self, visitor: &mut V) {
|
||||
walk_pat(self, visitor)
|
||||
}
|
||||
fn is_mac_call(&self) -> bool {
|
||||
matches!(self.kind, PatKind::MacCall(..))
|
||||
|
@ -1638,8 +1638,8 @@ impl InvocationCollectorNode for P<ast::Expr> {
|
|||
fn descr() -> &'static str {
|
||||
"an expression"
|
||||
}
|
||||
fn noop_visit<V: MutVisitor>(&mut self, visitor: &mut V) {
|
||||
noop_visit_expr(self, visitor)
|
||||
fn walk<V: MutVisitor>(&mut self, visitor: &mut V) {
|
||||
walk_expr(self, visitor)
|
||||
}
|
||||
fn is_mac_call(&self) -> bool {
|
||||
matches!(self.kind, ExprKind::MacCall(..))
|
||||
|
@ -1664,8 +1664,8 @@ impl InvocationCollectorNode for AstNodeWrapper<P<ast::Expr>, OptExprTag> {
|
|||
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
|
||||
fragment.make_opt_expr()
|
||||
}
|
||||
fn noop_flat_map<V: MutVisitor>(mut self, visitor: &mut V) -> Self::OutputTy {
|
||||
noop_visit_expr(&mut self.wrapped, visitor);
|
||||
fn walk_flat_map<V: MutVisitor>(mut self, visitor: &mut V) -> Self::OutputTy {
|
||||
walk_expr(&mut self.wrapped, visitor);
|
||||
Some(self.wrapped)
|
||||
}
|
||||
fn is_mac_call(&self) -> bool {
|
||||
|
@ -1704,8 +1704,8 @@ impl InvocationCollectorNode for AstNodeWrapper<P<ast::Expr>, MethodReceiverTag>
|
|||
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
|
||||
AstNodeWrapper::new(fragment.make_method_receiver_expr(), MethodReceiverTag)
|
||||
}
|
||||
fn noop_visit<V: MutVisitor>(&mut self, visitor: &mut V) {
|
||||
noop_visit_expr(&mut self.wrapped, visitor)
|
||||
fn walk<V: MutVisitor>(&mut self, visitor: &mut V) {
|
||||
walk_expr(&mut self.wrapped, visitor)
|
||||
}
|
||||
fn is_mac_call(&self) -> bool {
|
||||
matches!(self.wrapped.kind, ast::ExprKind::MacCall(..))
|
||||
|
@ -2015,12 +2015,12 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
|
|||
);
|
||||
Node::flatten_outputs(single_delegations.map(|item| {
|
||||
let mut item = Node::from_item(item);
|
||||
assign_id!(self, item.node_id_mut(), || item.noop_flat_map(self))
|
||||
assign_id!(self, item.node_id_mut(), || item.walk_flat_map(self))
|
||||
}))
|
||||
}
|
||||
None => {
|
||||
match Node::wrap_flat_map_node_noop_flat_map(node, self, |mut node, this| {
|
||||
assign_id!(this, node.node_id_mut(), || node.noop_flat_map(this))
|
||||
match Node::wrap_flat_map_node_walk_flat_map(node, self, |mut node, this| {
|
||||
assign_id!(this, node.node_id_mut(), || node.walk_flat_map(this))
|
||||
}) {
|
||||
Ok(output) => output,
|
||||
Err(returned_node) => {
|
||||
|
@ -2068,7 +2068,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
|
|||
}
|
||||
None if node.delegation().is_some() => unreachable!(),
|
||||
None => {
|
||||
assign_id!(self, node.node_id_mut(), || node.noop_visit(self))
|
||||
assign_id!(self, node.node_id_mut(), || node.walk(self))
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -2147,11 +2147,11 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
|
|||
self.cx.current_expansion.is_trailing_mac = true;
|
||||
// Don't use `assign_id` for this statement - it may get removed
|
||||
// entirely due to a `#[cfg]` on the contained expression
|
||||
let res = noop_flat_map_stmt(node, self);
|
||||
let res = walk_flat_map_stmt(node, self);
|
||||
self.cx.current_expansion.is_trailing_mac = false;
|
||||
res
|
||||
}
|
||||
_ => noop_flat_map_stmt(node, self),
|
||||
_ => walk_flat_map_stmt(node, self),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -2195,7 +2195,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
|
|||
&mut self.cx.current_expansion.dir_ownership,
|
||||
DirOwnership::UnownedViaBlock,
|
||||
);
|
||||
noop_visit_block(node, self);
|
||||
walk_block(node, self);
|
||||
self.cx.current_expansion.dir_ownership = orig_dir_ownership;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue