Use <stdin> when emitting stdin as filename (#4298)

# Conflicts:
#	src/config/file_lines.rs
#	src/rustfmt/main.rs
#	src/test/mod.rs
This commit is contained in:
Seiichi Uchida 2020-07-03 11:13:16 +09:00 committed by Caleb Cartwright
parent 894a3c0e77
commit 34d374ee5d
4 changed files with 7 additions and 7 deletions

View file

@ -39,7 +39,7 @@ impl fmt::Display for FileName {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
FileName::Real(p) => write!(f, "{}", p.to_str().unwrap()),
FileName::Stdin => write!(f, "stdin"),
FileName::Stdin => write!(f, "<stdin>"),
}
}
}

View file

@ -466,9 +466,9 @@ fn stdin_formatting_smoke_test() {
}
#[cfg(not(windows))]
assert_eq!(buf, "stdin:\n\nfn main() {}\n".as_bytes());
assert_eq!(buf, "<stdin>:\n\nfn main() {}\n".as_bytes());
#[cfg(windows)]
assert_eq!(buf, "stdin:\n\nfn main() {}\r\n".as_bytes());
assert_eq!(buf, "<stdin>:\n\nfn main() {}\r\n".as_bytes());
}
#[test]
@ -1013,5 +1013,5 @@ fn verify_check_l_works_with_stdin() {
.wait_with_output()
.expect("Failed to wait on rustfmt child");
assert!(output.status.success());
assert_eq!(std::str::from_utf8(&output.stdout).unwrap(), "stdin\n");
assert_eq!(std::str::from_utf8(&output.stdout).unwrap(), "<stdin>\n");
}

View file

@ -1 +1 @@
[{"name":"stdin","mismatches":[{"original_begin_line":1,"original_end_line":6,"expected_begin_line":1,"expected_end_line":2,"original":"\nfn\n some( )\n{\n}\nfn main () {}\n","expected":"fn some() {}\nfn main() {}\n"}]}]
[{"name":"<stdin>","mismatches":[{"original_begin_line":1,"original_end_line":6,"expected_begin_line":1,"expected_end_line":2,"original":"\nfn\n some( )\n{\n}\nfn main () {}\n","expected":"fn some() {}\nfn main() {}\n"}]}]

View file

@ -1,2 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<checkstyle version="4.3"><file name="stdin"><error line="1" severity="warning" message="Should be `fn some() {}`" /><error line="2" severity="warning" message="Should be `fn main() {}`" /></file></checkstyle>
<?xml version="1.0" encoding="utf-8"?>
<checkstyle version="4.3"><file name="<stdin>"><error line="1" severity="warning" message="Should be `fn some() {}`" /><error line="2" severity="warning" message="Should be `fn main() {}`" /></file></checkstyle>