-
Notifications
You must be signed in to change notification settings - Fork 281
transpile: Run rustfmt on generated .rs files
#1458
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -620,6 +620,8 @@ fn transpile_single( | |
| ), | ||
| }; | ||
|
|
||
| rustfmt(&output_path, build_dir); | ||
|
|
||
| Ok((output_path, pragmas, crates)) | ||
| } | ||
|
|
||
|
|
@@ -667,3 +669,17 @@ fn get_output_path( | |
| input_path | ||
| } | ||
| } | ||
|
|
||
| fn rustfmt(output_path: &Path, build_dir: &Path) { | ||
| let edition = "2021"; | ||
|
|
||
| let status = Command::new("rustfmt") | ||
| .args(["--edition", edition]) | ||
| .arg(output_path) | ||
| .current_dir(build_dir) | ||
| .status(); | ||
|
|
||
| if !status.map_or(false, |status| status.success()) { | ||
| warn!("rustfmt failed, code may not be well-formatted"); | ||
| } | ||
|
Comment on lines
+682
to
+684
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we handle these errors differently? The command will fail if Also, if we're calling
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think a panic is appropriate, as this is just an extra convenience for the user and not a hard requirement of the transpilation process. The transpilation should still succeed if |
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.