diff options
Diffstat (limited to 'src/tree')
-rw-r--r-- | src/tree/file_builder.rs | 2 | ||||
-rw-r--r-- | src/tree/mod.rs | 7 |
2 files changed, 5 insertions, 4 deletions
diff --git a/src/tree/file_builder.rs b/src/tree/file_builder.rs index a1b004892..ddb29a6b9 100644 --- a/src/tree/file_builder.rs +++ b/src/tree/file_builder.rs | |||
@@ -154,7 +154,7 @@ impl<'f> ErrorBuilder<'f> { | |||
154 | self | 154 | self |
155 | } | 155 | } |
156 | 156 | ||
157 | pub fn build(self) { | 157 | pub fn emit(self) { |
158 | let message = self.message.expect("Error message not set"); | 158 | let message = self.message.expect("Error message not set"); |
159 | let node = self.builder.current_id(); | 159 | let node = self.builder.current_id(); |
160 | self.builder.errors.push(SyntaxErrorData { node, message }) | 160 | self.builder.errors.push(SyntaxErrorData { node, message }) |
diff --git a/src/tree/mod.rs b/src/tree/mod.rs index 00d33cbc7..3980b23ce 100644 --- a/src/tree/mod.rs +++ b/src/tree/mod.rs | |||
@@ -73,7 +73,7 @@ impl<'f> Node<'f> { | |||
73 | Children { next: self.as_node(self.data().first_child) } | 73 | Children { next: self.as_node(self.data().first_child) } |
74 | } | 74 | } |
75 | 75 | ||
76 | pub fn SyntaxErrors(&self) -> SyntaxErrors<'f> { | 76 | pub fn errors(&self) -> SyntaxErrors<'f> { |
77 | let pos = self.file.errors.iter().position(|e| e.node == self.idx); | 77 | let pos = self.file.errors.iter().position(|e| e.node == self.idx); |
78 | let next = pos | 78 | let next = pos |
79 | .map(|i| ErrorIdx(i as u32)) | 79 | .map(|i| ErrorIdx(i as u32)) |
@@ -112,12 +112,13 @@ impl<'f> SyntaxError<'f> { | |||
112 | } | 112 | } |
113 | 113 | ||
114 | fn next(&self) -> Option<SyntaxError<'f>> { | 114 | fn next(&self) -> Option<SyntaxError<'f>> { |
115 | if self.file.errors.len() == self.idx.0 as usize { | 115 | let next_idx = self.idx.0 + 1; |
116 | if !((next_idx as usize) < self.file.errors.len()) { | ||
116 | return None; | 117 | return None; |
117 | } | 118 | } |
118 | let result = SyntaxError { | 119 | let result = SyntaxError { |
119 | file: self.file, | 120 | file: self.file, |
120 | idx: ErrorIdx(self.idx.0 + 1) | 121 | idx: ErrorIdx(next_idx) |
121 | }; | 122 | }; |
122 | if result.data().node != self.data().node { | 123 | if result.data().node != self.data().node { |
123 | return None; | 124 | return None; |