From 7517a4f882083a46593417560cdd19c10c3fc5cf Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Thu, 25 Apr 2024 22:50:06 +0300 Subject: [PATCH] ast: Visit item components in "natural" order --- compiler/rustc_ast/src/mut_visit.rs | 6 +++--- compiler/rustc_ast/src/visit.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index 2ff8098035d75..fc445600e77b9 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -1248,11 +1248,11 @@ pub fn noop_flat_map_item( visitor: &mut impl MutVisitor, ) -> SmallVec<[P>; 1]> { let Item { ident, attrs, id, kind, vis, span, tokens } = item.deref_mut(); - visitor.visit_ident(ident); - visit_attrs(attrs, visitor); visitor.visit_id(id); - kind.noop_visit(visitor); + visit_attrs(attrs, visitor); visitor.visit_vis(vis); + visitor.visit_ident(ident); + kind.noop_visit(visitor); visitor.visit_span(span); visit_lazy_tts(tokens, visitor); smallvec![item] diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs index c4a7c8a4540a2..a0ada9a7788d7 100644 --- a/compiler/rustc_ast/src/visit.rs +++ b/compiler/rustc_ast/src/visit.rs @@ -826,9 +826,9 @@ pub fn walk_assoc_item<'a, V: Visitor<'a>>( ctxt: AssocCtxt, ) -> V::Result { let &Item { id: _, span: _, ident, ref vis, ref attrs, ref kind, tokens: _ } = item; + walk_list!(visitor, visit_attribute, attrs); try_visit!(visitor.visit_vis(vis)); try_visit!(visitor.visit_ident(ident)); - walk_list!(visitor, visit_attribute, attrs); try_visit!(kind.walk(item, ctxt, visitor)); V::Result::output() }