Clean: display format

This commit is contained in:
GreasySlug 2022-11-18 21:56:09 +09:00
parent 899e8ead03
commit 12ccd6ac27

View file

@ -572,12 +572,12 @@ impl ErrorCore {
Location::Line(lineno) => format!(", line {lineno}"), Location::Line(lineno) => format!(", line {lineno}"),
Location::Unknown => "".to_string(), Location::Unknown => "".to_string(),
}; };
format!("{kind}: File {input}{loc}{caused_by}\n",) format!("{kind}: File {input}{loc}{caused_by}",)
} }
pub fn fmt_main_message(&self, kind: StyledString, caused_by: &str, input: &str) -> String { pub fn fmt_main_message(&self, kind: StyledString, caused_by: &str, input: &str) -> String {
format!( format!(
"{}{}\n\n", "{}\n{}\n\n",
self.fmt_header(kind, caused_by, input), self.fmt_header(kind, caused_by, input),
self.main_message self.main_message
) )
@ -666,11 +666,11 @@ pub trait ErrorDisplay {
); );
writeln!( writeln!(
f, f,
"{}\n", "{}",
core.fmt_main_message(kind, self.caused_by(), self.input().enclosed_name()) core.fmt_main_message(kind, self.caused_by(), self.input().enclosed_name())
)?; )?;
for sub_msg in &self.core().sub_messages { for sub_msg in &self.core().sub_messages {
writeln!( write!(
f, f,
"{}", "{}",
&sub_msg.format_code_and_pointer(self, color, gutter_color, mark, chars) &sub_msg.format_code_and_pointer(self, color, gutter_color, mark, chars)