feat(protocol): help is a single Display ref now.

This commit is contained in:
Kat Marchán 2021-08-07 22:57:56 -04:00
parent 7920a2315c
commit 80e7dabbe4
No known key found for this signature in database
GPG Key ID: AEB529C08A3C7E9E
3 changed files with 5 additions and 12 deletions

View File

@ -30,7 +30,7 @@ pub trait Diagnostic: std::error::Error {
/// Additional help text related to this Diagnostic. Do you have any
/// advice for the poor soul who's just run into this issue?
fn help(&self) -> Option<Box<dyn '_ + Iterator<Item = &'_ str>>> {
fn help(&self) -> Option<&(dyn Display)> {
None
}

View File

@ -131,10 +131,7 @@ impl DiagnosticReporter for MietteReporter {
}
if let Some(help) = diagnostic.help() {
writeln!(f)?;
for msg in help {
writeln!(f, "﹦{}", msg)?;
}
writeln!(f, "﹦{}", help)?;
}
Ok(())
@ -162,9 +159,7 @@ impl DiagnosticReporter for JokeReporter {
diagnostic,
diagnostic
.help()
.unwrap_or_else(|| Box::new(vec!["have you tried not failing?"].into_iter()))
.collect::<Vec<&str>>()
.join(" ")
.unwrap_or(&"have you tried not failing?")
)?;
writeln!(
f,

View File

@ -23,10 +23,8 @@ impl Diagnostic for MyBad {
&"oops::my::bad"
}
}
fn help(&self) -> Option<Box<dyn '_ + Iterator<Item = &'_ str>>> {
Some(Box::new(vec!["try doing it better next time?"].into_iter()))
fn help(&self) -> Option<&(dyn std::fmt::Display)> {
Some(&"try doing it better next time?")
}
fn snippets(&self) -> Option<&[DiagnosticSnippet]> {