Skip to content

Commit 4b4c4b6

Browse files
committed
Briefer ast traversal trait names
1 parent 9f231e6 commit 4b4c4b6

File tree

6 files changed

+612
-612
lines changed

6 files changed

+612
-612
lines changed

codegen/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
This is an internal (not published on crates.io) crate which is used to generate
44
the files in the `gen/` directory of `syn`. It is used to ensure that the
5-
implementations for `Folder`, `Visitor`, and `VisitorMut` remain in sync with
6-
the actual AST.
5+
implementations for `Fold`, `Visit`, and `VisitMut` remain in sync with the
6+
actual AST.
77

88
To run this program, run `cargo run` in this directory, and the `gen/` folder
99
will be re-generated.

codegen/src/main.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//! This crate automatically generates the definition of the `Visitor`,
2-
//! `VisitorMut`, and `Folder` traits in `syn` based on the `syn` source. It
1+
//! This crate automatically generates the definition of the `Visit`,
2+
//! `VisitMut`, and `Fold` traits in `syn` based on the `syn` source. It
33
//! discovers structs and enums declared with the `ast_*` macros and generates
44
//! the functions for those types.
55
//!
@@ -727,15 +727,15 @@ mod codegen {
727727

728728
state.visit_impl.push_str(&format!(
729729
"{features}\n\
730-
pub fn visit_{under_name}<'ast, V: Visitor<'ast> + ?Sized>(\
730+
pub fn visit_{under_name}<'ast, V: Visit<'ast> + ?Sized>(\
731731
_visitor: &mut V, _i: &'ast {ty}) {{\n",
732732
features = s.features,
733733
under_name = under_name,
734734
ty = s.ast.ident,
735735
));
736736
state.visit_mut_impl.push_str(&format!(
737737
"{features}\n\
738-
pub fn visit_{under_name}_mut<V: VisitorMut + ?Sized>(\
738+
pub fn visit_{under_name}_mut<V: VisitMut + ?Sized>(\
739739
_visitor: &mut V, _i: &mut {ty}) {{\n",
740740
features = s.features,
741741
under_name = under_name,
@@ -744,7 +744,7 @@ mod codegen {
744744
let before_fold_impl_len = state.fold_impl.len();
745745
state.fold_impl.push_str(&format!(
746746
"{features}\n\
747-
pub fn fold_{under_name}<V: Folder + ?Sized>(\
747+
pub fn fold_{under_name}<V: Fold + ?Sized>(\
748748
_visitor: &mut V, _i: {ty}) -> {ty} {{\n",
749749
features = s.features,
750750
under_name = under_name,
@@ -1006,7 +1006,7 @@ macro_rules! full {
10061006
"\
10071007
// THIS FILE IS AUTOMATICALLY GENERATED; DO NOT EDIT
10081008
1009-
//! A Folder represents an AST->AST fold; it accepts an AST piece,
1009+
//! A Fold represents an AST->AST fold; it accepts an AST piece,
10101010
//! and returns a piece of the same type.
10111011
10121012
#![cfg_attr(rustfmt, rustfmt_skip)]
@@ -1026,23 +1026,23 @@ use gen::helper::fold::*;
10261026
10271027
/// AST->AST fold.
10281028
///
1029-
/// Each method of the Folder trait is a hook to be potentially overridden. Each
1029+
/// Each method of the Fold trait is a hook to be potentially overridden. Each
10301030
/// method's default implementation recursively visits the substructure of the
10311031
/// input via the `walk` functions, which perform an \"identity fold\", that
10321032
/// is, they return the same structure that they are given (for example the
10331033
/// `fold_file` method by default calls `fold::walk_file`).
10341034
///
10351035
/// If you want to ensure that your code handles every variant
10361036
/// explicitly, you need to override each method. (And you also need
1037-
/// to monitor future changes to `Folder` in case a new method with a
1037+
/// to monitor future changes to `Fold` in case a new method with a
10381038
/// new default implementation gets introduced.)
1039-
pub trait Folder {{
1039+
pub trait Fold {{
10401040
{fold_trait}
10411041
}}
10421042
10431043
macro_rules! fold_span_only {{
10441044
($f:ident : $t:ident) => {{
1045-
pub fn $f<V: Folder + ?Sized>(_visitor: &mut V, mut _i: $t) -> $t {{
1045+
pub fn $f<V: Fold + ?Sized>(_visitor: &mut V, mut _i: $t) -> $t {{
10461046
_i.span = _visitor.fold_span(_i.span);
10471047
_i
10481048
}}
@@ -1096,16 +1096,16 @@ use gen::helper::visit::*;
10961096
10971097
{full_macro}
10981098
1099-
/// Each method of the Visitor trait is a hook to be potentially
1099+
/// Each method of the Visit trait is a hook to be potentially
11001100
/// overridden. Each method's default implementation recursively visits
11011101
/// the substructure of the input via the corresponding `walk` method;
11021102
/// e.g. the `visit_mod` method by default calls `visit::walk_mod`.
11031103
///
11041104
/// If you want to ensure that your code handles every variant
11051105
/// explicitly, you need to override each method. (And you also need
1106-
/// to monitor future changes to `Visitor` in case a new method with a
1106+
/// to monitor future changes to `Visit` in case a new method with a
11071107
/// new default implementation gets introduced.)
1108-
pub trait Visitor<'ast> {{
1108+
pub trait Visit<'ast> {{
11091109
{visit_trait}
11101110
}}
11111111
@@ -1140,16 +1140,16 @@ use gen::helper::visit_mut::*;
11401140
11411141
{full_macro}
11421142
1143-
/// Each method of the VisitorMut trait is a hook to be potentially
1143+
/// Each method of the VisitMut trait is a hook to be potentially
11441144
/// overridden. Each method's default implementation recursively visits
11451145
/// the substructure of the input via the corresponding `walk` method;
11461146
/// e.g. the `visit_mod` method by default calls `visit::walk_mod`.
11471147
///
11481148
/// If you want to ensure that your code handles every variant
11491149
/// explicitly, you need to override each method. (And you also need
1150-
/// to monitor future changes to `VisitorMut` in case a new method with a
1150+
/// to monitor future changes to `VisitMut` in case a new method with a
11511151
/// new default implementation gets introduced.)
1152-
pub trait VisitorMut {{
1152+
pub trait VisitMut {{
11531153
{visit_mut_trait}
11541154
}}
11551155

0 commit comments

Comments
 (0)