Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion tasks/ast_tools/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ impl From<(PathBuf, TokenStream)> for SideEffect {

impl From<GeneratorOutput> for SideEffect {
fn from(output: GeneratorOutput) -> Self {
Self::from((output.path, output.tokens))
match output {
GeneratorOutput::Rust { path, tokens } => Self::from((path, tokens)),
GeneratorOutput::Text { path, content } => Self { path, content: content.into() },
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion tasks/ast_tools/src/generators/assert_layouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl Generator for AssertLayouts {

let header = generated_header!();

GeneratorOutput {
GeneratorOutput::Rust {
path: output(crate::AST_CRATE, "assert_layouts.rs"),
tokens: quote! {
#header
Expand Down
2 changes: 1 addition & 1 deletion tasks/ast_tools/src/generators/ast_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl Generator for AstBuilderGenerator {

let header = generated_header!();

GeneratorOutput {
GeneratorOutput::Rust {
path: output(crate::AST_CRATE, "ast_builder.rs"),
tokens: quote! {
#header
Expand Down
2 changes: 1 addition & 1 deletion tasks/ast_tools/src/generators/ast_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ impl Generator for AstKindGenerator {

let header = generated_header!();

GeneratorOutput {
GeneratorOutput::Rust {
path: output(crate::AST_CRATE, "ast_kind.rs"),
tokens: quote! {
#header
Expand Down
13 changes: 10 additions & 3 deletions tasks/ast_tools/src/generators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,16 @@ pub trait Generator {
}

#[derive(Debug, Clone)]
pub struct GeneratorOutput {
pub path: PathBuf,
pub tokens: TokenStream,
pub enum GeneratorOutput {
Rust {
path: PathBuf,
tokens: TokenStream,
},
#[expect(dead_code)]
Text {
path: PathBuf,
content: String,
},
}

macro_rules! define_generator {
Expand Down
4 changes: 2 additions & 2 deletions tasks/ast_tools/src/generators/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ define_generator! {

impl Generator for VisitGenerator {
fn generate(&mut self, ctx: &LateCtx) -> GeneratorOutput {
GeneratorOutput {
GeneratorOutput::Rust {
path: output(crate::AST_CRATE, "visit.rs"),
tokens: generate_visit::<false>(ctx),
}
Expand All @@ -37,7 +37,7 @@ impl Generator for VisitGenerator {

impl Generator for VisitMutGenerator {
fn generate(&mut self, ctx: &LateCtx) -> GeneratorOutput {
GeneratorOutput {
GeneratorOutput::Rust {
path: output(crate::AST_CRATE, "visit_mut.rs"),
tokens: generate_visit::<true>(ctx),
}
Expand Down