summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHaibo Huang <hhb@google.com>2020-07-16 00:46:38 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-07-16 00:46:38 +0000
commit54d0e607625eb8e7398311bb126567ecde3e19bb (patch)
treec712b15986657e2a7071818de121771eca64276a /tests
parent3091f00e0bc9c566298da7c28693c05f08d7cb2c (diff)
parent688e0e8c1f55a91198d38c63a6f0ba1b55954fc1 (diff)
downloadcodespan-reporting-54d0e607625eb8e7398311bb126567ecde3e19bb.tar.gz
Upgrade rust/crates/codespan-reporting to 0.9.5 am: 688e0e8c1f
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/codespan-reporting/+/1361025 Change-Id: Ibb873f6068078d457fbaf5507fa3c18e1aafaf2c
Diffstat (limited to 'tests')
-rw-r--r--tests/snapshots/term__empty_ranges__rich_color.snap17
-rw-r--r--tests/snapshots/term__empty_ranges__rich_no_color.snap11
-rw-r--r--tests/snapshots/term__empty_ranges__short_color.snap3
-rw-r--r--tests/snapshots/term__empty_ranges__short_no_color.snap3
-rw-r--r--tests/snapshots/term__fizz_buzz__rich_color.snap18
-rw-r--r--tests/snapshots/term__multifile__rich_color.snap14
-rw-r--r--tests/snapshots/term__multiline_overlapping__rich_color.snap12
-rw-r--r--tests/snapshots/term__overlapping__rich_color.snap58
-rw-r--r--tests/snapshots/term__overlapping__rich_no_color.snap58
-rw-r--r--tests/snapshots/term__overlapping__short_color.snap11
-rw-r--r--tests/snapshots/term__overlapping__short_no_color.snap11
-rw-r--r--tests/snapshots/term__same_line__rich_color.snap (renamed from tests/snapshots/term__one_line__rich_color.snap)10
-rw-r--r--tests/snapshots/term__same_line__rich_no_color.snap (renamed from tests/snapshots/term__one_line__rich_no_color.snap)8
-rw-r--r--tests/snapshots/term__same_line__short_color.snap (renamed from tests/snapshots/term__one_line__short_color.snap)0
-rw-r--r--tests/snapshots/term__same_line__short_no_color.snap (renamed from tests/snapshots/term__one_line__short_no_color.snap)0
-rw-r--r--tests/snapshots/term__same_ranges__rich_color.snap9
-rw-r--r--tests/snapshots/term__same_ranges__rich_no_color.snap7
-rw-r--r--tests/snapshots/term__tab_columns__tab_width_2_no_color.snap23
-rw-r--r--tests/snapshots/term__tab_columns__tab_width_3_no_color.snap23
-rw-r--r--tests/snapshots/term__tab_columns__tab_width_6_no_color.snap23
-rw-r--r--tests/snapshots/term__tab_columns__tab_width_default_no_color.snap23
-rw-r--r--tests/snapshots/term__tabbed__tab_width_3_no_color.snap7
-rw-r--r--tests/snapshots/term__tabbed__tab_width_6_no_color.snap7
-rw-r--r--tests/snapshots/term__tabbed__tab_width_default_no_color.snap7
-rw-r--r--tests/snapshots/term__unicode_spans__rich_no_color.snap20
-rw-r--r--tests/snapshots/term__unicode_spans__short_no_color.snap3
-rw-r--r--tests/term.rs268
27 files changed, 568 insertions, 86 deletions
diff --git a/tests/snapshots/term__empty_ranges__rich_color.snap b/tests/snapshots/term__empty_ranges__rich_color.snap
index d1e9a2e..89bb2c0 100644
--- a/tests/snapshots/term__empty_ranges__rich_color.snap
+++ b/tests/snapshots/term__empty_ranges__rich_color.snap
@@ -5,22 +5,25 @@ expression: TEST_DATA.emit_color(&config)
{fg:Green bold bright}note{bold bright}: middle{/}
{fg:Blue}┌─{/} hello:1:7
{fg:Blue}│{/}
-{fg:Blue}1{/} {fg:Blue}│{/} Hello world!
- {fg:Blue}│{/} {fg:Green}^ middle{/}
- {fg:Blue}│{/}
+{fg:Blue}1{/} {fg:Blue}│{/} Hello {fg:Green}w{/}orld!
+ {fg:Blue}│{/} {fg:Green}^{/} {fg:Green}middle{/}
{fg:Green bold bright}note{bold bright}: end of line{/}
{fg:Blue}┌─{/} hello:1:13
{fg:Blue}│{/}
{fg:Blue}1{/} {fg:Blue}│{/} Hello world!
- {fg:Blue}│{/} {fg:Green}^ end of line{/}
- {fg:Blue}│{/}
+ {fg:Blue}│{/} {fg:Green}^{/} {fg:Green}end of line{/}
-{fg:Green bold bright}note{bold bright}: end of file{/}
+{fg:Green bold bright}note{bold bright}: end of line{/}
{fg:Blue}┌─{/} hello:2:11
{fg:Blue}│{/}
{fg:Blue}2{/} {fg:Blue}│{/} Bye world!
- {fg:Blue}│{/} {fg:Green}^ end of file{/}
+ {fg:Blue}│{/} {fg:Green}^{/} {fg:Green}end of line{/}
+
+{fg:Green bold bright}note{bold bright}: end of file{/}
+ {fg:Blue}┌─{/} hello:3:4
{fg:Blue}│{/}
+{fg:Blue}3{/} {fg:Blue}│{/}
+ {fg:Blue}│{/} {fg:Green}^{/} {fg:Green}end of file{/}
diff --git a/tests/snapshots/term__empty_ranges__rich_no_color.snap b/tests/snapshots/term__empty_ranges__rich_no_color.snap
index fa28550..862605c 100644
--- a/tests/snapshots/term__empty_ranges__rich_no_color.snap
+++ b/tests/snapshots/term__empty_ranges__rich_no_color.snap
@@ -7,20 +7,23 @@ note: middle
1 │ Hello world!
│ ^ middle
- │
note: end of line
┌─ hello:1:13
1 │ Hello world!
│ ^ end of line
- │
-note: end of file
+note: end of line
┌─ hello:2:11
2 │ Bye world!
- │ ^ end of file
+ │ ^ end of line
+
+note: end of file
+ ┌─ hello:3:4
+3 │
+ │ ^ end of file
diff --git a/tests/snapshots/term__empty_ranges__short_color.snap b/tests/snapshots/term__empty_ranges__short_color.snap
index b3930e0..3713ee4 100644
--- a/tests/snapshots/term__empty_ranges__short_color.snap
+++ b/tests/snapshots/term__empty_ranges__short_color.snap
@@ -4,5 +4,6 @@ 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 file{/}
+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/tests/snapshots/term__empty_ranges__short_no_color.snap b/tests/snapshots/term__empty_ranges__short_no_color.snap
index 5e2edfc..635a830 100644
--- a/tests/snapshots/term__empty_ranges__short_no_color.snap
+++ b/tests/snapshots/term__empty_ranges__short_no_color.snap
@@ -4,5 +4,6 @@ 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 file
+hello:2:11: note: end of line
+hello:3:4: note: end of file
diff --git a/tests/snapshots/term__fizz_buzz__rich_color.snap b/tests/snapshots/term__fizz_buzz__rich_color.snap
index 63bfdb9..a051eef 100644
--- a/tests/snapshots/term__fizz_buzz__rich_color.snap
+++ b/tests/snapshots/term__fizz_buzz__rich_color.snap
@@ -6,14 +6,14 @@ expression: TEST_DATA.emit_color(&config)
{fg:Blue}┌─{/} FizzBuzz.fun:3:15
{fg:Blue}│{/}
{fg:Blue}3{/} {fg:Blue}│{/} fizz₁ : Nat → String
- {fg:Blue}│{/} {fg:Blue}------ expected type `String` found here{/}
+ {fg:Blue}│{/} {fg:Blue}------{/} {fg:Blue}expected type `String` found here{/}
{fg:Blue}4{/} {fg:Blue}│{/} fizz₁ num = case (mod num 5) (mod num 3) of
{fg:Blue}│{/} {fg:Blue}╭{/}{fg:Blue}─────────────'{/}
{fg:Blue}5{/} {fg:Blue}│{/} {fg:Blue}│{/} 0 0 => "FizzBuzz"
{fg:Blue}6{/} {fg:Blue}│{/} {fg:Blue}│{/} 0 _ => "Fizz"
{fg:Blue}7{/} {fg:Blue}│{/} {fg:Blue}│{/} _ 0 => "Buzz"
-{fg:Blue}8{/} {fg:Blue}│{/} {fg:Blue}│{/} _ _ => num
- {fg:Blue}│{/} {fg:Blue}│{/} {fg:Red}^^^ expected `String`, found `Nat`{/}
+{fg:Blue}8{/} {fg:Blue}│{/} {fg:Blue}│{/} _ _ => {fg:Red}num{/}
+ {fg:Blue}│{/} {fg:Blue}│{/} {fg:Red}^^^{/} {fg:Red}expected `String`, found `Nat`{/}
{fg:Blue}│{/} {fg:Blue}╰{/}{fg:Blue}──────────────' `case` clauses have incompatible types{/}
{fg:Blue}│{/}
{fg:Blue}={/} expected type `String`
@@ -23,17 +23,17 @@ expression: TEST_DATA.emit_color(&config)
{fg:Blue}┌─{/} FizzBuzz.fun:10:15
{fg:Blue}│{/}
{fg:Blue}10{/} {fg:Blue}│{/} fizz₂ : Nat → String
- {fg:Blue}│{/} {fg:Blue}------ expected type `String` found here{/}
+ {fg:Blue}│{/} {fg:Blue}------{/} {fg:Blue}expected type `String` found here{/}
{fg:Blue}11{/} {fg:Blue}│{/} fizz₂ num =
{fg:Blue}12{/} {fg:Blue}│{/} {fg:Blue}╭{/} case (mod num 5) (mod num 3) of
{fg:Blue}13{/} {fg:Blue}│{/} {fg:Blue}│{/} 0 0 => "FizzBuzz"
- {fg:Blue}│{/} {fg:Blue}│{/} {fg:Blue}---------- this is found to be of type `String`{/}
+ {fg:Blue}│{/} {fg:Blue}│{/} {fg:Blue}----------{/} {fg:Blue}this is found to be of type `String`{/}
{fg:Blue}14{/} {fg:Blue}│{/} {fg:Blue}│{/} 0 _ => "Fizz"
- {fg:Blue}│{/} {fg:Blue}│{/} {fg:Blue}------ this is found to be of type `String`{/}
+ {fg:Blue}│{/} {fg:Blue}│{/} {fg:Blue}------{/} {fg:Blue}this is found to be of type `String`{/}
{fg:Blue}15{/} {fg:Blue}│{/} {fg:Blue}│{/} _ 0 => "Buzz"
- {fg:Blue}│{/} {fg:Blue}│{/} {fg:Blue}------ this is found to be of type `String`{/}
-{fg:Blue}16{/} {fg:Blue}│{/} {fg:Blue}│{/} _ _ => num
- {fg:Blue}│{/} {fg:Blue}│{/} {fg:Red}^^^ expected `String`, found `Nat`{/}
+ {fg:Blue}│{/} {fg:Blue}│{/} {fg:Blue}------{/} {fg:Blue}this is found to be of type `String`{/}
+{fg:Blue}16{/} {fg:Blue}│{/} {fg:Blue}│{/} _ _ => {fg:Red}num{/}
+ {fg:Blue}│{/} {fg:Blue}│{/} {fg:Red}^^^{/} {fg:Red}expected `String`, found `Nat`{/}
{fg:Blue}│{/} {fg:Blue}╰{/}{fg:Blue}──────────────────' `case` clauses have incompatible types{/}
{fg:Blue}│{/}
{fg:Blue}={/} expected type `String`
diff --git a/tests/snapshots/term__multifile__rich_color.snap b/tests/snapshots/term__multifile__rich_color.snap
index 5c3be31..514be49 100644
--- a/tests/snapshots/term__multifile__rich_color.snap
+++ b/tests/snapshots/term__multifile__rich_color.snap
@@ -5,29 +5,29 @@ expression: TEST_DATA.emit_color(&config)
{fg:Red bold bright}error{bold bright}: unknown builtin: `NATRAL`{/}
{fg:Blue}┌─{/} Data/Nat.fun:7:13
{fg:Blue}│{/}
-{fg:Blue}7{/} {fg:Blue}│{/} {-# BUILTIN NATRAL Nat #-}
- {fg:Blue}│{/} {fg:Red}^^^^^^ unknown builtin{/}
+{fg:Blue}7{/} {fg:Blue}│{/} {-# BUILTIN {fg:Red}NATRAL{/} Nat #-}
+ {fg:Blue}│{/} {fg:Red}^^^^^^{/} {fg:Red}unknown builtin{/}
{fg:Blue}│{/}
{fg:Blue}={/} there is a builtin with a similar name: `NATURAL`
{fg:Yellow bold bright}warning{bold bright}: unused parameter pattern: `n₂`{/}
{fg:Blue}┌─{/} Data/Nat.fun:17:16
{fg:Blue}│{/}
-{fg:Blue}17{/} {fg:Blue}│{/} zero - succ n₂ = zero
- {fg:Blue}│{/} {fg:Yellow}^^ unused parameter{/}
+{fg:Blue}17{/} {fg:Blue}│{/} zero - succ {fg:Yellow}n₂{/} = zero
+ {fg:Blue}│{/} {fg:Yellow}^^{/} {fg:Yellow}unused parameter{/}
{fg:Blue}│{/}
{fg:Blue}={/} consider using a wildcard pattern: `_`
{fg:Red bold bright}error[E0001]{bold bright}: unexpected type in application of `_+_`{/}
{fg:Blue}┌─{/} Test.fun:4:11
{fg:Blue}│{/}
-{fg:Blue} 4{/} {fg:Blue}│{/} _ = 123 + "hello"
- {fg:Blue}│{/} {fg:Red}^^^^^^^ expected `Nat`, found `String`{/}
+{fg:Blue} 4{/} {fg:Blue}│{/} _ = 123 + {fg:Red}"hello"{/}
+ {fg:Blue}│{/} {fg:Red}^^^^^^^{/} {fg:Red}expected `Nat`, found `String`{/}
{fg:Blue}│{/}
{fg:Blue}┌─{/} Data/Nat.fun:11:1
{fg:Blue}│{/}
{fg:Blue}11{/} {fg:Blue}│{/} _+_ : Nat → Nat → Nat
- {fg:Blue}│{/} {fg:Blue}--------------------- based on the definition of `_+_`{/}
+ {fg:Blue}│{/} {fg:Blue}---------------------{/} {fg:Blue}based on the definition of `_+_`{/}
{fg:Blue}│{/}
{fg:Blue}={/} expected type `Nat`
found type `String`
diff --git a/tests/snapshots/term__multiline_overlapping__rich_color.snap b/tests/snapshots/term__multiline_overlapping__rich_color.snap
index 87f8bed..fee20e1 100644
--- a/tests/snapshots/term__multiline_overlapping__rich_color.snap
+++ b/tests/snapshots/term__multiline_overlapping__rich_color.snap
@@ -7,14 +7,14 @@ expression: TEST_DATA.emit_color(&config)
{fg:Blue}│{/}
{fg:Blue}1{/} {fg:Blue}│{/} {fg:Blue}╭{/} match line_index.compare(self.last_line_index()) {
{fg:Blue}2{/} {fg:Blue}│{/} {fg:Blue}│{/} Ordering::Less => Ok(self.line_starts()[line_index.to_usize()]),
- {fg:Blue}│{/} {fg:Blue}│{/} {fg:Blue}--------------------------------------------- this is found to be of type `Result<ByteIndex, LineIndexOutOfBoundsError>`{/}
+ {fg:Blue}│{/} {fg:Blue}│{/} {fg:Blue}---------------------------------------------{/} {fg:Blue}this is found to be of type `Result<ByteIndex, LineIndexOutOfBoundsError>`{/}
{fg:Blue}3{/} {fg:Blue}│{/} {fg:Blue}│{/} Ordering::Equal => Ok(self.source_span().end()),
- {fg:Blue}│{/} {fg:Blue}│{/} {fg:Blue}---------------------------- this is found to be of type `Result<ByteIndex, LineIndexOutOfBoundsError>`{/}
-{fg:Blue}4{/} {fg:Blue}│{/} {fg:Blue}│{/} Ordering::Greater => LineIndexOutOfBoundsError {
+ {fg:Blue}│{/} {fg:Blue}│{/} {fg:Blue}----------------------------{/} {fg:Blue}this is found to be of type `Result<ByteIndex, LineIndexOutOfBoundsError>`{/}
+{fg:Blue}4{/} {fg:Blue}│{/} {fg:Blue}│{/} Ordering::Greater => {fg:Red}LineIndexOutOfBoundsError {{/}
{fg:Blue}│{/} {fg:Red}╭{/}{fg:Red}─{/}{fg:Blue}│{/}{fg:Red}──────────────────────────────────^{/}
-{fg:Blue}5{/} {fg:Blue}│{/} {fg:Red}│{/} {fg:Blue}│{/} given: line_index,
-{fg:Blue}6{/} {fg:Blue}│{/} {fg:Red}│{/} {fg:Blue}│{/} max: self.last_line_index(),
-{fg:Blue}7{/} {fg:Blue}│{/} {fg:Red}│{/} {fg:Blue}│{/} },
+{fg:Blue}5{/} {fg:Blue}│{/} {fg:Red}│{/} {fg:Blue}│{/} {fg:Red} given: line_index,{/}
+{fg:Blue}6{/} {fg:Blue}│{/} {fg:Red}│{/} {fg:Blue}│{/} {fg:Red} max: self.last_line_index(),{/}
+{fg:Blue}7{/} {fg:Blue}│{/} {fg:Red}│{/} {fg:Blue}│{/} {fg:Red} }{/},
{fg:Blue}│{/} {fg:Red}╰{/}{fg:Red}─{/}{fg:Blue}│{/}{fg:Red}─────────────^ expected enum `Result`, found struct `LineIndexOutOfBoundsError`{/}
{fg:Blue}8{/} {fg:Blue}│{/} {fg:Blue}│{/} }
{fg:Blue}│{/} {fg:Blue}╰{/}{fg:Blue}─────────' `match` arms have incompatible types{/}
diff --git a/tests/snapshots/term__overlapping__rich_color.snap b/tests/snapshots/term__overlapping__rich_color.snap
new file mode 100644
index 0000000..92f061f
--- /dev/null
+++ b/tests/snapshots/term__overlapping__rich_color.snap
@@ -0,0 +1,58 @@
+---
+source: codespan-reporting/tests/term.rs
+expression: TEST_DATA.emit_color(&config)
+---
+{fg:Red bold bright}error[E0666]{bold bright}: nested `impl Trait` is not allowed{/}
+ {fg:Blue}┌─{/} nested_impl_trait.rs:5:46
+ {fg:Blue}│{/}
+{fg:Blue}5{/} {fg:Blue}│{/} fn bad_in_ret_position(x: impl Into<u32>) -> impl Into<{fg:Red}impl Debug{/}> { x }
+ {fg:Blue}│{/} {fg:Blue}----------{fg:Red}^^^^^^^^^^{fg:Blue}-{/}
+ {fg:Blue}│{/} {fg:Blue}│{/} {fg:Red}│{/}
+ {fg:Blue}│{/} {fg:Blue}│{/} {fg:Red}nested `impl Trait` here{/}
+ {fg:Blue}│{/} {fg:Blue}outer `impl Trait`{/}
+
+{fg:Red bold bright}error[E0121]{bold bright}: the type placeholder `_` is not allowed within types on item signatures{/}
+ {fg:Blue}┌─{/} typeck_type_placeholder_item.rs:1:18
+ {fg:Blue}│{/}
+{fg:Blue}1{/} {fg:Blue}│{/} fn fn_test1() -> {fg:Red}_{/} { 5 }
+ {fg:Blue}│{/} {fg:Red}^{/}
+ {fg:Blue}│{/} {fg:Red}│{/}
+ {fg:Blue}│{/} {fg:Red}not allowed in type signatures{/}
+ {fg:Blue}│{/} {fg:Blue}help: replace with the correct return type: `i32`{/}
+
+{fg:Red bold bright}error[E0121]{bold bright}: the type placeholder `_` is not allowed within types on item signatures{/}
+ {fg:Blue}┌─{/} typeck_type_placeholder_item.rs:2:24
+ {fg:Blue}│{/}
+{fg:Blue}2{/} {fg:Blue}│{/} fn fn_test2(x: i32) -> ({fg:Red}_{/}, {fg:Red}_{/}) { (x, x) }
+ {fg:Blue}│{/} {fg:Blue}-{fg:Red}^{fg:Blue}--{fg:Red}^{fg:Blue}-{/}
+ {fg:Blue}│{/} {fg:Blue}│{/}{fg:Red}│{/} {fg:Red}│{/}
+ {fg:Blue}│{/} {fg:Blue}│{/}{fg:Red}│{/} {fg:Red}not allowed in type signatures{/}
+ {fg:Blue}│{/} {fg:Blue}│{/}{fg:Red}not allowed in type signatures{/}
+ {fg:Blue}│{/} {fg:Blue}help: replace with the correct return type: `(i32, i32)`{/}
+
+{fg:Red bold bright}error[E0277]{bold bright}: `std::rc::Rc<()>` cannot be sent between threads safely{/}
+ {fg:Blue}┌─{/} no_send_res_ports.rs:25:5
+ {fg:Blue}│{/}
+{fg:Blue}25{/} {fg:Blue}│{/} {fg:Red}thread::spawn{/}(move|| {
+ {fg:Blue}│{/} {fg:Red}^^^^^^^^^^^^^{/} {fg:Red}`std::rc::Rc<()>` cannot be sent between threads safely{/}
+ {fg:Blue}│{/} {fg:Blue}╭{/}{fg:Blue}───────────────────'{/}
+{fg:Blue}26{/} {fg:Blue}│{/} {fg:Blue}│{/} let y = x;
+{fg:Blue}27{/} {fg:Blue}│{/} {fg:Blue}│{/} println!("{:?}", y);
+{fg:Blue}28{/} {fg:Blue}│{/} {fg:Blue}│{/} });
+ {fg:Blue}│{/} {fg:Blue}╰{/}{fg:Blue}──────' within this `[closure@no_send_res_ports.rs:29:19: 33:6 x:main::Foo]`{/}
+ {fg:Blue}│{/}
+ {fg:Blue}┌─{/} libstd/thread/mod.rs:5:8
+ {fg:Blue}│{/}
+{fg:Blue} 5{/} {fg:Blue}│{/} F: Send + 'static,
+ {fg:Blue}│{/} {fg:Blue}----{/} {fg:Blue}required by this bound in `std::thread::spawn`{/}
+ {fg:Blue}│{/}
+ {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/tests/snapshots/term__overlapping__rich_no_color.snap b/tests/snapshots/term__overlapping__rich_no_color.snap
new file mode 100644
index 0000000..e4a944d
--- /dev/null
+++ b/tests/snapshots/term__overlapping__rich_no_color.snap
@@ -0,0 +1,58 @@
+---
+source: codespan-reporting/tests/term.rs
+expression: TEST_DATA.emit_no_color(&config)
+---
+error[E0666]: nested `impl Trait` is not allowed
+ ┌─ nested_impl_trait.rs:5:46
+ │
+5 │ fn bad_in_ret_position(x: impl Into<u32>) -> impl Into<impl Debug> { x }
+ │ ----------^^^^^^^^^^-
+ │ │ │
+ │ │ nested `impl Trait` here
+ │ outer `impl Trait`
+
+error[E0121]: the type placeholder `_` is not allowed within types on item signatures
+ ┌─ typeck_type_placeholder_item.rs:1:18
+ │
+1 │ fn fn_test1() -> _ { 5 }
+ │ ^
+ │ │
+ │ not allowed in type signatures
+ │ help: replace with the correct return type: `i32`
+
+error[E0121]: the type placeholder `_` is not allowed within types on item signatures
+ ┌─ typeck_type_placeholder_item.rs:2:24
+ │
+2 │ fn fn_test2(x: i32) -> (_, _) { (x, x) }
+ │ -^--^-
+ │ ││ │
+ │ ││ not allowed in type signatures
+ │ │not allowed in type signatures
+ │ help: replace with the correct return type: `(i32, i32)`
+
+error[E0277]: `std::rc::Rc<()>` cannot be sent between threads safely
+ ┌─ no_send_res_ports.rs:25:5
+ │
+25 │ thread::spawn(move|| {
+ │ ^^^^^^^^^^^^^ `std::rc::Rc<()>` cannot be sent between threads safely
+ │ ╭───────────────────'
+26 │ │ let y = x;
+27 │ │ println!("{:?}", y);
+28 │ │ });
+ │ ╰──────' within this `[closure@no_send_res_ports.rs:29:19: 33:6 x:main::Foo]`
+ │
+ ┌─ libstd/thread/mod.rs:5:8
+ │
+ 5 │ F: Send + 'static,
+ │ ---- required by this bound in `std::thread::spawn`
+ │
+ = 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/tests/snapshots/term__overlapping__short_color.snap b/tests/snapshots/term__overlapping__short_color.snap
new file mode 100644
index 0000000..8e33cbf
--- /dev/null
+++ b/tests/snapshots/term__overlapping__short_color.snap
@@ -0,0 +1,11 @@
+---
+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:Red bold bright}error{bold bright}: aborting due 5 previous errors{/}
+
diff --git a/tests/snapshots/term__overlapping__short_no_color.snap b/tests/snapshots/term__overlapping__short_no_color.snap
new file mode 100644
index 0000000..47ed5db
--- /dev/null
+++ b/tests/snapshots/term__overlapping__short_no_color.snap
@@ -0,0 +1,11 @@
+---
+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
+error: aborting due 5 previous errors
+
diff --git a/tests/snapshots/term__one_line__rich_color.snap b/tests/snapshots/term__same_line__rich_color.snap
index 6f0a7f4..59bd616 100644
--- a/tests/snapshots/term__one_line__rich_color.snap
+++ b/tests/snapshots/term__same_line__rich_color.snap
@@ -5,11 +5,11 @@ expression: TEST_DATA.emit_color(&config)
{fg:Red bold bright}error[E0499]{bold bright}: cannot borrow `v` as mutable more than once at a time{/}
{fg:Blue}┌─{/} one_line.rs:3:5
{fg:Blue}│{/}
-{fg:Blue}3{/} {fg:Blue}│{/} v.push(v.pop().unwrap());
- {fg:Blue}│{/} {fg:Blue}- first borrow later used by call{/}
- {fg:Blue}│{/} {fg:Blue}---- first mutable borrow occurs here{/}
- {fg:Blue}│{/} {fg:Red}^ second mutable borrow occurs here{/}
- {fg:Blue}│{/}
+{fg:Blue}3{/} {fg:Blue}│{/} v.push({fg:Red}v{/}.pop().unwrap());
+ {fg:Blue}│{/} {fg:Blue}-{/} {fg:Blue}----{/} {fg:Red}^{/} {fg:Red}second mutable borrow occurs here{/}
+ {fg:Blue}│{/} {fg:Blue}│{/} {fg:Blue}│{/}
+ {fg:Blue}│{/} {fg:Blue}│{/} {fg:Blue}first mutable borrow occurs here{/}
+ {fg:Blue}│{/} {fg:Blue}first borrow later used by call{/}
{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/tests/snapshots/term__one_line__rich_no_color.snap b/tests/snapshots/term__same_line__rich_no_color.snap
index f857bf1..7342f3f 100644
--- a/tests/snapshots/term__one_line__rich_no_color.snap
+++ b/tests/snapshots/term__same_line__rich_no_color.snap
@@ -6,10 +6,10 @@ error[E0499]: cannot borrow `v` as mutable more than once at a time
┌─ one_line.rs:3:5
3 │ v.push(v.pop().unwrap());
- │ - first borrow later used by call
- │ ---- first mutable borrow occurs here
- │ ^ second mutable borrow occurs here
- │
+ │ - ---- ^ second mutable borrow occurs here
+ │ │ │
+ │ │ first mutable borrow occurs here
+ │ first borrow later used by call
error: aborting due to previous error
= For more information about this error, try `rustc --explain E0499`.
diff --git a/tests/snapshots/term__one_line__short_color.snap b/tests/snapshots/term__same_line__short_color.snap
index c2d86c7..c2d86c7 100644
--- a/tests/snapshots/term__one_line__short_color.snap
+++ b/tests/snapshots/term__same_line__short_color.snap
diff --git a/tests/snapshots/term__one_line__short_no_color.snap b/tests/snapshots/term__same_line__short_no_color.snap
index d4f94e1..d4f94e1 100644
--- a/tests/snapshots/term__one_line__short_no_color.snap
+++ b/tests/snapshots/term__same_line__short_no_color.snap
diff --git a/tests/snapshots/term__same_ranges__rich_color.snap b/tests/snapshots/term__same_ranges__rich_color.snap
index 0860add..e6ec885 100644
--- a/tests/snapshots/term__same_ranges__rich_color.snap
+++ b/tests/snapshots/term__same_ranges__rich_color.snap
@@ -5,9 +5,10 @@ expression: TEST_DATA.emit_color(&config)
{fg:Red bold bright}error{bold bright}: Unexpected token{/}
{fg:Blue}┌─{/} same_range:1:5
{fg:Blue}│{/}
-{fg:Blue}1{/} {fg:Blue}│{/} ::S { }
- {fg:Blue}│{/} {fg:Red}^ Unexpected '{'{/}
- {fg:Blue}│{/} {fg:Blue}- Expected '('{/}
- {fg:Blue}│{/}
+{fg:Blue}1{/} {fg:Blue}│{/} ::S {fg:Red}{{/} }
+ {fg:Blue}│{/} {fg:Red}^{/}
+ {fg:Blue}│{/} {fg:Red}│{/}
+ {fg:Blue}│{/} {fg:Red}Unexpected '{'{/}
+ {fg:Blue}│{/} {fg:Blue}Expected '('{/}
diff --git a/tests/snapshots/term__same_ranges__rich_no_color.snap b/tests/snapshots/term__same_ranges__rich_no_color.snap
index 462fc89..09510e6 100644
--- a/tests/snapshots/term__same_ranges__rich_no_color.snap
+++ b/tests/snapshots/term__same_ranges__rich_no_color.snap
@@ -6,8 +6,9 @@ error: Unexpected token
┌─ same_range:1:5
1 │ ::S { }
- │ ^ Unexpected '{'
- │ - Expected '('
- │
+ │ ^
+ │ │
+ │ Unexpected '{'
+ │ Expected '('
diff --git a/tests/snapshots/term__tab_columns__tab_width_2_no_color.snap b/tests/snapshots/term__tab_columns__tab_width_2_no_color.snap
new file mode 100644
index 0000000..0faa8d8
--- /dev/null
+++ b/tests/snapshots/term__tab_columns__tab_width_2_no_color.snap
@@ -0,0 +1,23 @@
+---
+source: codespan-reporting/tests/term.rs
+expression: TEST_DATA.emit_no_color(&config)
+---
+warning: tab test
+ ┌─ tab_columns:1:2
+ │
+1 │ hello
+ │ ^^^^^
+2 │ ∙ hello
+ │ ^^^^^
+3 │ ∙∙ hello
+ │ ^^^^^
+4 │ ∙∙∙ hello
+ │ ^^^^^
+5 │ ∙∙∙∙ hello
+ │ ^^^^^
+6 │ ∙∙∙∙∙ hello
+ │ ^^^^^
+7 │ ∙∙∙∙∙∙ hello
+ │ ^^^^^
+
+
diff --git a/tests/snapshots/term__tab_columns__tab_width_3_no_color.snap b/tests/snapshots/term__tab_columns__tab_width_3_no_color.snap
new file mode 100644
index 0000000..40f20a6
--- /dev/null
+++ b/tests/snapshots/term__tab_columns__tab_width_3_no_color.snap
@@ -0,0 +1,23 @@
+---
+source: codespan-reporting/tests/term.rs
+expression: TEST_DATA.emit_no_color(&config)
+---
+warning: tab test
+ ┌─ tab_columns:1:2
+ │
+1 │ hello
+ │ ^^^^^
+2 │ ∙ hello
+ │ ^^^^^
+3 │ ∙∙ hello
+ │ ^^^^^
+4 │ ∙∙∙ hello
+ │ ^^^^^
+5 │ ∙∙∙∙ hello
+ │ ^^^^^
+6 │ ∙∙∙∙∙ hello
+ │ ^^^^^
+7 │ ∙∙∙∙∙∙ hello
+ │ ^^^^^
+
+
diff --git a/tests/snapshots/term__tab_columns__tab_width_6_no_color.snap b/tests/snapshots/term__tab_columns__tab_width_6_no_color.snap
new file mode 100644
index 0000000..018a402
--- /dev/null
+++ b/tests/snapshots/term__tab_columns__tab_width_6_no_color.snap
@@ -0,0 +1,23 @@
+---
+source: codespan-reporting/tests/term.rs
+expression: TEST_DATA.emit_no_color(&config)
+---
+warning: tab test
+ ┌─ tab_columns:1:2
+ │
+1 │ hello
+ │ ^^^^^
+2 │ ∙ hello
+ │ ^^^^^
+3 │ ∙∙ hello
+ │ ^^^^^
+4 │ ∙∙∙ hello
+ │ ^^^^^
+5 │ ∙∙∙∙ hello
+ │ ^^^^^
+6 │ ∙∙∙∙∙ hello
+ │ ^^^^^
+7 │ ∙∙∙∙∙∙ hello
+ │ ^^^^^
+
+
diff --git a/tests/snapshots/term__tab_columns__tab_width_default_no_color.snap b/tests/snapshots/term__tab_columns__tab_width_default_no_color.snap
new file mode 100644
index 0000000..67cd187
--- /dev/null
+++ b/tests/snapshots/term__tab_columns__tab_width_default_no_color.snap
@@ -0,0 +1,23 @@
+---
+source: codespan-reporting/tests/term.rs
+expression: TEST_DATA.emit_no_color(&config)
+---
+warning: tab test
+ ┌─ tab_columns:1:2
+ │
+1 │ hello
+ │ ^^^^^
+2 │ ∙ hello
+ │ ^^^^^
+3 │ ∙∙ hello
+ │ ^^^^^
+4 │ ∙∙∙ hello
+ │ ^^^^^
+5 │ ∙∙∙∙ hello
+ │ ^^^^^
+6 │ ∙∙∙∙∙ hello
+ │ ^^^^^
+7 │ ∙∙∙∙∙∙ hello
+ │ ^^^^^
+
+
diff --git a/tests/snapshots/term__tabbed__tab_width_3_no_color.snap b/tests/snapshots/term__tabbed__tab_width_3_no_color.snap
index e8d797c..f7328c3 100644
--- a/tests/snapshots/term__tabbed__tab_width_3_no_color.snap
+++ b/tests/snapshots/term__tabbed__tab_width_3_no_color.snap
@@ -7,20 +7,17 @@ warning: unknown weapon `DogJaw`
3 │ Weapon: DogJaw
│ ^^^^^^ the weapon
- │
warning: unknown condition `attack-cooldown`
┌─ tabbed:4:23
-4 │ ReloadingCondition: attack-cooldown
- │ ^^^^^^^^^^^^^^^ the condition
- │
+4 │ ReloadingCondition: attack-cooldown
+ │ ^^^^^^^^^^^^^^^ the condition
warning: unknown field `Foo`
┌─ tabbed:5:2
5 │ Foo: Bar
│ ^^^ the field
- │
diff --git a/tests/snapshots/term__tabbed__tab_width_6_no_color.snap b/tests/snapshots/term__tabbed__tab_width_6_no_color.snap
index 72991cf..bcd1b2b 100644
--- a/tests/snapshots/term__tabbed__tab_width_6_no_color.snap
+++ b/tests/snapshots/term__tabbed__tab_width_6_no_color.snap
@@ -7,20 +7,17 @@ warning: unknown weapon `DogJaw`
3 │ Weapon: DogJaw
│ ^^^^^^ the weapon
- │
warning: unknown condition `attack-cooldown`
┌─ tabbed:4:23
-4 │ ReloadingCondition: attack-cooldown
- │ ^^^^^^^^^^^^^^^ the condition
- │
+4 │ ReloadingCondition: attack-cooldown
+ │ ^^^^^^^^^^^^^^^ the condition
warning: unknown field `Foo`
┌─ tabbed:5:2
5 │ Foo: Bar
│ ^^^ the field
- │
diff --git a/tests/snapshots/term__tabbed__tab_width_default_no_color.snap b/tests/snapshots/term__tabbed__tab_width_default_no_color.snap
index d3c0ee2..d3a41a0 100644
--- a/tests/snapshots/term__tabbed__tab_width_default_no_color.snap
+++ b/tests/snapshots/term__tabbed__tab_width_default_no_color.snap
@@ -7,20 +7,17 @@ warning: unknown weapon `DogJaw`
3 │ Weapon: DogJaw
│ ^^^^^^ the weapon
- │
warning: unknown condition `attack-cooldown`
┌─ tabbed:4:23
-4 │ ReloadingCondition: attack-cooldown
- │ ^^^^^^^^^^^^^^^ the condition
- │
+4 │ ReloadingCondition: attack-cooldown
+ │ ^^^^^^^^^^^^^^^ the condition
warning: unknown field `Foo`
┌─ tabbed:5:2
5 │ Foo: Bar
│ ^^^ the field
- │
diff --git a/tests/snapshots/term__unicode_spans__rich_no_color.snap b/tests/snapshots/term__unicode_spans__rich_no_color.snap
index e76de4b..653a60e 100644
--- a/tests/snapshots/term__unicode_spans__rich_no_color.snap
+++ b/tests/snapshots/term__unicode_spans__rich_no_color.snap
@@ -6,10 +6,24 @@ error[E01]: cow may not jump during new moon.
┌─ moon_jump.rs:1:1
1 │ 🐄🌑🐄🌒🐄🌓🐄🌔🐄🌕🐄🌖🐄🌗🐄🌘🐄
- │ ^^ Invalid jump
- │ -- Cow range does not start at boundary.
- │ ------ Cow does not start or end at boundary.
+ │ ^^ Invalid jump
+
+note: invalid unicode range
+ ┌─ moon_jump.rs:1:1
+ │
+1 │ 🐄🌑🐄🌒🐄🌓🐄🌔🐄🌕🐄🌖🐄🌗🐄🌘🐄
+ │ -- Cow range does not start at boundary.
+
+note: invalid unicode range
+ ┌─ moon_jump.rs:1:3
+ │
+1 │ 🐄🌑🐄🌒🐄🌓🐄🌔🐄🌕🐄🌖🐄🌗🐄🌘🐄
│ -- Cow range does not end at boundary.
+
+note: invalid unicode range
+ ┌─ moon_jump.rs:1:1
+1 │ 🐄🌑🐄🌒🐄🌓🐄🌔🐄🌕🐄🌖🐄🌗🐄🌘🐄
+ │ ------ Cow does not start or end at boundary.
diff --git a/tests/snapshots/term__unicode_spans__short_no_color.snap b/tests/snapshots/term__unicode_spans__short_no_color.snap
index 9085082..1b19451 100644
--- a/tests/snapshots/term__unicode_spans__short_no_color.snap
+++ b/tests/snapshots/term__unicode_spans__short_no_color.snap
@@ -3,4 +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
diff --git a/tests/term.rs b/tests/term.rs
index 95cc670..ee02372 100644
--- a/tests/term.rs
+++ b/tests/term.rs
@@ -87,20 +87,23 @@ mod empty {
test_emit!(short_no_color);
}
-/// Based on: https://github.com/rust-lang/rust/blob/c20d7eecbc0928b57da8fe30b2ef8528e2bdd5be/src/test/ui/codemap_tests/one_line.stderr
-mod one_line {
+/// Based on:
+/// - https://github.com/rust-lang/rust/blob/c20d7eecbc0928b57da8fe30b2ef8528e2bdd5be/src/test/ui/codemap_tests/one_line.stderr
+mod same_line {
use super::*;
lazy_static::lazy_static! {
- static ref TEST_DATA: TestData<'static, SimpleFile<&'static str, String>> = {
- let file = SimpleFile::new(
+ static ref TEST_DATA: TestData<'static, SimpleFiles<&'static str, String>> = {
+ let mut files = SimpleFiles::new();
+
+ let file_id1 = files.add(
"one_line.rs",
unindent::unindent(r#"
fn main() {
let mut v = vec![Some("foo"), Some("bar")];
v.push(v.pop().unwrap());
}
- "#)
+ "#),
);
let diagnostics = vec![
@@ -108,11 +111,11 @@ mod one_line {
.with_code("E0499")
.with_message("cannot borrow `v` as mutable more than once at a time")
.with_labels(vec![
- Label::primary((), 71..72)
+ Label::primary(file_id1, 71..72)
.with_message("second mutable borrow occurs here"),
- Label::secondary((), 64..65)
+ Label::secondary(file_id1, 64..65)
.with_message("first borrow later used by call"),
- Label::secondary((), 66..70)
+ Label::secondary(file_id1, 66..70)
.with_message("first mutable borrow occurs here"),
]),
Diagnostic::error()
@@ -122,7 +125,149 @@ mod one_line {
]),
];
- TestData { files: file, diagnostics }
+ TestData { files, diagnostics }
+ };
+ }
+
+ test_emit!(rich_color);
+ test_emit!(short_color);
+ test_emit!(rich_no_color);
+ test_emit!(short_no_color);
+}
+
+/// Based on:
+/// - https://github.com/rust-lang/rust/blob/c20d7eecbc0928b57da8fe30b2ef8528e2bdd5be/src/test/ui/nested_impl_trait.stderr
+/// - https://github.com/rust-lang/rust/blob/c20d7eecbc0928b57da8fe30b2ef8528e2bdd5be/src/test/ui/typeck/typeck_type_placeholder_item.stderr
+/// - https://github.com/rust-lang/rust/blob/c20d7eecbc0928b57da8fe30b2ef8528e2bdd5be/src/test/ui/no_send_res_ports.stderr
+mod overlapping {
+ use super::*;
+
+ lazy_static::lazy_static! {
+ static ref TEST_DATA: TestData<'static, SimpleFiles<&'static str, String>> = {
+ let mut files = SimpleFiles::new();
+
+ let file_id1 = files.add(
+ "nested_impl_trait.rs",
+ unindent::unindent(r#"
+ use std::fmt::Debug;
+
+ fn fine(x: impl Into<u32>) -> impl Into<u32> { x }
+
+ fn bad_in_ret_position(x: impl Into<u32>) -> impl Into<impl Debug> { x }
+ "#),
+ );
+ let file_id2 = files.add(
+ "typeck_type_placeholder_item.rs",
+ unindent::unindent(r#"
+ fn fn_test1() -> _ { 5 }
+ fn fn_test2(x: i32) -> (_, _) { (x, x) }
+ "#),
+ );
+ let file_id3 = files.add(
+ "libstd/thread/mod.rs",
+ unindent::unindent(r#"
+ #[stable(feature = "rust1", since = "1.0.0")]
+ pub fn spawn<F, T>(self, f: F) -> io::Result<JoinHandle<T>>
+ where
+ F: FnOnce() -> T,
+ F: Send + 'static,
+ T: Send + 'static,
+ {
+ unsafe { self.spawn_unchecked(f) }
+ }
+ "#),
+ );
+ let file_id4 = files.add(
+ "no_send_res_ports.rs",
+ unindent::unindent(r#"
+ use std::thread;
+ use std::rc::Rc;
+
+ #[derive(Debug)]
+ struct Port<T>(Rc<T>);
+
+ fn main() {
+ #[derive(Debug)]
+ struct Foo {
+ _x: Port<()>,
+ }
+
+ impl Drop for Foo {
+ fn drop(&mut self) {}
+ }
+
+ fn foo(x: Port<()>) -> Foo {
+ Foo {
+ _x: x
+ }
+ }
+
+ let x = foo(Port(Rc::new(())));
+
+ thread::spawn(move|| {
+ let y = x;
+ println!("{:?}", y);
+ });
+ }
+ "#),
+ );
+
+ let diagnostics = vec![
+ Diagnostic::error()
+ .with_code("E0666")
+ .with_message("nested `impl Trait` is not allowed")
+ .with_labels(vec![
+ Label::primary(file_id1, 129..139)
+ .with_message("nested `impl Trait` here"),
+ Label::secondary(file_id1, 119..140)
+ .with_message("outer `impl Trait`"),
+ ]),
+ Diagnostic::error()
+ .with_code("E0121")
+ .with_message("the type placeholder `_` is not allowed within types on item signatures")
+ .with_labels(vec![
+ Label::primary(file_id2, 17..18)
+ .with_message("not allowed in type signatures"),
+ Label::secondary(file_id2, 17..18)
+ .with_message("help: replace with the correct return type: `i32`"),
+ ]),
+ Diagnostic::error()
+ .with_code("E0121")
+ .with_message("the type placeholder `_` is not allowed within types on item signatures")
+ .with_labels(vec![
+ Label::primary(file_id2, 49..50)
+ .with_message("not allowed in type signatures"),
+ Label::primary(file_id2, 52..53)
+ .with_message("not allowed in type signatures"),
+ Label::secondary(file_id2, 48..54)
+ .with_message("help: replace with the correct return type: `(i32, i32)`"),
+ ]),
+ Diagnostic::error()
+ .with_code("E0277")
+ .with_message("`std::rc::Rc<()>` cannot be sent between threads safely")
+ .with_labels(vec![
+ Label::primary(file_id4, 339..352)
+ .with_message("`std::rc::Rc<()>` cannot be sent between threads safely"),
+ Label::secondary(file_id4, 353..416)
+ .with_message("within this `[closure@no_send_res_ports.rs:29:19: 33:6 x:main::Foo]`"),
+ Label::secondary(file_id3, 141..145)
+ .with_message("required by this bound in `std::thread::spawn`"),
+ ])
+ .with_notes(vec![
+ "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<()>`".to_owned(),
+ "note: required because it appears within the type `Port<()>`".to_owned(),
+ "note: required because it appears within the type `main::Foo`".to_owned(),
+ "note: required because it appears within the type `[closure@no_send_res_ports.rs:29:19: 33:6 x:main::Foo]`".to_owned(),
+ ]),
+ Diagnostic::error()
+ .with_message("aborting due 5 previous errors")
+ .with_notes(vec![
+ "Some errors have detailed explanations: E0121, E0277, E0666.".to_owned(),
+ "For more information about an error, try `rustc --explain E0121`.".to_owned(),
+ ]),
+ ];
+
+ TestData { files, diagnostics }
};
}
@@ -185,7 +330,7 @@ mod empty_ranges {
lazy_static::lazy_static! {
static ref TEST_DATA: TestData<'static, SimpleFile<&'static str, &'static str>> = {
- let file = SimpleFile::new("hello", "Hello world!\nBye world!");
+ let file = SimpleFile::new("hello", "Hello world!\nBye world!\n ");
let eof = file.source().len();
let diagnostics = vec![
@@ -196,6 +341,9 @@ mod empty_ranges {
.with_message("end of line")
.with_labels(vec![Label::primary((), 12..12).with_message("end of line")]),
Diagnostic::note()
+ .with_message("end of line")
+ .with_labels(vec![Label::primary((), 23..23).with_message("end of line")]),
+ Diagnostic::note()
.with_message("end of file")
.with_labels(vec![Label::primary((), eof..eof).with_message("end of file")]),
];
@@ -483,10 +631,83 @@ mod tabbed {
fn tab_width_default_no_color() {
let config = TEST_CONFIG.clone();
- insta::assert_snapshot!(
- "tab_width_default_no_color",
- TEST_DATA.emit_no_color(&config)
- );
+ insta::assert_snapshot!(TEST_DATA.emit_no_color(&config));
+ }
+
+ #[test]
+ fn tab_width_3_no_color() {
+ let config = Config {
+ tab_width: 3,
+ ..TEST_CONFIG.clone()
+ };
+
+ insta::assert_snapshot!(TEST_DATA.emit_no_color(&config));
+ }
+
+ #[test]
+ fn tab_width_6_no_color() {
+ let config = Config {
+ tab_width: 6,
+ ..TEST_CONFIG.clone()
+ };
+
+ insta::assert_snapshot!(TEST_DATA.emit_no_color(&config));
+ }
+}
+
+mod tab_columns {
+ use super::*;
+
+ lazy_static::lazy_static! {
+ static ref TEST_DATA: TestData<'static, SimpleFiles<&'static str, String>> = {
+ let mut files = SimpleFiles::new();
+
+ let source = [
+ "\thello",
+ "∙\thello",
+ "∙∙\thello",
+ "∙∙∙\thello",
+ "∙∙∙∙\thello",
+ "∙∙∙∙∙\thello",
+ "∙∙∙∙∙∙\thello",
+ ].join("\n");
+ let hello_ranges = source
+ .match_indices("hello")
+ .map(|(start, hello)| start..(start+hello.len()))
+ .collect::<Vec<_>>();
+
+ let file_id = files.add("tab_columns", source);
+
+ let diagnostics = vec![
+ Diagnostic::warning()
+ .with_message("tab test")
+ .with_labels(
+ hello_ranges
+ .into_iter()
+ .map(|range| Label::primary(file_id, range))
+ .collect(),
+ ),
+ ];
+
+ TestData { files, diagnostics }
+ };
+ }
+
+ #[test]
+ fn tab_width_default_no_color() {
+ let config = TEST_CONFIG.clone();
+
+ insta::assert_snapshot!(TEST_DATA.emit_no_color(&config));
+ }
+
+ #[test]
+ fn tab_width_2_no_color() {
+ let config = Config {
+ tab_width: 2,
+ ..TEST_CONFIG.clone()
+ };
+
+ insta::assert_snapshot!(TEST_DATA.emit_no_color(&config));
}
#[test]
@@ -510,7 +731,8 @@ mod tabbed {
}
}
-/// Based on: https://github.com/TheSamsa/rust/blob/75cf41afb468152611212271bae026948cd3ba46/src/test/ui/codemap_tests/unicode.stderr
+/// Based on:
+/// - https://github.com/TheSamsa/rust/blob/75cf41afb468152611212271bae026948cd3ba46/src/test/ui/codemap_tests/unicode.stderr
mod unicode {
use super::*;
@@ -595,14 +817,26 @@ mod unicode_spans {
.with_labels(vec![
Label::primary((), invalid_start..invalid_end)
.with_message("Invalid jump"),
+ ]),
+ Diagnostic::note()
+ .with_message("invalid unicode range")
+ .with_labels(vec![
Label::secondary((), invalid_start.."🐄".len())
.with_message("Cow range does not start at boundary."),
+ ]),
+ Diagnostic::note()
+ .with_message("invalid unicode range")
+ .with_labels(vec![
Label::secondary((), "🐄🌑".len().."🐄🌑🐄".len() - 1)
.with_message("Cow range does not end at boundary."),
+ ]),
+ Diagnostic::note()
+ .with_message("invalid unicode range")
+ .with_labels(vec![
Label::secondary((), invalid_start.."🐄🌑🐄".len() - 1)
.with_message("Cow does not start or end at boundary."),
-
- ])];
+ ]),
+ ];
TestData{files: file, diagnostics }
};
}