From 12ab4dfce5ba2e1127202554011f761bae9c694d Mon Sep 17 00:00:00 2001 From: Johann150 Date: Wed, 15 Jul 2020 20:04:30 +0200 Subject: [PATCH 1/4] add medium rendering mode just added it onto the short diagnostic rendering otherwise big chunks of code would be duplicated --- codespan-reporting/src/term.rs | 3 ++- codespan-reporting/src/term/config.rs | 10 ++++++++++ codespan-reporting/src/term/views.rs | 17 ++++++++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/codespan-reporting/src/term.rs b/codespan-reporting/src/term.rs index c852e70..183676a 100644 --- a/codespan-reporting/src/term.rs +++ b/codespan-reporting/src/term.rs @@ -94,7 +94,8 @@ pub fn emit<'files, F: Files<'files>>( let mut renderer = Renderer::new(writer, config); match config.display_style { DisplayStyle::Rich => RichDiagnostic::new(diagnostic).render(files, &mut renderer), - DisplayStyle::Short => ShortDiagnostic::new(diagnostic).render(files, &mut renderer), + DisplayStyle::Medium => ShortDiagnostic::new(diagnostic, true).render(files, &mut renderer), + DisplayStyle::Short => ShortDiagnostic::new(diagnostic, false).render(files, &mut renderer), } } diff --git a/codespan-reporting/src/term/config.rs b/codespan-reporting/src/term/config.rs index cb368b3..18cbd44 100644 --- a/codespan-reporting/src/term/config.rs +++ b/codespan-reporting/src/term/config.rs @@ -59,6 +59,16 @@ pub enum DisplayStyle { /// /// ``` Rich, + /// Output a condensed diagnostic, with a line number, severity, message and notes (if any). + /// + /// ```text + /// test:2:9: error[E0001]: unexpected type in `+` application + /// = expected type `Int` + /// found type `String` + /// + /// error[E0002]: Bad config found + /// ``` + Medium, /// Output a short diagnostic, with a line number, severity, and message. /// /// ```text diff --git a/codespan-reporting/src/term/views.rs b/codespan-reporting/src/term/views.rs index 0e75977..5cc8168 100644 --- a/codespan-reporting/src/term/views.rs +++ b/codespan-reporting/src/term/views.rs @@ -419,6 +419,7 @@ where /// Output a short diagnostic, with a line number, severity, and message. pub struct ShortDiagnostic<'diagnostic, FileId> { diagnostic: &'diagnostic Diagnostic, + show_notes: bool } impl<'diagnostic, FileId> ShortDiagnostic<'diagnostic, FileId> @@ -427,8 +428,9 @@ where { pub fn new( diagnostic: &'diagnostic Diagnostic, + show_notes: bool, ) -> ShortDiagnostic<'diagnostic, FileId> { - ShortDiagnostic { diagnostic } + ShortDiagnostic { diagnostic, show_notes } } pub fn render<'files>( @@ -474,6 +476,19 @@ where )?; } + if self.show_notes { + // Additional notes + // + // ```text + // = expected type `Int` + // found type `String` + // ``` + for note in &self.diagnostic.notes { + renderer.render_snippet_note(0, note)?; + } + renderer.render_empty()?; + } + Ok(()) } } From e67efa01dae508e79b51fa97d878b2858499ba8d Mon Sep 17 00:00:00 2001 From: Johann150 Date: Wed, 15 Jul 2020 20:07:32 +0200 Subject: [PATCH 2/4] forgot something & add test macros also added two small test to see that it works --- codespan-reporting/src/term/views.rs | 7 ++++-- .../snapshots/term__empty__medium_color.snap | 17 +++++++++++++ .../term__empty__medium_no_color.snap | 17 +++++++++++++ codespan-reporting/tests/term.rs | 24 +++++++++++++++++++ 4 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 codespan-reporting/tests/snapshots/term__empty__medium_color.snap create mode 100644 codespan-reporting/tests/snapshots/term__empty__medium_no_color.snap diff --git a/codespan-reporting/src/term/views.rs b/codespan-reporting/src/term/views.rs index 5cc8168..d9ac875 100644 --- a/codespan-reporting/src/term/views.rs +++ b/codespan-reporting/src/term/views.rs @@ -419,7 +419,7 @@ where /// Output a short diagnostic, with a line number, severity, and message. pub struct ShortDiagnostic<'diagnostic, FileId> { diagnostic: &'diagnostic Diagnostic, - show_notes: bool + show_notes: bool, } impl<'diagnostic, FileId> ShortDiagnostic<'diagnostic, FileId> @@ -430,7 +430,10 @@ where diagnostic: &'diagnostic Diagnostic, show_notes: bool, ) -> ShortDiagnostic<'diagnostic, FileId> { - ShortDiagnostic { diagnostic, show_notes } + ShortDiagnostic { + diagnostic, + show_notes, + } } pub fn render<'files>( diff --git a/codespan-reporting/tests/snapshots/term__empty__medium_color.snap b/codespan-reporting/tests/snapshots/term__empty__medium_color.snap new file mode 100644 index 0000000..f94d46b --- /dev/null +++ b/codespan-reporting/tests/snapshots/term__empty__medium_color.snap @@ -0,0 +1,17 @@ +--- +source: codespan-reporting/tests/term.rs +expression: TEST_DATA.emit_color(&config) +--- +{fg:Red bold bright}bug{bold bright}: {/} + +{fg:Red bold bright}error{bold bright}: {/} + +{fg:Yellow bold bright}warning{bold bright}: {/} + +{fg:Green bold bright}note{bold bright}: {/} + +{fg:Cyan bold bright}help{bold bright}: {/} + +{fg:Red bold bright}bug{bold bright}: {/} + + diff --git a/codespan-reporting/tests/snapshots/term__empty__medium_no_color.snap b/codespan-reporting/tests/snapshots/term__empty__medium_no_color.snap new file mode 100644 index 0000000..1ec1a94 --- /dev/null +++ b/codespan-reporting/tests/snapshots/term__empty__medium_no_color.snap @@ -0,0 +1,17 @@ +--- +source: codespan-reporting/tests/term.rs +expression: TEST_DATA.emit_no_color(&config) +--- +bug: + +error: + +warning: + +note: + +help: + +bug: + + diff --git a/codespan-reporting/tests/term.rs b/codespan-reporting/tests/term.rs index 4a0fa26..71c017b 100644 --- a/codespan-reporting/tests/term.rs +++ b/codespan-reporting/tests/term.rs @@ -26,6 +26,17 @@ macro_rules! test_emit { insta::assert_snapshot!(TEST_DATA.emit_color(&config)); } }; + (medium_color) => { + #[test] + fn medium_color() { + let config = Config { + display_style: DisplayStyle::Medium, + ..TEST_CONFIG.clone() + }; + + insta::assert_snapshot!(TEST_DATA.emit_color(&config)); + } + }; (short_color) => { #[test] fn short_color() { @@ -48,6 +59,17 @@ macro_rules! test_emit { insta::assert_snapshot!(TEST_DATA.emit_no_color(&config)); } }; + (medium_no_color) => { + #[test] + fn medium_no_color() { + let config = Config { + display_style: DisplayStyle::Medium, + ..TEST_CONFIG.clone() + }; + + insta::assert_snapshot!(TEST_DATA.emit_no_color(&config)); + } + }; (short_no_color) => { #[test] fn short_no_color() { @@ -82,8 +104,10 @@ mod empty { } test_emit!(rich_color); + test_emit!(medium_color); test_emit!(short_color); test_emit!(rich_no_color); + test_emit!(medium_no_color); test_emit!(short_no_color); } From 20f9b6e9978a94f9b66aa74b1e527b3dec8c0d6f Mon Sep 17 00:00:00 2001 From: Johann150 Date: Wed, 15 Jul 2020 20:19:22 +0200 Subject: [PATCH 3/4] add remaining tests --- .../term__empty_ranges__medium_color.snap | 13 ++++++++ .../term__empty_ranges__medium_no_color.snap | 13 ++++++++ .../term__fizz_buzz__medium_color.snap | 13 ++++++++ .../term__fizz_buzz__medium_no_color.snap | 13 ++++++++ .../term__message__medium_color.snap | 13 ++++++++ .../term__message__medium_no_color.snap | 13 ++++++++ ...term__message_and_notes__medium_color.snap | 17 ++++++++++ ...m__message_and_notes__medium_no_color.snap | 17 ++++++++++ .../term__multifile__medium_color.snap | 15 +++++++++ .../term__multifile__medium_no_color.snap | 15 +++++++++ ...__multiline_overlapping__medium_color.snap | 9 ++++++ ...ultiline_overlapping__medium_no_color.snap | 9 ++++++ .../term__overlapping__medium_color.snap | 22 +++++++++++++ .../term__overlapping__medium_no_color.snap | 22 +++++++++++++ ...__position_indicator__medium_no_color.snap | 7 +++++ .../term__same_line__medium_color.snap | 10 ++++++ .../term__same_line__medium_no_color.snap | 10 ++++++ .../term__same_ranges__medium_color.snap | 7 +++++ .../term__same_ranges__medium_no_color.snap | 7 +++++ .../term__unicode__medium_no_color.snap | 31 +++++++++++++++++++ .../term__unicode_spans__medium_no_color.snap | 13 ++++++++ codespan-reporting/tests/term.rs | 21 +++++++++++++ 22 files changed, 310 insertions(+) create mode 100644 codespan-reporting/tests/snapshots/term__empty_ranges__medium_color.snap create mode 100644 codespan-reporting/tests/snapshots/term__empty_ranges__medium_no_color.snap create mode 100644 codespan-reporting/tests/snapshots/term__fizz_buzz__medium_color.snap create mode 100644 codespan-reporting/tests/snapshots/term__fizz_buzz__medium_no_color.snap create mode 100644 codespan-reporting/tests/snapshots/term__message__medium_color.snap create mode 100644 codespan-reporting/tests/snapshots/term__message__medium_no_color.snap create mode 100644 codespan-reporting/tests/snapshots/term__message_and_notes__medium_color.snap create mode 100644 codespan-reporting/tests/snapshots/term__message_and_notes__medium_no_color.snap create mode 100644 codespan-reporting/tests/snapshots/term__multifile__medium_color.snap create mode 100644 codespan-reporting/tests/snapshots/term__multifile__medium_no_color.snap create mode 100644 codespan-reporting/tests/snapshots/term__multiline_overlapping__medium_color.snap create mode 100644 codespan-reporting/tests/snapshots/term__multiline_overlapping__medium_no_color.snap create mode 100644 codespan-reporting/tests/snapshots/term__overlapping__medium_color.snap create mode 100644 codespan-reporting/tests/snapshots/term__overlapping__medium_no_color.snap create mode 100644 codespan-reporting/tests/snapshots/term__position_indicator__medium_no_color.snap create mode 100644 codespan-reporting/tests/snapshots/term__same_line__medium_color.snap create mode 100644 codespan-reporting/tests/snapshots/term__same_line__medium_no_color.snap create mode 100644 codespan-reporting/tests/snapshots/term__same_ranges__medium_color.snap create mode 100644 codespan-reporting/tests/snapshots/term__same_ranges__medium_no_color.snap create mode 100644 codespan-reporting/tests/snapshots/term__unicode__medium_no_color.snap create mode 100644 codespan-reporting/tests/snapshots/term__unicode_spans__medium_no_color.snap diff --git a/codespan-reporting/tests/snapshots/term__empty_ranges__medium_color.snap b/codespan-reporting/tests/snapshots/term__empty_ranges__medium_color.snap new file mode 100644 index 0000000..0226779 --- /dev/null +++ b/codespan-reporting/tests/snapshots/term__empty_ranges__medium_color.snap @@ -0,0 +1,13 @@ +--- +source: codespan-reporting/tests/term.rs +expression: TEST_DATA.emit_color(&config) +--- +hello:1:7: {fg:Green bold bright}note{bold bright}: middle{/} + +hello:1:13: {fg:Green bold bright}note{bold bright}: end of line{/} + +hello:2:11: {fg:Green bold bright}note{bold bright}: end of line{/} + +hello:3:4: {fg:Green bold bright}note{bold bright}: end of file{/} + + diff --git a/codespan-reporting/tests/snapshots/term__empty_ranges__medium_no_color.snap b/codespan-reporting/tests/snapshots/term__empty_ranges__medium_no_color.snap new file mode 100644 index 0000000..150ca86 --- /dev/null +++ b/codespan-reporting/tests/snapshots/term__empty_ranges__medium_no_color.snap @@ -0,0 +1,13 @@ +--- +source: codespan-reporting/tests/term.rs +expression: TEST_DATA.emit_no_color(&config) +--- +hello:1:7: note: middle + +hello:1:13: note: end of line + +hello:2:11: note: end of line + +hello:3:4: note: end of file + + diff --git a/codespan-reporting/tests/snapshots/term__fizz_buzz__medium_color.snap b/codespan-reporting/tests/snapshots/term__fizz_buzz__medium_color.snap new file mode 100644 index 0000000..ab60435 --- /dev/null +++ b/codespan-reporting/tests/snapshots/term__fizz_buzz__medium_color.snap @@ -0,0 +1,13 @@ +--- +source: codespan-reporting/tests/term.rs +expression: TEST_DATA.emit_color(&config) +--- +FizzBuzz.fun:8:12: {fg:Red bold bright}error[E0308]{bold bright}: `case` clauses have incompatible types{/} + {fg:Blue}={/} expected type `String` + found type `Nat` + +FizzBuzz.fun:16:16: {fg:Red bold bright}error[E0308]{bold bright}: `case` clauses have incompatible types{/} + {fg:Blue}={/} expected type `String` + found type `Nat` + + diff --git a/codespan-reporting/tests/snapshots/term__fizz_buzz__medium_no_color.snap b/codespan-reporting/tests/snapshots/term__fizz_buzz__medium_no_color.snap new file mode 100644 index 0000000..77a48af --- /dev/null +++ b/codespan-reporting/tests/snapshots/term__fizz_buzz__medium_no_color.snap @@ -0,0 +1,13 @@ +--- +source: codespan-reporting/tests/term.rs +expression: TEST_DATA.emit_no_color(&config) +--- +FizzBuzz.fun:8:12: error[E0308]: `case` clauses have incompatible types + = expected type `String` + found type `Nat` + +FizzBuzz.fun:16:16: error[E0308]: `case` clauses have incompatible types + = expected type `String` + found type `Nat` + + diff --git a/codespan-reporting/tests/snapshots/term__message__medium_color.snap b/codespan-reporting/tests/snapshots/term__message__medium_color.snap new file mode 100644 index 0000000..c1bd423 --- /dev/null +++ b/codespan-reporting/tests/snapshots/term__message__medium_color.snap @@ -0,0 +1,13 @@ +--- +source: codespan-reporting/tests/term.rs +expression: TEST_DATA.emit_color(&config) +--- +{fg:Red bold bright}error{bold bright}: a message{/} + +{fg:Yellow bold bright}warning{bold bright}: a message{/} + +{fg:Green bold bright}note{bold bright}: a message{/} + +{fg:Cyan bold bright}help{bold bright}: a message{/} + + diff --git a/codespan-reporting/tests/snapshots/term__message__medium_no_color.snap b/codespan-reporting/tests/snapshots/term__message__medium_no_color.snap new file mode 100644 index 0000000..d3abe84 --- /dev/null +++ b/codespan-reporting/tests/snapshots/term__message__medium_no_color.snap @@ -0,0 +1,13 @@ +--- +source: codespan-reporting/tests/term.rs +expression: TEST_DATA.emit_no_color(&config) +--- +error: a message + +warning: a message + +note: a message + +help: a message + + diff --git a/codespan-reporting/tests/snapshots/term__message_and_notes__medium_color.snap b/codespan-reporting/tests/snapshots/term__message_and_notes__medium_color.snap new file mode 100644 index 0000000..56900e8 --- /dev/null +++ b/codespan-reporting/tests/snapshots/term__message_and_notes__medium_color.snap @@ -0,0 +1,17 @@ +--- +source: codespan-reporting/tests/term.rs +expression: TEST_DATA.emit_color(&config) +--- +{fg:Red bold bright}error{bold bright}: a message{/} + {fg:Blue}={/} a note + +{fg:Yellow bold bright}warning{bold bright}: a message{/} + {fg:Blue}={/} a note + +{fg:Green bold bright}note{bold bright}: a message{/} + {fg:Blue}={/} a note + +{fg:Cyan bold bright}help{bold bright}: a message{/} + {fg:Blue}={/} a note + + diff --git a/codespan-reporting/tests/snapshots/term__message_and_notes__medium_no_color.snap b/codespan-reporting/tests/snapshots/term__message_and_notes__medium_no_color.snap new file mode 100644 index 0000000..d4e209b --- /dev/null +++ b/codespan-reporting/tests/snapshots/term__message_and_notes__medium_no_color.snap @@ -0,0 +1,17 @@ +--- +source: codespan-reporting/tests/term.rs +expression: TEST_DATA.emit_no_color(&config) +--- +error: a message + = a note + +warning: a message + = a note + +note: a message + = a note + +help: a message + = a note + + diff --git a/codespan-reporting/tests/snapshots/term__multifile__medium_color.snap b/codespan-reporting/tests/snapshots/term__multifile__medium_color.snap new file mode 100644 index 0000000..5e0c3f9 --- /dev/null +++ b/codespan-reporting/tests/snapshots/term__multifile__medium_color.snap @@ -0,0 +1,15 @@ +--- +source: codespan-reporting/tests/term.rs +expression: TEST_DATA.emit_color(&config) +--- +Data/Nat.fun:7:13: {fg:Red bold bright}error{bold bright}: unknown builtin: `NATRAL`{/} + {fg:Blue}={/} there is a builtin with a similar name: `NATURAL` + +Data/Nat.fun:17:16: {fg:Yellow bold bright}warning{bold bright}: unused parameter pattern: `n₂`{/} + {fg:Blue}={/} consider using a wildcard pattern: `_` + +Test.fun:4:11: {fg:Red bold bright}error[E0001]{bold bright}: unexpected type in application of `_+_`{/} + {fg:Blue}={/} expected type `Nat` + found type `String` + + diff --git a/codespan-reporting/tests/snapshots/term__multifile__medium_no_color.snap b/codespan-reporting/tests/snapshots/term__multifile__medium_no_color.snap new file mode 100644 index 0000000..f0bf796 --- /dev/null +++ b/codespan-reporting/tests/snapshots/term__multifile__medium_no_color.snap @@ -0,0 +1,15 @@ +--- +source: codespan-reporting/tests/term.rs +expression: TEST_DATA.emit_no_color(&config) +--- +Data/Nat.fun:7:13: error: unknown builtin: `NATRAL` + = there is a builtin with a similar name: `NATURAL` + +Data/Nat.fun:17:16: warning: unused parameter pattern: `n₂` + = consider using a wildcard pattern: `_` + +Test.fun:4:11: error[E0001]: unexpected type in application of `_+_` + = expected type `Nat` + found type `String` + + diff --git a/codespan-reporting/tests/snapshots/term__multiline_overlapping__medium_color.snap b/codespan-reporting/tests/snapshots/term__multiline_overlapping__medium_color.snap new file mode 100644 index 0000000..afddf24 --- /dev/null +++ b/codespan-reporting/tests/snapshots/term__multiline_overlapping__medium_color.snap @@ -0,0 +1,9 @@ +--- +source: codespan-reporting/tests/term.rs +expression: TEST_DATA.emit_color(&config) +--- +codespan/src/file.rs:4:34: {fg:Red bold bright}error[E0308]{bold bright}: match arms have incompatible types{/} + {fg:Blue}={/} expected type `Result` + found type `LineIndexOutOfBoundsError` + + diff --git a/codespan-reporting/tests/snapshots/term__multiline_overlapping__medium_no_color.snap b/codespan-reporting/tests/snapshots/term__multiline_overlapping__medium_no_color.snap new file mode 100644 index 0000000..0e50bd8 --- /dev/null +++ b/codespan-reporting/tests/snapshots/term__multiline_overlapping__medium_no_color.snap @@ -0,0 +1,9 @@ +--- +source: codespan-reporting/tests/term.rs +expression: TEST_DATA.emit_no_color(&config) +--- +codespan/src/file.rs:4:34: error[E0308]: match arms have incompatible types + = expected type `Result` + found type `LineIndexOutOfBoundsError` + + diff --git a/codespan-reporting/tests/snapshots/term__overlapping__medium_color.snap b/codespan-reporting/tests/snapshots/term__overlapping__medium_color.snap new file mode 100644 index 0000000..578353d --- /dev/null +++ b/codespan-reporting/tests/snapshots/term__overlapping__medium_color.snap @@ -0,0 +1,22 @@ +--- +source: codespan-reporting/tests/term.rs +expression: TEST_DATA.emit_color(&config) +--- +nested_impl_trait.rs:5:56: {fg:Red bold bright}error[E0666]{bold bright}: nested `impl Trait` is not allowed{/} + +typeck_type_placeholder_item.rs:1:18: {fg:Red bold bright}error[E0121]{bold bright}: the type placeholder `_` is not allowed within types on item signatures{/} + +typeck_type_placeholder_item.rs:2:25: {fg:Red bold bright}error[E0121]{bold bright}: the type placeholder `_` is not allowed within types on item signatures{/} +typeck_type_placeholder_item.rs:2:28: {fg:Red bold bright}error[E0121]{bold bright}: the type placeholder `_` is not allowed within types on item signatures{/} + +no_send_res_ports.rs:25:5: {fg:Red bold bright}error[E0277]{bold bright}: `std::rc::Rc<()>` cannot be sent between threads safely{/} + {fg:Blue}={/} help: within `[closure@no_send_res_ports.rs:29:19: 33:6 x:main::Foo]`, the trait `std::marker::Send` is not implemented for `std::rc::Rc<()>` + {fg:Blue}={/} note: required because it appears within the type `Port<()>` + {fg:Blue}={/} note: required because it appears within the type `main::Foo` + {fg:Blue}={/} note: required because it appears within the type `[closure@no_send_res_ports.rs:29:19: 33:6 x:main::Foo]` + +{fg:Red bold bright}error{bold bright}: aborting due 5 previous errors{/} + {fg:Blue}={/} Some errors have detailed explanations: E0121, E0277, E0666. + {fg:Blue}={/} For more information about an error, try `rustc --explain E0121`. + + diff --git a/codespan-reporting/tests/snapshots/term__overlapping__medium_no_color.snap b/codespan-reporting/tests/snapshots/term__overlapping__medium_no_color.snap new file mode 100644 index 0000000..07b65d9 --- /dev/null +++ b/codespan-reporting/tests/snapshots/term__overlapping__medium_no_color.snap @@ -0,0 +1,22 @@ +--- +source: codespan-reporting/tests/term.rs +expression: TEST_DATA.emit_no_color(&config) +--- +nested_impl_trait.rs:5:56: error[E0666]: nested `impl Trait` is not allowed + +typeck_type_placeholder_item.rs:1:18: error[E0121]: the type placeholder `_` is not allowed within types on item signatures + +typeck_type_placeholder_item.rs:2:25: error[E0121]: the type placeholder `_` is not allowed within types on item signatures +typeck_type_placeholder_item.rs:2:28: error[E0121]: the type placeholder `_` is not allowed within types on item signatures + +no_send_res_ports.rs:25:5: error[E0277]: `std::rc::Rc<()>` cannot be sent between threads safely + = help: within `[closure@no_send_res_ports.rs:29:19: 33:6 x:main::Foo]`, the trait `std::marker::Send` is not implemented for `std::rc::Rc<()>` + = note: required because it appears within the type `Port<()>` + = note: required because it appears within the type `main::Foo` + = note: required because it appears within the type `[closure@no_send_res_ports.rs:29:19: 33:6 x:main::Foo]` + +error: aborting due 5 previous errors + = Some errors have detailed explanations: E0121, E0277, E0666. + = For more information about an error, try `rustc --explain E0121`. + + diff --git a/codespan-reporting/tests/snapshots/term__position_indicator__medium_no_color.snap b/codespan-reporting/tests/snapshots/term__position_indicator__medium_no_color.snap new file mode 100644 index 0000000..0e40c83 --- /dev/null +++ b/codespan-reporting/tests/snapshots/term__position_indicator__medium_no_color.snap @@ -0,0 +1,7 @@ +--- +source: codespan-reporting/tests/term.rs +expression: TEST_DATA.emit_no_color(&config) +--- +tests/main.js:4:3: warning[ParserWarning]: The strict mode declaration in the body of function `foo` is redundant, as the outer scope is already in strict mode + + diff --git a/codespan-reporting/tests/snapshots/term__same_line__medium_color.snap b/codespan-reporting/tests/snapshots/term__same_line__medium_color.snap new file mode 100644 index 0000000..4c1a1b2 --- /dev/null +++ b/codespan-reporting/tests/snapshots/term__same_line__medium_color.snap @@ -0,0 +1,10 @@ +--- +source: codespan-reporting/tests/term.rs +expression: TEST_DATA.emit_color(&config) +--- +one_line.rs:3:12: {fg:Red bold bright}error[E0499]{bold bright}: cannot borrow `v` as mutable more than once at a time{/} + +{fg:Red bold bright}error{bold bright}: aborting due to previous error{/} + {fg:Blue}={/} For more information about this error, try `rustc --explain E0499`. + + diff --git a/codespan-reporting/tests/snapshots/term__same_line__medium_no_color.snap b/codespan-reporting/tests/snapshots/term__same_line__medium_no_color.snap new file mode 100644 index 0000000..7301a69 --- /dev/null +++ b/codespan-reporting/tests/snapshots/term__same_line__medium_no_color.snap @@ -0,0 +1,10 @@ +--- +source: codespan-reporting/tests/term.rs +expression: TEST_DATA.emit_no_color(&config) +--- +one_line.rs:3:12: error[E0499]: cannot borrow `v` as mutable more than once at a time + +error: aborting due to previous error + = For more information about this error, try `rustc --explain E0499`. + + diff --git a/codespan-reporting/tests/snapshots/term__same_ranges__medium_color.snap b/codespan-reporting/tests/snapshots/term__same_ranges__medium_color.snap new file mode 100644 index 0000000..095b975 --- /dev/null +++ b/codespan-reporting/tests/snapshots/term__same_ranges__medium_color.snap @@ -0,0 +1,7 @@ +--- +source: codespan-reporting/tests/term.rs +expression: TEST_DATA.emit_color(&config) +--- +same_range:1:5: {fg:Red bold bright}error{bold bright}: Unexpected token{/} + + diff --git a/codespan-reporting/tests/snapshots/term__same_ranges__medium_no_color.snap b/codespan-reporting/tests/snapshots/term__same_ranges__medium_no_color.snap new file mode 100644 index 0000000..a452022 --- /dev/null +++ b/codespan-reporting/tests/snapshots/term__same_ranges__medium_no_color.snap @@ -0,0 +1,7 @@ +--- +source: codespan-reporting/tests/term.rs +expression: TEST_DATA.emit_no_color(&config) +--- +same_range:1:5: error: Unexpected token + + diff --git a/codespan-reporting/tests/snapshots/term__unicode__medium_no_color.snap b/codespan-reporting/tests/snapshots/term__unicode__medium_no_color.snap new file mode 100644 index 0000000..a04bdc8 --- /dev/null +++ b/codespan-reporting/tests/snapshots/term__unicode__medium_no_color.snap @@ -0,0 +1,31 @@ +--- +source: codespan-reporting/tests/term.rs +expression: TEST_DATA.emit_no_color(&config) +--- +unicode.rs:1:8: error[E0703]: invalid ABI: found `路濫狼á́́` + = valid ABIs: + - aapcs + - amdgpu-kernel + - C + - cdecl + - efiapi + - fastcall + - msp430-interrupt + - platform-intrinsic + - ptx-kernel + - Rust + - rust-call + - rust-intrinsic + - stdcall + - system + - sysv64 + - thiscall + - unadjusted + - vectorcall + - win64 + - x86-interrupt + +error: aborting due to previous error + = For more information about this error, try `rustc --explain E0703`. + + diff --git a/codespan-reporting/tests/snapshots/term__unicode_spans__medium_no_color.snap b/codespan-reporting/tests/snapshots/term__unicode_spans__medium_no_color.snap new file mode 100644 index 0000000..71622b0 --- /dev/null +++ b/codespan-reporting/tests/snapshots/term__unicode_spans__medium_no_color.snap @@ -0,0 +1,13 @@ +--- +source: codespan-reporting/tests/term.rs +expression: TEST_DATA.emit_no_color(&config) +--- +moon_jump.rs:1:1: error[E01]: cow may not jump during new moon. + +note: invalid unicode range + +note: invalid unicode range + +note: invalid unicode range + + diff --git a/codespan-reporting/tests/term.rs b/codespan-reporting/tests/term.rs index 71c017b..1b4c28a 100644 --- a/codespan-reporting/tests/term.rs +++ b/codespan-reporting/tests/term.rs @@ -154,8 +154,10 @@ mod same_line { } test_emit!(rich_color); + test_emit!(medium_color); test_emit!(short_color); test_emit!(rich_no_color); + test_emit!(medium_no_color); test_emit!(short_no_color); } @@ -296,8 +298,10 @@ mod overlapping { } test_emit!(rich_color); + test_emit!(medium_color); test_emit!(short_color); test_emit!(rich_no_color); + test_emit!(medium_no_color); test_emit!(short_no_color); } @@ -320,8 +324,10 @@ mod message { } test_emit!(rich_color); + test_emit!(medium_color); test_emit!(short_color); test_emit!(rich_no_color); + test_emit!(medium_no_color); test_emit!(short_no_color); } @@ -344,8 +350,10 @@ mod message_and_notes { } test_emit!(rich_color); + test_emit!(medium_color); test_emit!(short_color); test_emit!(rich_no_color); + test_emit!(medium_no_color); test_emit!(short_no_color); } @@ -377,8 +385,10 @@ mod empty_ranges { } test_emit!(rich_color); + test_emit!(medium_color); test_emit!(short_color); test_emit!(rich_no_color); + test_emit!(medium_no_color); test_emit!(short_no_color); } @@ -403,8 +413,10 @@ mod same_ranges { } test_emit!(rich_color); + test_emit!(medium_color); test_emit!(short_color); test_emit!(rich_no_color); + test_emit!(medium_no_color); test_emit!(short_no_color); } @@ -487,8 +499,10 @@ mod multifile { } test_emit!(rich_color); + test_emit!(medium_color); test_emit!(short_color); test_emit!(rich_no_color); + test_emit!(medium_no_color); test_emit!(short_no_color); } @@ -564,8 +578,10 @@ mod fizz_buzz { } test_emit!(rich_color); + test_emit!(medium_color); test_emit!(short_color); test_emit!(rich_no_color); + test_emit!(medium_no_color); test_emit!(short_no_color); } @@ -611,8 +627,10 @@ mod multiline_overlapping { } test_emit!(rich_color); + test_emit!(medium_color); test_emit!(short_color); test_emit!(rich_no_color); + test_emit!(medium_no_color); test_emit!(short_no_color); } @@ -816,6 +834,7 @@ mod unicode { } test_emit!(rich_no_color); + test_emit!(medium_no_color); test_emit!(short_no_color); } @@ -866,6 +885,7 @@ mod unicode_spans { } test_emit!(rich_no_color); + test_emit!(medium_no_color); test_emit!(short_no_color); } @@ -901,6 +921,7 @@ mod position_indicator { } test_emit!(rich_no_color); + test_emit!(medium_no_color); test_emit!(short_no_color); } From 99c320f2e6b83259cdedec3b4376e79a72e56e37 Mon Sep 17 00:00:00 2001 From: Johann150 <20990607+Johann150@users.noreply.github.com> Date: Sat, 22 Aug 2020 16:26:09 +0200 Subject: [PATCH 4/4] remove empty line also adjusted tests --- codespan-reporting/src/term/views.rs | 1 - .../tests/snapshots/term__empty__medium_color.snap | 6 ------ .../tests/snapshots/term__empty__medium_no_color.snap | 6 ------ .../tests/snapshots/term__empty_ranges__medium_color.snap | 4 ---- .../snapshots/term__empty_ranges__medium_no_color.snap | 4 ---- .../tests/snapshots/term__fizz_buzz__medium_color.snap | 2 -- .../tests/snapshots/term__fizz_buzz__medium_no_color.snap | 2 -- .../tests/snapshots/term__message__medium_color.snap | 4 ---- .../tests/snapshots/term__message__medium_no_color.snap | 4 ---- .../snapshots/term__message_and_notes__medium_color.snap | 4 ---- .../term__message_and_notes__medium_no_color.snap | 4 ---- .../tests/snapshots/term__multifile__medium_color.snap | 3 --- .../tests/snapshots/term__multifile__medium_no_color.snap | 3 --- .../tests/snapshots/term__overlapping__medium_color.snap | 5 ----- .../snapshots/term__overlapping__medium_no_color.snap | 5 ----- .../tests/snapshots/term__same_line__medium_color.snap | 2 -- .../tests/snapshots/term__same_line__medium_no_color.snap | 2 -- .../tests/snapshots/term__unicode__medium_no_color.snap | 2 -- .../snapshots/term__unicode_spans__medium_no_color.snap | 8 ++------ 19 files changed, 2 insertions(+), 69 deletions(-) diff --git a/codespan-reporting/src/term/views.rs b/codespan-reporting/src/term/views.rs index d9ac875..2c40154 100644 --- a/codespan-reporting/src/term/views.rs +++ b/codespan-reporting/src/term/views.rs @@ -489,7 +489,6 @@ where for note in &self.diagnostic.notes { renderer.render_snippet_note(0, note)?; } - renderer.render_empty()?; } Ok(()) diff --git a/codespan-reporting/tests/snapshots/term__empty__medium_color.snap b/codespan-reporting/tests/snapshots/term__empty__medium_color.snap index f94d46b..e4a14fb 100644 --- a/codespan-reporting/tests/snapshots/term__empty__medium_color.snap +++ b/codespan-reporting/tests/snapshots/term__empty__medium_color.snap @@ -3,15 +3,9 @@ source: codespan-reporting/tests/term.rs expression: TEST_DATA.emit_color(&config) --- {fg:Red bold bright}bug{bold bright}: {/} - {fg:Red bold bright}error{bold bright}: {/} - {fg:Yellow bold bright}warning{bold bright}: {/} - {fg:Green bold bright}note{bold bright}: {/} - {fg:Cyan bold bright}help{bold bright}: {/} - {fg:Red bold bright}bug{bold bright}: {/} - diff --git a/codespan-reporting/tests/snapshots/term__empty__medium_no_color.snap b/codespan-reporting/tests/snapshots/term__empty__medium_no_color.snap index 1ec1a94..6a8bf45 100644 --- a/codespan-reporting/tests/snapshots/term__empty__medium_no_color.snap +++ b/codespan-reporting/tests/snapshots/term__empty__medium_no_color.snap @@ -3,15 +3,9 @@ source: codespan-reporting/tests/term.rs expression: TEST_DATA.emit_no_color(&config) --- bug: - error: - warning: - note: - help: - bug: - diff --git a/codespan-reporting/tests/snapshots/term__empty_ranges__medium_color.snap b/codespan-reporting/tests/snapshots/term__empty_ranges__medium_color.snap index 0226779..3713ee4 100644 --- a/codespan-reporting/tests/snapshots/term__empty_ranges__medium_color.snap +++ b/codespan-reporting/tests/snapshots/term__empty_ranges__medium_color.snap @@ -3,11 +3,7 @@ source: codespan-reporting/tests/term.rs expression: TEST_DATA.emit_color(&config) --- hello:1:7: {fg:Green bold bright}note{bold bright}: middle{/} - hello:1:13: {fg:Green bold bright}note{bold bright}: end of line{/} - hello:2:11: {fg:Green bold bright}note{bold bright}: end of line{/} - hello:3:4: {fg:Green bold bright}note{bold bright}: end of file{/} - diff --git a/codespan-reporting/tests/snapshots/term__empty_ranges__medium_no_color.snap b/codespan-reporting/tests/snapshots/term__empty_ranges__medium_no_color.snap index 150ca86..635a830 100644 --- a/codespan-reporting/tests/snapshots/term__empty_ranges__medium_no_color.snap +++ b/codespan-reporting/tests/snapshots/term__empty_ranges__medium_no_color.snap @@ -3,11 +3,7 @@ source: codespan-reporting/tests/term.rs expression: TEST_DATA.emit_no_color(&config) --- hello:1:7: note: middle - hello:1:13: note: end of line - hello:2:11: note: end of line - hello:3:4: note: end of file - diff --git a/codespan-reporting/tests/snapshots/term__fizz_buzz__medium_color.snap b/codespan-reporting/tests/snapshots/term__fizz_buzz__medium_color.snap index ab60435..ef97c2c 100644 --- a/codespan-reporting/tests/snapshots/term__fizz_buzz__medium_color.snap +++ b/codespan-reporting/tests/snapshots/term__fizz_buzz__medium_color.snap @@ -5,9 +5,7 @@ expression: TEST_DATA.emit_color(&config) FizzBuzz.fun:8:12: {fg:Red bold bright}error[E0308]{bold bright}: `case` clauses have incompatible types{/} {fg:Blue}={/} expected type `String` found type `Nat` - FizzBuzz.fun:16:16: {fg:Red bold bright}error[E0308]{bold bright}: `case` clauses have incompatible types{/} {fg:Blue}={/} expected type `String` found type `Nat` - diff --git a/codespan-reporting/tests/snapshots/term__fizz_buzz__medium_no_color.snap b/codespan-reporting/tests/snapshots/term__fizz_buzz__medium_no_color.snap index 77a48af..1120064 100644 --- a/codespan-reporting/tests/snapshots/term__fizz_buzz__medium_no_color.snap +++ b/codespan-reporting/tests/snapshots/term__fizz_buzz__medium_no_color.snap @@ -5,9 +5,7 @@ expression: TEST_DATA.emit_no_color(&config) FizzBuzz.fun:8:12: error[E0308]: `case` clauses have incompatible types = expected type `String` found type `Nat` - FizzBuzz.fun:16:16: error[E0308]: `case` clauses have incompatible types = expected type `String` found type `Nat` - diff --git a/codespan-reporting/tests/snapshots/term__message__medium_color.snap b/codespan-reporting/tests/snapshots/term__message__medium_color.snap index c1bd423..f0b16d8 100644 --- a/codespan-reporting/tests/snapshots/term__message__medium_color.snap +++ b/codespan-reporting/tests/snapshots/term__message__medium_color.snap @@ -3,11 +3,7 @@ source: codespan-reporting/tests/term.rs expression: TEST_DATA.emit_color(&config) --- {fg:Red bold bright}error{bold bright}: a message{/} - {fg:Yellow bold bright}warning{bold bright}: a message{/} - {fg:Green bold bright}note{bold bright}: a message{/} - {fg:Cyan bold bright}help{bold bright}: a message{/} - diff --git a/codespan-reporting/tests/snapshots/term__message__medium_no_color.snap b/codespan-reporting/tests/snapshots/term__message__medium_no_color.snap index d3abe84..43565ac 100644 --- a/codespan-reporting/tests/snapshots/term__message__medium_no_color.snap +++ b/codespan-reporting/tests/snapshots/term__message__medium_no_color.snap @@ -3,11 +3,7 @@ source: codespan-reporting/tests/term.rs expression: TEST_DATA.emit_no_color(&config) --- error: a message - warning: a message - note: a message - help: a message - diff --git a/codespan-reporting/tests/snapshots/term__message_and_notes__medium_color.snap b/codespan-reporting/tests/snapshots/term__message_and_notes__medium_color.snap index 56900e8..f44b2a4 100644 --- a/codespan-reporting/tests/snapshots/term__message_and_notes__medium_color.snap +++ b/codespan-reporting/tests/snapshots/term__message_and_notes__medium_color.snap @@ -4,14 +4,10 @@ expression: TEST_DATA.emit_color(&config) --- {fg:Red bold bright}error{bold bright}: a message{/} {fg:Blue}={/} a note - {fg:Yellow bold bright}warning{bold bright}: a message{/} {fg:Blue}={/} a note - {fg:Green bold bright}note{bold bright}: a message{/} {fg:Blue}={/} a note - {fg:Cyan bold bright}help{bold bright}: a message{/} {fg:Blue}={/} a note - diff --git a/codespan-reporting/tests/snapshots/term__message_and_notes__medium_no_color.snap b/codespan-reporting/tests/snapshots/term__message_and_notes__medium_no_color.snap index d4e209b..bab7a65 100644 --- a/codespan-reporting/tests/snapshots/term__message_and_notes__medium_no_color.snap +++ b/codespan-reporting/tests/snapshots/term__message_and_notes__medium_no_color.snap @@ -4,14 +4,10 @@ expression: TEST_DATA.emit_no_color(&config) --- error: a message = a note - warning: a message = a note - note: a message = a note - help: a message = a note - diff --git a/codespan-reporting/tests/snapshots/term__multifile__medium_color.snap b/codespan-reporting/tests/snapshots/term__multifile__medium_color.snap index 5e0c3f9..6c03d83 100644 --- a/codespan-reporting/tests/snapshots/term__multifile__medium_color.snap +++ b/codespan-reporting/tests/snapshots/term__multifile__medium_color.snap @@ -4,12 +4,9 @@ expression: TEST_DATA.emit_color(&config) --- Data/Nat.fun:7:13: {fg:Red bold bright}error{bold bright}: unknown builtin: `NATRAL`{/} {fg:Blue}={/} there is a builtin with a similar name: `NATURAL` - Data/Nat.fun:17:16: {fg:Yellow bold bright}warning{bold bright}: unused parameter pattern: `n₂`{/} {fg:Blue}={/} consider using a wildcard pattern: `_` - Test.fun:4:11: {fg:Red bold bright}error[E0001]{bold bright}: unexpected type in application of `_+_`{/} {fg:Blue}={/} expected type `Nat` found type `String` - diff --git a/codespan-reporting/tests/snapshots/term__multifile__medium_no_color.snap b/codespan-reporting/tests/snapshots/term__multifile__medium_no_color.snap index f0bf796..db33fc0 100644 --- a/codespan-reporting/tests/snapshots/term__multifile__medium_no_color.snap +++ b/codespan-reporting/tests/snapshots/term__multifile__medium_no_color.snap @@ -4,12 +4,9 @@ expression: TEST_DATA.emit_no_color(&config) --- Data/Nat.fun:7:13: error: unknown builtin: `NATRAL` = there is a builtin with a similar name: `NATURAL` - Data/Nat.fun:17:16: warning: unused parameter pattern: `n₂` = consider using a wildcard pattern: `_` - Test.fun:4:11: error[E0001]: unexpected type in application of `_+_` = expected type `Nat` found type `String` - diff --git a/codespan-reporting/tests/snapshots/term__overlapping__medium_color.snap b/codespan-reporting/tests/snapshots/term__overlapping__medium_color.snap index 578353d..9ccf3e5 100644 --- a/codespan-reporting/tests/snapshots/term__overlapping__medium_color.snap +++ b/codespan-reporting/tests/snapshots/term__overlapping__medium_color.snap @@ -3,20 +3,15 @@ source: codespan-reporting/tests/term.rs expression: TEST_DATA.emit_color(&config) --- nested_impl_trait.rs:5:56: {fg:Red bold bright}error[E0666]{bold bright}: nested `impl Trait` is not allowed{/} - typeck_type_placeholder_item.rs:1:18: {fg:Red bold bright}error[E0121]{bold bright}: the type placeholder `_` is not allowed within types on item signatures{/} - typeck_type_placeholder_item.rs:2:25: {fg:Red bold bright}error[E0121]{bold bright}: the type placeholder `_` is not allowed within types on item signatures{/} typeck_type_placeholder_item.rs:2:28: {fg:Red bold bright}error[E0121]{bold bright}: the type placeholder `_` is not allowed within types on item signatures{/} - no_send_res_ports.rs:25:5: {fg:Red bold bright}error[E0277]{bold bright}: `std::rc::Rc<()>` cannot be sent between threads safely{/} {fg:Blue}={/} help: within `[closure@no_send_res_ports.rs:29:19: 33:6 x:main::Foo]`, the trait `std::marker::Send` is not implemented for `std::rc::Rc<()>` {fg:Blue}={/} note: required because it appears within the type `Port<()>` {fg:Blue}={/} note: required because it appears within the type `main::Foo` {fg:Blue}={/} note: required because it appears within the type `[closure@no_send_res_ports.rs:29:19: 33:6 x:main::Foo]` - {fg:Red bold bright}error{bold bright}: aborting due 5 previous errors{/} {fg:Blue}={/} Some errors have detailed explanations: E0121, E0277, E0666. {fg:Blue}={/} For more information about an error, try `rustc --explain E0121`. - diff --git a/codespan-reporting/tests/snapshots/term__overlapping__medium_no_color.snap b/codespan-reporting/tests/snapshots/term__overlapping__medium_no_color.snap index 07b65d9..3b9eac9 100644 --- a/codespan-reporting/tests/snapshots/term__overlapping__medium_no_color.snap +++ b/codespan-reporting/tests/snapshots/term__overlapping__medium_no_color.snap @@ -3,20 +3,15 @@ source: codespan-reporting/tests/term.rs expression: TEST_DATA.emit_no_color(&config) --- nested_impl_trait.rs:5:56: error[E0666]: nested `impl Trait` is not allowed - typeck_type_placeholder_item.rs:1:18: error[E0121]: the type placeholder `_` is not allowed within types on item signatures - typeck_type_placeholder_item.rs:2:25: error[E0121]: the type placeholder `_` is not allowed within types on item signatures typeck_type_placeholder_item.rs:2:28: error[E0121]: the type placeholder `_` is not allowed within types on item signatures - no_send_res_ports.rs:25:5: error[E0277]: `std::rc::Rc<()>` cannot be sent between threads safely = help: within `[closure@no_send_res_ports.rs:29:19: 33:6 x:main::Foo]`, the trait `std::marker::Send` is not implemented for `std::rc::Rc<()>` = note: required because it appears within the type `Port<()>` = note: required because it appears within the type `main::Foo` = note: required because it appears within the type `[closure@no_send_res_ports.rs:29:19: 33:6 x:main::Foo]` - error: aborting due 5 previous errors = Some errors have detailed explanations: E0121, E0277, E0666. = For more information about an error, try `rustc --explain E0121`. - diff --git a/codespan-reporting/tests/snapshots/term__same_line__medium_color.snap b/codespan-reporting/tests/snapshots/term__same_line__medium_color.snap index 4c1a1b2..43e1eb0 100644 --- a/codespan-reporting/tests/snapshots/term__same_line__medium_color.snap +++ b/codespan-reporting/tests/snapshots/term__same_line__medium_color.snap @@ -3,8 +3,6 @@ source: codespan-reporting/tests/term.rs expression: TEST_DATA.emit_color(&config) --- one_line.rs:3:12: {fg:Red bold bright}error[E0499]{bold bright}: cannot borrow `v` as mutable more than once at a time{/} - {fg:Red bold bright}error{bold bright}: aborting due to previous error{/} {fg:Blue}={/} For more information about this error, try `rustc --explain E0499`. - diff --git a/codespan-reporting/tests/snapshots/term__same_line__medium_no_color.snap b/codespan-reporting/tests/snapshots/term__same_line__medium_no_color.snap index 7301a69..6bb55ed 100644 --- a/codespan-reporting/tests/snapshots/term__same_line__medium_no_color.snap +++ b/codespan-reporting/tests/snapshots/term__same_line__medium_no_color.snap @@ -3,8 +3,6 @@ source: codespan-reporting/tests/term.rs expression: TEST_DATA.emit_no_color(&config) --- one_line.rs:3:12: error[E0499]: cannot borrow `v` as mutable more than once at a time - error: aborting due to previous error = For more information about this error, try `rustc --explain E0499`. - diff --git a/codespan-reporting/tests/snapshots/term__unicode__medium_no_color.snap b/codespan-reporting/tests/snapshots/term__unicode__medium_no_color.snap index a04bdc8..b5f8780 100644 --- a/codespan-reporting/tests/snapshots/term__unicode__medium_no_color.snap +++ b/codespan-reporting/tests/snapshots/term__unicode__medium_no_color.snap @@ -24,8 +24,6 @@ unicode.rs:1:8: error[E0703]: invalid ABI: found `路濫狼á́́` - vectorcall - win64 - x86-interrupt - error: aborting due to previous error = For more information about this error, try `rustc --explain E0703`. - diff --git a/codespan-reporting/tests/snapshots/term__unicode_spans__medium_no_color.snap b/codespan-reporting/tests/snapshots/term__unicode_spans__medium_no_color.snap index 71622b0..1b19451 100644 --- a/codespan-reporting/tests/snapshots/term__unicode_spans__medium_no_color.snap +++ b/codespan-reporting/tests/snapshots/term__unicode_spans__medium_no_color.snap @@ -3,11 +3,7 @@ source: codespan-reporting/tests/term.rs expression: TEST_DATA.emit_no_color(&config) --- moon_jump.rs:1:1: error[E01]: cow may not jump during new moon. - +note: invalid unicode range +note: invalid unicode range note: invalid unicode range -note: invalid unicode range - -note: invalid unicode range - -