Skip to content

rustfmt crashes with ignore on Windows #6178

@danakj

Description

@danakj

Using nightly rust:

PS C:\src\test> C:\src\c\src\third_party\rust-toolchain\bin\rustfmt.exe --version
rustfmt 1.7.0-dev (27eb5e46111 2024-05-14)

My directory layout:

PS C:\src\test> ls


    Directory: C:\src\test


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         5/30/2024  12:45 PM                foo
-a----         5/30/2024  12:45 PM             22 .rustfmt.toml
-a----         5/30/2024  12:47 PM              0 ffi.rs

The foo directory is empty. The bug occurs with or without it being present. The ffi.rs file is empty, its contents are not relevant.

My .rustfmt.toml:

ignore = [
  "foo",
]

Panic when running rustfmt:

PS C:\src\test> C:\src\c\src\third_party\rust-toolchain\bin\rustfmt.exe --config-path=.rustfmt.toml ffi.rs
thread 'main' panicked at C:\b\s\w\ir\cache\builder\src\third_party\rust-src\cargo-home\registry\src\index.crates.io-6f17d22bba15001f\ignore-0.4.20\src\gitignore.rs:227:9:
path is expected to be under the root
stack backtrace:
   0:     0x7ffa0c14dd4b - std::backtrace_rs::backtrace::trace_unsynchronized::h5f93b2abd0db91f0
   1:     0x7ffa0c133607 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hce6ce78ac92839e4
   2:     0x7ffa0c165849 - core::fmt::write::ha5fb765460c424ba
   3:     0x7ffa0c13e1b2 - std::io::Write::write_fmt::habae0783318d8fea
   4:     0x7ffa0c1333b6 - std::sys_common::backtrace::lock::hb3e74337ee21512b
   5:     0x7ffa0c134a36 - std::panicking::default_hook::h7607b7ddd5c7b6ec
   6:     0x7ffa0c134695 - std::panicking::default_hook::h7607b7ddd5c7b6ec
   7:     0x7ffa032f19bd - RNvXsM_NtCs3lievmH1lCy_5alloc5boxedINtB5_3BoxNCNvCsb1rAIG9dYoS_17rustc_driver_impl16install_ice_hook0EINtNtNtCs5nNRtGYlUPI_4core3ops8function2FnTRDG0_IB1D_TRL1_INtNtNtB1J_5panic10panic_info9PanicInfoL0_EEEp6OutputuNtNtB1J_6marker4SendNtB3s_4SyncEL_RB2z_EE
   8:     0x7ffa0c135697 - std::panicking::rust_panic_with_hook::haf133a654d379e78
   9:     0x7ff6ebefe31e - <unknown>
  10:     0x7ff6ebefd9a9 - <unknown>
  11:     0x7ff6ec1c02dd - <unknown>
  12:     0x7ff6ebf15f50 - <unknown>
  13:     0x7ff6ebf131cd - <unknown>
  14:     0x7ff6ebe35662 - <unknown>
  15:     0x7ff6ebe0ada3 - <unknown>
  16:     0x7ff6ebe339c3 - <unknown>
  17:     0x7ff6ebe2c4b5 - <unknown>
  18:     0x7ff6ebe29b43 - <unknown>
  19:     0x7ff6ebe37585 - <unknown>
  20:     0x7ff6ebe1b7d3 - <unknown>
  21:     0x7ff6ebe1957c - <unknown>
  22:     0x7ff6ebe17046 - <unknown>
  23:     0x7ff6ebe3a046 - <unknown>
  24:     0x7ff6ebe36a8c - <unknown>
  25:     0x7ffa0c134dce - std::panicking::try::h55cdbfa07f843c24
  26:     0x7ffa0c145d1e - std::rt::lang_start_internal::ha0abe746fee78982
  27:     0x7ff6ebe1c6dc - <unknown>
  28:     0x7ff6ec1a51c0 - <unknown>
  29:     0x7ffa5c877344 - BaseThreadInitThunk
  30:     0x7ffa5d0626b1 - RtlUserThreadStart

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rustfmt/issues/new?labels=bug

note: please make sure that you have updated to the latest nightly

There is no such problem on Linux.

The assertion failing is here: https://github.com/BurntSushi/ripgrep/blob/fe97c0a152cabc1bc07ec36b4b1e27cd230c3014/crates/ignore/src/gitignore.rs#L227

Chromium bug for cross-linking: https://crbug.com/40248903

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

    Issue actions