Skip to content

Commit d54d59f

Browse files
epagephip1611
authored andcommitted
fix: Ensure stdout is locked
In 3a29410, we switched to anstream which doesn't seem to be locking properly (rust-lang/cargo#12289). For now, we are working around it. Fixes crate-ci#749
1 parent 027c3b1 commit d54d59f

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

Diff for: crates/typos-cli/src/bin/typos-cli/report.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,17 @@ impl Report for PrintBrief {
122122
Message::Typo(msg) => print_brief_correction(msg, self.stdout_palette)?,
123123
Message::FileType(msg) => {
124124
writeln!(
125-
stdout(),
125+
stdout().lock(),
126126
"{}:{}",
127127
msg.path.display(),
128128
msg.file_type.unwrap_or("-")
129129
)?;
130130
}
131131
Message::File(msg) => {
132-
writeln!(stdout(), "{}", msg.path.display())?;
132+
writeln!(stdout().lock(), "{}", msg.path.display())?;
133133
}
134134
Message::Parse(msg) => {
135-
writeln!(stdout(), "{}", msg.data)?;
135+
writeln!(stdout().lock(), "{}", msg.data)?;
136136
}
137137
Message::Error(msg) => {
138138
log::error!("{}: {}", context_display(&msg.context), msg.msg);
@@ -157,17 +157,17 @@ impl Report for PrintLong {
157157
Message::Typo(msg) => print_long_correction(msg, self.stdout_palette)?,
158158
Message::FileType(msg) => {
159159
writeln!(
160-
stdout(),
160+
stdout().lock(),
161161
"{}:{}",
162162
msg.path.display(),
163163
msg.file_type.unwrap_or("-")
164164
)?;
165165
}
166166
Message::File(msg) => {
167-
writeln!(stdout(), "{}", msg.path.display())?;
167+
writeln!(stdout().lock(), "{}", msg.path.display())?;
168168
}
169169
Message::Parse(msg) => {
170-
writeln!(stdout(), "{}", msg.data)?;
170+
writeln!(stdout().lock(), "{}", msg.data)?;
171171
}
172172
Message::Error(msg) => {
173173
log::error!("{}: {}", context_display(&msg.context), msg.msg);
@@ -187,7 +187,7 @@ fn print_brief_correction(msg: &Typo, palette: Palette) -> Result<(), std::io::E
187187
typos::Status::Invalid => {
188188
let divider = ":";
189189
writeln!(
190-
stdout(),
190+
stdout().lock(),
191191
"{:#}{:#}{:#}: {:#}",
192192
palette.info(context_display(&msg.context)),
193193
palette.info(divider),
@@ -198,7 +198,7 @@ fn print_brief_correction(msg: &Typo, palette: Palette) -> Result<(), std::io::E
198198
typos::Status::Corrections(corrections) => {
199199
let divider = ":";
200200
writeln!(
201-
stdout(),
201+
stdout().lock(),
202202
"{:#}{:#}{:#}: {:#}",
203203
palette.info(context_display(&msg.context)),
204204
palette.info(divider),
@@ -328,7 +328,7 @@ pub struct PrintJson;
328328

329329
impl Report for PrintJson {
330330
fn report(&self, msg: Message) -> Result<(), std::io::Error> {
331-
writeln!(stdout(), "{}", serde_json::to_string(&msg).unwrap())?;
331+
writeln!(stdout().lock(), "{}", serde_json::to_string(&msg).unwrap())?;
332332
Ok(())
333333
}
334334
}

0 commit comments

Comments
 (0)