Skip to content

Commit cd7d3ff

Browse files
authored
Use <stdin> when emitting stdin as filename (#4298)
2 parents 7159095 + 575a351 commit cd7d3ff

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

Diff for: src/config/file_lines.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl fmt::Display for FileName {
6060
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
6161
match self {
6262
FileName::Real(p) => write!(f, "{}", p.display()),
63-
FileName::Stdin => write!(f, "stdin"),
63+
FileName::Stdin => write!(f, "<stdin>"),
6464
}
6565
}
6666
}

Diff for: src/rustfmt/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ mod test {
708708
.wait_with_output()
709709
.expect("Failed to wait on rustfmt child");
710710
assert!(!output.status.success());
711-
assert_eq!(std::str::from_utf8(&output.stdout).unwrap(), "stdin\n");
711+
assert_eq!(std::str::from_utf8(&output.stdout).unwrap(), "<stdin>\n");
712712
}
713713

714714
#[cfg(nightly)]
@@ -818,7 +818,7 @@ fn foo() {
818818
assert!(output.stdout.is_empty());
819819
let exp_err = vec![
820820
"\u{1b}[1;38;5;9merror\u{1b}[0m: \u{1b}[1minvalid attribute",
821-
"\u{1b}[0m\n \u{1b}[1;38;5;12m-->\u{1b}[0m stdin:2\n",
821+
"\u{1b}[0m\n \u{1b}[1;38;5;12m-->\u{1b}[0m <stdin>:2\n",
822822
"\u{1b}[1;38;5;12m |\u{1b}[0m\n",
823823
"\u{1b}[1;38;5;12m2 |\u{1b}[0m #![rustfmt::max_width(120)]\n",
824824
"\u{1b}[1;38;5;12m |\u{1b}[0m\n\n",

Diff for: src/test/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,9 @@ fn stdin_formatting_smoke_test() {
428428
.unwrap();
429429

430430
#[cfg(not(windows))]
431-
assert_eq!(buf, b"stdin:\n\nfn main() {}\n");
431+
assert_eq!(buf, b"<stdin>:\n\nfn main() {}\n");
432432
#[cfg(windows)]
433-
assert_eq!(buf, b"stdin:\n\nfn main() {}\r\n");
433+
assert_eq!(buf, b"<stdin>:\n\nfn main() {}\r\n");
434434
}
435435

436436
#[test]

Diff for: tests/writemode/target/stdin.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +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"}]}]
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"}]}]

Diff for: tests/writemode/target/stdin.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<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>
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<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>

0 commit comments

Comments
 (0)