Skip to content

bazel run @rules_rust//:rustfmt fails on generated files #3711

@rejuvenile

Description

@rejuvenile

In my case, I have IDL which I transform into a rust file via flatbuffer_library_public(). However, it would seem all dependencies are not built before rustfmt runs; it errors out with:

error: couldn't read `/Users/user/project/crate/src/../session_generated.rs`: No such file or directory (os error 2)
  --> /Users/user/crate/common/src/lib.rs:18:1
   |
18 | mod generated;
   | ^^^^^^^^^^^^^^

Error writing files: failed to resolve mod `generated`: /Users/user/project/crate/src/../session_generated.rs does not exist

It is included as follows:

#[cfg(not(cargo_build))]
#[allow(dead_code, unused_imports, unsafe_op_in_unsafe_fn)]
#[path = "../session_generated.rs"]
mod generated;

Normal bazel ops, like build and test, work fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions