Skip to content

Modules with path don't formated on Windows #1754

Closed
@EPashkin

Description

@EPashkin

This crate with build script, that use file from src

>cargo new fmt_bug
>cd fmt_bug
>cat build.rs
#[path = "src/consts.rs"]
mod consts;

fn main() {
    println!("VERSION:{}", consts::VERSION);
}

>cat src/consts.rs
pub const VERSION: &'static str = "1dd0028";

produce this error on Windows + MSys2:

D:\eap\rust\0_test\fmt_bug>cargo fmt
error: couldn't read "\\\\?\\D:\\eap\\rust\\0_test\\fmt_bug\\src/consts.rs": Syntax error in file name, folder name, or volume label.
(os error 123)
 --> \\?\D:\eap\rust\0_test\fmt_bug\build.rs:2:5
  |
2 | mod consts;
  |     ^^^^^^

thread 'main' panicked at 'Box<Any>', src\libsyntax\parse\mod.rs:207
stack backtrace:
   0: mingw_set_invalid_parameter_handler
   1: mingw_set_invalid_parameter_handler
   2: mingw_set_invalid_parameter_handler
   3: mingw_set_invalid_parameter_handler
   4: mingw_set_invalid_parameter_handler
   5: mingw_set_invalid_parameter_handler
   6: mingw_set_invalid_parameter_handler
   7: mingw_set_invalid_parameter_handler
   8: mingw_set_invalid_parameter_handler
   9: mingw_set_invalid_parameter_handler
  10: mingw_set_invalid_parameter_handler
  11: mingw_set_invalid_parameter_handler
  12: rustfmt_nightly::parse_input
  13: rustfmt_nightly::run
  14: rustfmt::execute
  15: rustfmt::main
  16: mingw_set_invalid_parameter_handler
  17: mingw_set_invalid_parameter_handler
  18: _tmainCRTStartup
  19: mainCRTStartup
  20: mingw_set_invalid_parameter_handler

Versions:

>cargo -Vv
cargo 0.21.0-nightly (e53e2f8d5 2017-06-17)
release: 0.21.0
commit-hash: e53e2f8d5b7f7751dd478fff68c1dbe7247cb096
commit-date: 2017-06-17

>rustc -Vv
rustc 1.20.0-nightly (445077963 2017-06-20)
binary: rustc
commit-hash: 445077963c55297ef1e196a3525723090fe80b22
commit-date: 2017-06-20
host: x86_64-pc-windows-gnu
release: 1.20.0-nightly
LLVM version: 4.0

>rustfmt -Vv
0.1.5-nightly ( )

EDIT: translated error message from Russian.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugPanic, non-idempotency, invalid code, etc.os-windowsp-medium

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions