bazelbuild / bazelbuild/rules_rust
Rustfmt `ignore` causes panic
- Dominant language
- Starlark
- Stars
- 843
- Forks
- 651
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 15
Description
I am trying to use rustfmt's [ignore](https://rust-lang.github.io/rustfmt/?version=v1.5.1&search=#ignore) configuration option to ignore some generated files, but doing so causes a panic:
```
RUST_BACKTRACE=1 bazel run //:rustfmt
INFO: Analyzed target //:rustfmt (23 packages loaded, 268 targets configured).
INFO: Found 1 target...
INFO: From BazelWorkspaceStatusAction stable-status.txt:
Target @rules_rust//tools/rustfmt:rustfmt up-to-date:
bazel-bin/external/rules_rust/tools/rustfmt/rustfmt
INFO: Elapsed time: 2.638s, Critical Path: 0.08s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/external/rules_rust/tools/rustfmt/rustfmt
Loading: 0 packages loaded
INFO: Empty results
Loading: 930 packages loaded
Loading: 0 packages loaded
INFO: Empty results
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 92 packages loaded
Loading: 0 packages loaded
Loading: 8 packages loaded
thread 'main' panicked at 'path is expected to be under the root', /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ignore-0.4.18/src/gitignore.rs:227:9
stack backtrace:
0: std::panicking::begin_panic::<&str>
1: ::matched_path_or_any_parents::<&std::path::PathBuf>
2: ::ignore_file
3: <&mut rustfmt_nightly::formatting::format_project>::{closure#1} as core::ops::function::FnMut<(&(rustfmt_nightly::config::file_lines::FileName, rustfmt_nightly::modules::Module),)>>::call_mut
4: , rustfmt_nightly::formatting::format_project>::{closure#1}> as core::iter::traits::iterator::Iterator>::next
5: as alloc::vec::spec_from_iter::SpecFromIter<(rustfmt_nightly::config::file_lines::FileName, rustfmt_nightly::modules::Module), core::iter::adapters::filter::Filter, rustfmt_nightly::formatting::format_project>::{closure#1}>>>::from_iter
6: rustfmt_nightly::formatting::format_project::>
7: >::with::<>::format_input_inner::{closure#0}, core::result::Result>
8: >::format_input_inner
9: rustfmt::format_and_emit_report::
10: rustfmt::execute
11: rustfmt::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
```
This happens both when trying to ignore a directory or a specific files. The same configuration works with `cargo +nightly fmt`.
Contributor guide
Assessment
This issue has not been assessed yet.