blob: 7ec9d2e1fd3ac5d403e52eff99bd883da147786a [file] [log] [blame]
David Tolnay4b4c4b62018-01-06 13:48:05 -08001//! This crate automatically generates the definition of the `Visit`,
2//! `VisitMut`, and `Fold` traits in `syn` based on the `syn` source. It
Nika Layzell27726662017-10-24 23:16:35 -04003//! discovers structs and enums declared with the `ast_*` macros and generates
4//! the functions for those types.
5//!
6//! It makes a few assumptions about the target crate:
7//! 1. All structs which are discovered must be re-exported in the root of the
8//! crate, even if they were declared in a submodule.
9//! 2. This code cannot discover submodules which are located in subdirectories
10//! - only submodules located in the same directory.
11//! 3. The path to `syn` is hardcoded.
12
David Tolnay6af48992018-08-01 11:16:28 -070013#![recursion_limit = "128"]
David Tolnayc1f55792018-11-21 01:39:42 -080014#![allow(clippy::needless_pass_by_value)]
David Tolnayea9ae892017-12-26 01:44:32 -050015
David Tolnay14d463e2019-02-15 14:23:51 -080016extern crate indexmap;
Nika Layzell27726662017-10-24 23:16:35 -040017extern crate inflections;
David Tolnay2e0dba12017-12-27 01:54:40 -050018extern crate proc_macro2;
David Tolnayd67fb752017-12-27 13:50:29 -050019#[macro_use]
20extern crate quote;
David Tolnay8c81f622018-07-31 23:34:35 -070021extern crate rustfmt_nightly as rustfmt;
Carl Lerche058ff472019-02-13 16:23:52 -080022#[macro_use]
David Tolnay5f794802018-11-24 14:51:21 -080023extern crate syn;
Carl Lerche9a7d5882019-02-15 12:27:04 -080024extern crate serde;
25#[macro_use]
26extern crate serde_derive;
27extern crate serde_json;
28extern crate toml;
Nika Layzell27726662017-10-24 23:16:35 -040029
Carl Lerche058ff472019-02-13 16:23:52 -080030mod gen;
Carl Lerche9a7d5882019-02-15 12:27:04 -080031mod json;
Carl Lerche058ff472019-02-13 16:23:52 -080032mod parse;
33mod types;
David Tolnay8c81f622018-07-31 23:34:35 -070034
Nika Layzell27726662017-10-24 23:16:35 -040035fn main() {
Carl Lerche058ff472019-02-13 16:23:52 -080036 let types = parse::parse();
37 gen::generate(&types);
Carl Lerche9a7d5882019-02-15 12:27:04 -080038 json::generate(&types);
Nika Layzell27726662017-10-24 23:16:35 -040039}