Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch Rust codegen to use new ModuleDef #1675

Merged
merged 2 commits into from
Sep 17, 2024

Conversation

coolreader18
Copy link
Collaborator

Description of Changes

Based on #1661. The way I did this also allows for incremental porting of the typescript & csharp codegens - obviously it should happen soon, but this is nice cause it allows avoiding conflicts (unless Ingvar's already started working on the csharp one).

Expected complexity level and risk

2

Testing

Snapshot tests all pass.

@coolreader18 coolreader18 force-pushed the noa/rust-codegen-typespace_for_generate branch from d8d1485 to dfe601f Compare September 5, 2024 16:56
@coolreader18 coolreader18 force-pushed the noa/rust-codegen-typespace_for_generate branch 3 times, most recently from 0da5569 to 2dffb7c Compare September 5, 2024 21:25
@coolreader18 coolreader18 force-pushed the noa/rust-codegen-typespace_for_generate branch from 2dffb7c to f6d2e77 Compare September 16, 2024 16:58
@coolreader18 coolreader18 marked this pull request as ready for review September 16, 2024 16:58
@bfops bfops added the release-any To be landed in any release window label Sep 16, 2024
@coolreader18 coolreader18 force-pushed the noa/rust-codegen-typespace_for_generate branch from f6d2e77 to 7a3fe5d Compare September 17, 2024 16:17
Copy link
Contributor

@kazimuth kazimuth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nits otherwise I'm happy with this. I'm less familiar with how the codegen works in the nitty gritty but everything here makes sense to me.


Ok(files)
pub fn generate(module: RawModuleDef, lang: Language, namespace: &str) -> anyhow::Result<Vec<(String, String)>> {
let module = match module {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this whole function looks good, this was exactly the structure I thought would make sense here while we port

}
write_type(ctx, out, &elem.algebraic_type)
})?;
AlgebraicTypeUse::Unit => write!(out, "()")?,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy with this patch :)

extract_descriptions(module.path()).expect("failed to extract module descriptions");
let RawModuleDef::V8BackCompat(raw_module_def) = raw_module_def else {
panic!("no more v8")
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So both C# and rust are patched to produce v9 now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, not yet - the panic!() will happen when v8 is no longer being produced.

crates/schema/src/type_for_generate.rs Show resolved Hide resolved
crates/cli/src/subcommands/generate/rust.rs Outdated Show resolved Hide resolved
@coolreader18 coolreader18 added this pull request to the merge queue Sep 17, 2024
Merged via the queue into master with commit f6bc6dc Sep 17, 2024
8 checks passed
@coolreader18 coolreader18 deleted the noa/rust-codegen-typespace_for_generate branch September 17, 2024 18:56
@RReverser RReverser mentioned this pull request Sep 18, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-any To be landed in any release window
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants