Closed
Description
I have a module that has different implementations depending on what the target is. I use #[cfg_attr(..., path = "...")]
to choose the correct implementation.
https://github.com/fitzgen/wee_alloc/blob/master/wee_alloc/src/lib.rs#L237-L246
#[cfg(all(not(unix), not(target_arch = "wasm32")))]
compile_error! {
"There is no `wee_alloc` implementation for this target; want to send a pull request? :)"
}
#[cfg_attr(target_arch = "wasm32",
path = "./imp_wasm32.rs")]
#[cfg_attr(all(unix, not(target_arch = "wasm32")),
path = "./imp_unix.rs")]
mod imp;
rustfmt
seems unable to handle this:
$ cargo fmt --all
error[E0583]: file not found for module `imp`
--> /home/fitzgen/wee_alloc/wee_alloc/src/lib.rs:246:5
|
246 | mod imp;
| ^^^
|
= help: name the file either imp.rs or imp/mod.rs inside the directory "/home/fitzgen/wee_alloc/wee_alloc/src"
I would expect that it would use the host target by default, or otherwise maybe hit the compile_error
or something.
$ cargo fmt --version
0.3.6-nightly (e0e3e22 2018-01-18)
Full Steps to Reproduce
- clone and checkout https://github.com/fitzgen/wee_alloc/blob/b162ed4f33d127d8b00bc38281116e51f50dd2bd
$ cd wee_alloc/
$ cargo fmt --all