bazelbuild / bazelbuild/rules_rust

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

Open
#3,711 2 comments 0 reactions 0 assignees View on GitHub
awaiting-response rustfmt
Dominant language
Starlark
Stars
843
Forks
651
Avg merge
2d 18h
Merged PRs (30d)
15

Description

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.