diff options
author | Aleksey Kladov <[email protected]> | 2019-05-29 08:12:08 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-05-29 08:31:07 +0100 |
commit | 2e722ec54b3503e2b2f411959fffb63ef9f1a334 (patch) | |
tree | c72a31f26edea8fc44b5c717a4701c2e7f9bae41 /crates/ra_syntax/src/syntax_error.rs | |
parent | 7a1cae59acf72f821343b2ba10ef69fb92a5b952 (diff) |
show error offsets in tests
Diffstat (limited to 'crates/ra_syntax/src/syntax_error.rs')
-rw-r--r-- | crates/ra_syntax/src/syntax_error.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/crates/ra_syntax/src/syntax_error.rs b/crates/ra_syntax/src/syntax_error.rs index 27e12293b..67deee1be 100644 --- a/crates/ra_syntax/src/syntax_error.rs +++ b/crates/ra_syntax/src/syntax_error.rs | |||
@@ -13,7 +13,7 @@ pub struct SyntaxError { | |||
13 | location: Location, | 13 | location: Location, |
14 | } | 14 | } |
15 | 15 | ||
16 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 16 | #[derive(Clone, PartialEq, Eq, Hash)] |
17 | pub enum Location { | 17 | pub enum Location { |
18 | Offset(TextUnit), | 18 | Offset(TextUnit), |
19 | Range(TextRange), | 19 | Range(TextRange), |
@@ -31,6 +31,15 @@ impl Into<Location> for TextRange { | |||
31 | } | 31 | } |
32 | } | 32 | } |
33 | 33 | ||
34 | impl fmt::Debug for Location { | ||
35 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
36 | match self { | ||
37 | Location::Offset(it) => fmt::Debug::fmt(it, f), | ||
38 | Location::Range(it) => fmt::Debug::fmt(it, f), | ||
39 | } | ||
40 | } | ||
41 | } | ||
42 | |||
34 | impl SyntaxError { | 43 | impl SyntaxError { |
35 | pub fn new<L: Into<Location>>(kind: SyntaxErrorKind, loc: L) -> SyntaxError { | 44 | pub fn new<L: Into<Location>>(kind: SyntaxErrorKind, loc: L) -> SyntaxError { |
36 | SyntaxError { kind, location: loc.into() } | 45 | SyntaxError { kind, location: loc.into() } |