silence tidy errors
This commit is contained in:
parent
5b3902fc65
commit
72cb1bd06d
2 changed files with 27 additions and 27 deletions
|
@ -1284,9 +1284,7 @@ where
|
||||||
|
|
||||||
for (ind, error) in cause.chain().enumerate() {
|
for (ind, error) in cause.chain().enumerate() {
|
||||||
writeln!(f)?;
|
writeln!(f)?;
|
||||||
let mut indented = Indented {
|
let mut indented = Indented { inner: f };
|
||||||
inner: f,
|
|
||||||
};
|
|
||||||
if multiple {
|
if multiple {
|
||||||
write!(indented, "{: >4}: {}", ind, error)?;
|
write!(indented, "{: >4}: {}", ind, error)?;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1310,8 +1308,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Report<Box<dyn Error>>
|
impl Report<Box<dyn Error>> {
|
||||||
{
|
|
||||||
fn backtrace(&self) -> Option<&Backtrace> {
|
fn backtrace(&self) -> Option<&Backtrace> {
|
||||||
// have to grab the backtrace on the first error directly since that error may not be
|
// have to grab the backtrace on the first error directly since that error may not be
|
||||||
// 'static
|
// 'static
|
||||||
|
@ -1353,9 +1350,7 @@ impl Report<Box<dyn Error>>
|
||||||
|
|
||||||
for (ind, error) in cause.chain().enumerate() {
|
for (ind, error) in cause.chain().enumerate() {
|
||||||
writeln!(f)?;
|
writeln!(f)?;
|
||||||
let mut indented = Indented {
|
let mut indented = Indented { inner: f };
|
||||||
inner: f,
|
|
||||||
};
|
|
||||||
if multiple {
|
if multiple {
|
||||||
write!(indented, "{: >4}: {}", ind, error)?;
|
write!(indented, "{: >4}: {}", ind, error)?;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1411,8 +1406,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "error_reporter", issue = "90172")]
|
#[unstable(feature = "error_reporter", issue = "90172")]
|
||||||
impl fmt::Display for Report<Box<dyn Error>>
|
impl fmt::Display for Report<Box<dyn Error>> {
|
||||||
{
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
if self.pretty { self.fmt_multiline(f) } else { self.fmt_singleline(f) }
|
if self.pretty { self.fmt_multiline(f) } else { self.fmt_singleline(f) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,11 +82,13 @@ fn multi_line_formatting() {
|
||||||
let error = SuperError { source: SuperErrorSideKick };
|
let error = SuperError { source: SuperErrorSideKick };
|
||||||
let report = Report::new(&error).pretty(true);
|
let report = Report::new(&error).pretty(true);
|
||||||
let actual = report.to_string();
|
let actual = report.to_string();
|
||||||
let expected = String::from("\
|
let expected = String::from(
|
||||||
|
"\
|
||||||
SuperError is here!
|
SuperError is here!
|
||||||
|
|
||||||
Caused by:
|
Caused by:
|
||||||
SuperErrorSideKick is here!");
|
SuperErrorSideKick is here!",
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
}
|
}
|
||||||
|
@ -112,20 +114,22 @@ fn error_with_no_sources_formats_multi_line_correctly() {
|
||||||
#[test]
|
#[test]
|
||||||
fn error_with_backtrace_outputs_correctly_with_one_source() {
|
fn error_with_backtrace_outputs_correctly_with_one_source() {
|
||||||
let trace = Backtrace::force_capture();
|
let trace = Backtrace::force_capture();
|
||||||
let expected = format!("\
|
let expected = format!(
|
||||||
|
"\
|
||||||
The source of the error
|
The source of the error
|
||||||
|
|
||||||
Caused by:
|
Caused by:
|
||||||
Error with backtrace
|
Error with backtrace
|
||||||
|
|
||||||
Stack backtrace:
|
Stack backtrace:
|
||||||
{}", trace);
|
{}",
|
||||||
|
trace
|
||||||
|
);
|
||||||
let error = GenericError::new("Error with backtrace");
|
let error = GenericError::new("Error with backtrace");
|
||||||
let mut error = GenericError::new_with_source("The source of the error", error);
|
let mut error = GenericError::new_with_source("The source of the error", error);
|
||||||
error.backtrace = Some(trace);
|
error.backtrace = Some(trace);
|
||||||
let report = Report::new(error).pretty(true).show_backtrace(true);
|
let report = Report::new(error).pretty(true).show_backtrace(true);
|
||||||
|
|
||||||
|
|
||||||
println!("Error: {}", report);
|
println!("Error: {}", report);
|
||||||
assert_eq!(expected.trim_end(), report.to_string());
|
assert_eq!(expected.trim_end(), report.to_string());
|
||||||
}
|
}
|
||||||
|
@ -133,7 +137,8 @@ Stack backtrace:
|
||||||
#[test]
|
#[test]
|
||||||
fn error_with_backtrace_outputs_correctly_with_two_sources() {
|
fn error_with_backtrace_outputs_correctly_with_two_sources() {
|
||||||
let trace = Backtrace::force_capture();
|
let trace = Backtrace::force_capture();
|
||||||
let expected = format!("\
|
let expected = format!(
|
||||||
|
"\
|
||||||
Error with two sources
|
Error with two sources
|
||||||
|
|
||||||
Caused by:
|
Caused by:
|
||||||
|
@ -141,14 +146,15 @@ Caused by:
|
||||||
1: Error with backtrace
|
1: Error with backtrace
|
||||||
|
|
||||||
Stack backtrace:
|
Stack backtrace:
|
||||||
{}", trace);
|
{}",
|
||||||
|
trace
|
||||||
|
);
|
||||||
let mut error = GenericError::new("Error with backtrace");
|
let mut error = GenericError::new("Error with backtrace");
|
||||||
error.backtrace = Some(trace);
|
error.backtrace = Some(trace);
|
||||||
let error = GenericError::new_with_source("The source of the error", error);
|
let error = GenericError::new_with_source("The source of the error", error);
|
||||||
let error = GenericError::new_with_source("Error with two sources", error);
|
let error = GenericError::new_with_source("Error with two sources", error);
|
||||||
let report = Report::new(error).pretty(true).show_backtrace(true);
|
let report = Report::new(error).pretty(true).show_backtrace(true);
|
||||||
|
|
||||||
|
|
||||||
println!("Error: {}", report);
|
println!("Error: {}", report);
|
||||||
assert_eq!(expected.trim_end(), report.to_string());
|
assert_eq!(expected.trim_end(), report.to_string());
|
||||||
}
|
}
|
||||||
|
@ -313,11 +319,11 @@ The message
|
||||||
|
|
||||||
|
|
||||||
Caused by:
|
Caused by:
|
||||||
0:
|
0: \
|
||||||
The message
|
\n The message
|
||||||
|
\
|
||||||
1:
|
\n 1: \
|
||||||
The message
|
\n The message
|
||||||
";
|
";
|
||||||
|
|
||||||
let actual = report.to_string();
|
let actual = report.to_string();
|
||||||
|
@ -399,11 +405,11 @@ line 2
|
||||||
|
|
||||||
Caused by:
|
Caused by:
|
||||||
0: line 1
|
0: line 1
|
||||||
|
\
|
||||||
line 2
|
\n line 2
|
||||||
1: line 1
|
1: line 1
|
||||||
|
\
|
||||||
line 2";
|
\n line 2";
|
||||||
|
|
||||||
let actual = report.to_string();
|
let actual = report.to_string();
|
||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue