Skip to content

Commit

Permalink
Briefer ast traversal trait names
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jan 6, 2018
1 parent 9f231e6 commit 4b4c4b6
Show file tree
Hide file tree
Showing 6 changed files with 612 additions and 612 deletions.
4 changes: 2 additions & 2 deletions codegen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

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

To run this program, run `cargo run` in this directory, and the `gen/` folder
will be re-generated.
Expand Down
32 changes: 16 additions & 16 deletions codegen/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! This crate automatically generates the definition of the `Visitor`,
//! `VisitorMut`, and `Folder` traits in `syn` based on the `syn` source. It
//! This crate automatically generates the definition of the `Visit`,
//! `VisitMut`, and `Fold` traits in `syn` based on the `syn` source. It
//! discovers structs and enums declared with the `ast_*` macros and generates
//! the functions for those types.
//!
Expand Down Expand Up @@ -727,15 +727,15 @@ mod codegen {

state.visit_impl.push_str(&format!(
"{features}\n\
pub fn visit_{under_name}<'ast, V: Visitor<'ast> + ?Sized>(\
pub fn visit_{under_name}<'ast, V: Visit<'ast> + ?Sized>(\
_visitor: &mut V, _i: &'ast {ty}) {{\n",
features = s.features,
under_name = under_name,
ty = s.ast.ident,
));
state.visit_mut_impl.push_str(&format!(
"{features}\n\
pub fn visit_{under_name}_mut<V: VisitorMut + ?Sized>(\
pub fn visit_{under_name}_mut<V: VisitMut + ?Sized>(\
_visitor: &mut V, _i: &mut {ty}) {{\n",
features = s.features,
under_name = under_name,
Expand All @@ -744,7 +744,7 @@ mod codegen {
let before_fold_impl_len = state.fold_impl.len();
state.fold_impl.push_str(&format!(
"{features}\n\
pub fn fold_{under_name}<V: Folder + ?Sized>(\
pub fn fold_{under_name}<V: Fold + ?Sized>(\
_visitor: &mut V, _i: {ty}) -> {ty} {{\n",
features = s.features,
under_name = under_name,
Expand Down Expand Up @@ -1006,7 +1006,7 @@ macro_rules! full {
"\
// THIS FILE IS AUTOMATICALLY GENERATED; DO NOT EDIT
//! A Folder represents an AST->AST fold; it accepts an AST piece,
//! A Fold represents an AST->AST fold; it accepts an AST piece,
//! and returns a piece of the same type.
#![cfg_attr(rustfmt, rustfmt_skip)]
Expand All @@ -1026,23 +1026,23 @@ use gen::helper::fold::*;
/// AST->AST fold.
///
/// Each method of the Folder trait is a hook to be potentially overridden. Each
/// Each method of the Fold trait is a hook to be potentially overridden. Each
/// method's default implementation recursively visits the substructure of the
/// input via the `walk` functions, which perform an \"identity fold\", that
/// is, they return the same structure that they are given (for example the
/// `fold_file` method by default calls `fold::walk_file`).
///
/// If you want to ensure that your code handles every variant
/// explicitly, you need to override each method. (And you also need
/// to monitor future changes to `Folder` in case a new method with a
/// to monitor future changes to `Fold` in case a new method with a
/// new default implementation gets introduced.)
pub trait Folder {{
pub trait Fold {{
{fold_trait}
}}
macro_rules! fold_span_only {{
($f:ident : $t:ident) => {{
pub fn $f<V: Folder + ?Sized>(_visitor: &mut V, mut _i: $t) -> $t {{
pub fn $f<V: Fold + ?Sized>(_visitor: &mut V, mut _i: $t) -> $t {{
_i.span = _visitor.fold_span(_i.span);
_i
}}
Expand Down Expand Up @@ -1096,16 +1096,16 @@ use gen::helper::visit::*;
{full_macro}
/// Each method of the Visitor trait is a hook to be potentially
/// Each method of the Visit trait is a hook to be potentially
/// overridden. Each method's default implementation recursively visits
/// the substructure of the input via the corresponding `walk` method;
/// e.g. the `visit_mod` method by default calls `visit::walk_mod`.
///
/// If you want to ensure that your code handles every variant
/// explicitly, you need to override each method. (And you also need
/// to monitor future changes to `Visitor` in case a new method with a
/// to monitor future changes to `Visit` in case a new method with a
/// new default implementation gets introduced.)
pub trait Visitor<'ast> {{
pub trait Visit<'ast> {{
{visit_trait}
}}
Expand Down Expand Up @@ -1140,16 +1140,16 @@ use gen::helper::visit_mut::*;
{full_macro}
/// Each method of the VisitorMut trait is a hook to be potentially
/// Each method of the VisitMut trait is a hook to be potentially
/// overridden. Each method's default implementation recursively visits
/// the substructure of the input via the corresponding `walk` method;
/// e.g. the `visit_mod` method by default calls `visit::walk_mod`.
///
/// If you want to ensure that your code handles every variant
/// explicitly, you need to override each method. (And you also need
/// to monitor future changes to `VisitorMut` in case a new method with a
/// to monitor future changes to `VisitMut` in case a new method with a
/// new default implementation gets introduced.)
pub trait VisitorMut {{
pub trait VisitMut {{
{visit_mut_trait}
}}
Expand Down
Loading

0 comments on commit 4b4c4b6

Please sign in to comment.