mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-13 00:17:15 +00:00
Merge #2188
2188: Ignore line-endings when checking generated files for freshness r=matklad a=matklad Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
d222608a45
1 changed files with 6 additions and 2 deletions
|
@ -46,7 +46,7 @@ pub enum Mode {
|
|||
/// With verify = false,
|
||||
fn update(path: &Path, contents: &str, mode: Mode) -> Result<()> {
|
||||
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(());
|
||||
}
|
||||
_ => (),
|
||||
|
@ -56,7 +56,11 @@ fn update(path: &Path, contents: &str, mode: Mode) -> Result<()> {
|
|||
}
|
||||
eprintln!("updating {}", path.display());
|
||||
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> {
|
||||
|
|
Loading…
Reference in a new issue