Skip to content

Allow for missing modules #5962

Not planned
Not planned
@abrisco

Description

@abrisco

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

ytmimi

ytmimi commented on Nov 12, 2023

@ytmimi
Contributor

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 only main.rs would be formatted. if you ran

rustfmt ./src/main.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ytmimi@abrisco

        Issue actions

          Allow for missing modules · Issue #5962 · rust-lang/rustfmt