diff --git a/src/protocol.rs b/src/protocol.rs index a4e5f40..2c192f1 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -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>> { + fn help(&self) -> Option<&(dyn Display)> { None } diff --git a/src/reporter.rs b/src/reporter.rs index 1224bc5..bcebf9e 100644 --- a/src/reporter.rs +++ b/src/reporter.rs @@ -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::>() - .join(" ") + .unwrap_or(&"have you tried not failing?") )?; writeln!( f, diff --git a/tests/reporter.rs b/tests/reporter.rs index 2b36dab..7fa2653 100644 --- a/tests/reporter.rs +++ b/tests/reporter.rs @@ -23,10 +23,8 @@ impl Diagnostic for MyBad { &"oops::my::bad" } - } - - fn help(&self) -> Option>> { - 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]> {