Skip to content

Commit 72cb1bd

Browse files
committed
silence tidy errors
1 parent 5b3902f commit 72cb1bd

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

library/std/src/error.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -1284,9 +1284,7 @@ where
12841284

12851285
for (ind, error) in cause.chain().enumerate() {
12861286
writeln!(f)?;
1287-
let mut indented = Indented {
1288-
inner: f,
1289-
};
1287+
let mut indented = Indented { inner: f };
12901288
if multiple {
12911289
write!(indented, "{: >4}: {}", ind, error)?;
12921290
} else {
@@ -1310,8 +1308,7 @@ where
13101308
}
13111309
}
13121310

1313-
impl Report<Box<dyn Error>>
1314-
{
1311+
impl Report<Box<dyn Error>> {
13151312
fn backtrace(&self) -> Option<&Backtrace> {
13161313
// have to grab the backtrace on the first error directly since that error may not be
13171314
// 'static
@@ -1353,9 +1350,7 @@ impl Report<Box<dyn Error>>
13531350

13541351
for (ind, error) in cause.chain().enumerate() {
13551352
writeln!(f)?;
1356-
let mut indented = Indented {
1357-
inner: f,
1358-
};
1353+
let mut indented = Indented { inner: f };
13591354
if multiple {
13601355
write!(indented, "{: >4}: {}", ind, error)?;
13611356
} else {
@@ -1411,8 +1406,7 @@ where
14111406
}
14121407

14131408
#[unstable(feature = "error_reporter", issue = "90172")]
1414-
impl fmt::Display for Report<Box<dyn Error>>
1415-
{
1409+
impl fmt::Display for Report<Box<dyn Error>> {
14161410
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
14171411
if self.pretty { self.fmt_multiline(f) } else { self.fmt_singleline(f) }
14181412
}

library/std/src/error/tests.rs

+23-17
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,13 @@ fn multi_line_formatting() {
8282
let error = SuperError { source: SuperErrorSideKick };
8383
let report = Report::new(&error).pretty(true);
8484
let actual = report.to_string();
85-
let expected = String::from("\
85+
let expected = String::from(
86+
"\
8687
SuperError is here!
8788
8889
Caused by:
89-
SuperErrorSideKick is here!");
90+
SuperErrorSideKick is here!",
91+
);
9092

9193
assert_eq!(expected, actual);
9294
}
@@ -112,43 +114,47 @@ fn error_with_no_sources_formats_multi_line_correctly() {
112114
#[test]
113115
fn error_with_backtrace_outputs_correctly_with_one_source() {
114116
let trace = Backtrace::force_capture();
115-
let expected = format!("\
117+
let expected = format!(
118+
"\
116119
The source of the error
117120
118121
Caused by:
119122
Error with backtrace
120123
121124
Stack backtrace:
122-
{}", trace);
125+
{}",
126+
trace
127+
);
123128
let error = GenericError::new("Error with backtrace");
124129
let mut error = GenericError::new_with_source("The source of the error", error);
125130
error.backtrace = Some(trace);
126131
let report = Report::new(error).pretty(true).show_backtrace(true);
127132

128-
129133
println!("Error: {}", report);
130134
assert_eq!(expected.trim_end(), report.to_string());
131135
}
132136

133137
#[test]
134138
fn error_with_backtrace_outputs_correctly_with_two_sources() {
135139
let trace = Backtrace::force_capture();
136-
let expected = format!("\
140+
let expected = format!(
141+
"\
137142
Error with two sources
138143
139144
Caused by:
140145
0: The source of the error
141146
1: Error with backtrace
142147
143148
Stack backtrace:
144-
{}", trace);
149+
{}",
150+
trace
151+
);
145152
let mut error = GenericError::new("Error with backtrace");
146153
error.backtrace = Some(trace);
147154
let error = GenericError::new_with_source("The source of the error", error);
148155
let error = GenericError::new_with_source("Error with two sources", error);
149156
let report = Report::new(error).pretty(true).show_backtrace(true);
150157

151-
152158
println!("Error: {}", report);
153159
assert_eq!(expected.trim_end(), report.to_string());
154160
}
@@ -313,11 +319,11 @@ The message
313319
314320
315321
Caused by:
316-
0:
317-
The message
318-
319-
1:
320-
The message
322+
0: \
323+
\n The message
324+
\
325+
\n 1: \
326+
\n The message
321327
";
322328

323329
let actual = report.to_string();
@@ -399,11 +405,11 @@ line 2
399405
400406
Caused by:
401407
0: line 1
402-
403-
line 2
408+
\
409+
\n line 2
404410
1: line 1
405-
406-
line 2";
411+
\
412+
\n line 2";
407413

408414
let actual = report.to_string();
409415
assert_eq!(expected, actual);

0 commit comments

Comments
 (0)