#[cfg(windows)]
fn main() {
use common_util::get_version_for_rc;
use std::env;
use winres::{VersionInfo, WindowsResource};
println!("cargo:rerun-if-changed=favicon.ico");
println!("cargo:rerun-if-changed=Cargo.toml"); // rerun when version changed
/*let profile = env::var("PROFILE").unwrap();
if profile == "release"*/ {
let mut res = WindowsResource::new();
res.set_icon("favicon.ico");
let version = get_version_for_rc!();
res.set_version_info(VersionInfo::PRODUCTVERSION, version);
res.set_version_info(VersionInfo::FILEVERSION, version);
res.compile().unwrap();
}
}
#[cfg(not(windows))]
fn main() {}
causes this error:
error[internal]: left behind trailing whitespace
--> \\?\D:\projects\myproject\build.rs:9:9:0
|
9 |
| ^
|
warning: rustfmt has failed to format. See previous 1 errors.
and this formatted file:
#[cfg(windows)]
fn main() {
use common_util::get_version_for_rc;
use std::env;
use winres::{VersionInfo, WindowsResource};
println!("cargo:rerun-if-changed=favicon.ico");
println!("cargo:rerun-if-changed=Cargo.toml"); // rerun when version changed
/*let profile = env::var("PROFILE").unwrap();
if profile == "release"*/
{
let mut res = WindowsResource::new();
res.set_icon("favicon.ico");
let version = get_version_for_rc!();
res.set_version_info(VersionInfo::PRODUCTVERSION, version);
res.set_version_info(VersionInfo::FILEVERSION, version);
res.compile().unwrap();
}
}
#[cfg(not(windows))]
fn main() {}
(I'm invoking it with cargo +nightly fmt.)
Note that there was a new line inserted before the multiline comment, but it's not empty, it contains a TAB character (I'm using tabs for indentation).
This is the trailing whitespace that the error is referring to.
confirming this is still an issue with rustfmt 1.5.1-nightly (5c41baf8 2022-07-14) and I don't need any configuration options besides version=Two to trigger it.
This input file:
causes this error:
and this formatted file:
(I'm invoking it with
cargo +nightly fmt
.) Note that there was a new line inserted before the multiline comment, but it's not empty, it contains a TAB character (I'm using tabs for indentation). This is the trailing whitespace that the error is referring to.My config:
rustfmt version: