aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/lib.rs2
-rw-r--r--crates/ra_syntax/src/syntax_error.rs11
2 files changed, 11 insertions, 2 deletions
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs
index 930a643b7..8c0ba6f2d 100644
--- a/crates/ra_syntax/src/lib.rs
+++ b/crates/ra_syntax/src/lib.rs
@@ -76,7 +76,7 @@ impl Parse {
76 pub fn debug_dump(&self) -> String { 76 pub fn debug_dump(&self) -> String {
77 let mut buf = self.tree.syntax().debug_dump(); 77 let mut buf = self.tree.syntax().debug_dump();
78 for err in self.errors.iter() { 78 for err in self.errors.iter() {
79 writeln!(buf, "err: `{}`", err).unwrap(); 79 writeln!(buf, "error {:?}: {}", err.location(), err.kind()).unwrap();
80 } 80 }
81 buf 81 buf
82 } 82 }
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)]
17pub enum Location { 17pub 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
34impl 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
34impl SyntaxError { 43impl 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() }