Not planned
Description
I have a crate that uses some generated source code that fails whenever I run rustfmt before generating it with the following error
~/Code/rustfmthing (main ✗) rustfmt ./src/main.rs
Error writing files: failed to resolve mod `generated`: /Users/abrisco/Code/rustfmthing/src/generated.rs does not exist
The source file looks like this:
mod generated;
pub fn main() {
generated::greeting();
}
Is there a way to have rustfmt not attempt to resolve modules and instead simply format the file I passed?
Activity
@rules_rust//:rustfmt
tool fails on crates with generated sources bazelbuild/rules_rust#2254ytmimi commentedon Nov 12, 2023
Thanks for reaching out. This is a similar request to #5609, and #5611 was opened to provide an option to ignore missing submodules.
You can subscribe to the PR to be notified when the team has a chance to revisit those proposed changes.
You could also use
skip_children=true
and rustfmt won't try to resolve any submodules. So in your example above onlymain.rs
would be formatted. if you ran