diff options
Diffstat (limited to 'crates/ra_syntax/src/syntax_error.rs')
-rw-r--r-- | crates/ra_syntax/src/syntax_error.rs | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/crates/ra_syntax/src/syntax_error.rs b/crates/ra_syntax/src/syntax_error.rs index 27e12293b..d29c0cf6c 100644 --- a/crates/ra_syntax/src/syntax_error.rs +++ b/crates/ra_syntax/src/syntax_error.rs | |||
@@ -13,21 +13,30 @@ 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), |
20 | } | 20 | } |
21 | 21 | ||
22 | impl Into<Location> for TextUnit { | 22 | impl From<TextUnit> for Location { |
23 | fn into(self) -> Location { | 23 | fn from(offset: TextUnit) -> Location { |
24 | Location::Offset(self) | 24 | Location::Offset(offset) |
25 | } | ||
26 | } | ||
27 | |||
28 | impl From<TextRange> for Location { | ||
29 | fn from(range: TextRange) -> Location { | ||
30 | Location::Range(range) | ||
25 | } | 31 | } |
26 | } | 32 | } |
27 | 33 | ||
28 | impl Into<Location> for TextRange { | 34 | impl fmt::Debug for Location { |
29 | fn into(self) -> Location { | 35 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
30 | Location::Range(self) | 36 | match self { |
37 | Location::Offset(it) => fmt::Debug::fmt(it, f), | ||
38 | Location::Range(it) => fmt::Debug::fmt(it, f), | ||
39 | } | ||
31 | } | 40 | } |
32 | } | 41 | } |
33 | 42 | ||