mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Ignore line-endings when checking generated files for freshness
closes #2184
This commit is contained in:
parent
4fbb36db9b
commit
5efd99a6e0
1 changed files with 6 additions and 2 deletions
|
@ -46,7 +46,7 @@ pub enum Mode {
|
||||||
/// With verify = false,
|
/// With verify = false,
|
||||||
fn update(path: &Path, contents: &str, mode: Mode) -> Result<()> {
|
fn update(path: &Path, contents: &str, mode: Mode) -> Result<()> {
|
||||||
match fs::read_to_string(path) {
|
match fs::read_to_string(path) {
|
||||||
Ok(ref old_contents) if old_contents == contents => {
|
Ok(ref old_contents) if normalize(old_contents) == normalize(contents) => {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
|
@ -56,7 +56,11 @@ fn update(path: &Path, contents: &str, mode: Mode) -> Result<()> {
|
||||||
}
|
}
|
||||||
eprintln!("updating {}", path.display());
|
eprintln!("updating {}", path.display());
|
||||||
fs::write(path, contents)?;
|
fs::write(path, contents)?;
|
||||||
Ok(())
|
return Ok(());
|
||||||
|
|
||||||
|
fn normalize(s: &str) -> String {
|
||||||
|
s.replace("\r\n", "\n")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reformat(text: impl std::fmt::Display) -> Result<String> {
|
fn reformat(text: impl std::fmt::Display) -> Result<String> {
|
||||||
|
|
Loading…
Reference in a new issue