aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
authorVeetaha <[email protected]>2020-02-10 00:08:49 +0000
committerVeetaha <[email protected]>2020-02-17 20:24:38 +0000
commite00922d113e5f998893419dedae511043890f9fa (patch)
tree28d53fc6b80febc9cca5d4ad8d95a2b471ec812d /crates/ra_syntax/src
parentacdab6f0f232913da44fca085e2f508d53982ab6 (diff)
ra_syntax: SyntaxError::range() now returns by value
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/parsing/reparsing.rs2
-rw-r--r--crates/ra_syntax/src/syntax_error.rs4
-rw-r--r--crates/ra_syntax/src/tests.rs10
3 files changed, 5 insertions, 11 deletions
diff --git a/crates/ra_syntax/src/parsing/reparsing.rs b/crates/ra_syntax/src/parsing/reparsing.rs
index 41a355ec7..4faeeab45 100644
--- a/crates/ra_syntax/src/parsing/reparsing.rs
+++ b/crates/ra_syntax/src/parsing/reparsing.rs
@@ -180,7 +180,7 @@ fn merge_errors(
180 } 180 }
181 res.extend(new_errors.into_iter().map(|new_err| { 181 res.extend(new_errors.into_iter().map(|new_err| {
182 // fighting borrow checker with a variable ;) 182 // fighting borrow checker with a variable ;)
183 let offseted_range = *new_err.range() + range_before_reparse.start(); 183 let offseted_range = new_err.range() + range_before_reparse.start();
184 new_err.with_range(offseted_range) 184 new_err.with_range(offseted_range)
185 })); 185 }));
186 res 186 res
diff --git a/crates/ra_syntax/src/syntax_error.rs b/crates/ra_syntax/src/syntax_error.rs
index eaa825cf0..af4584e66 100644
--- a/crates/ra_syntax/src/syntax_error.rs
+++ b/crates/ra_syntax/src/syntax_error.rs
@@ -30,8 +30,8 @@ impl SyntaxError {
30 pub fn message(&self) -> &str { 30 pub fn message(&self) -> &str {
31 &self.0 31 &self.0
32 } 32 }
33 pub fn range(&self) -> &TextRange { 33 pub fn range(&self) -> TextRange {
34 &self.1 34 self.1
35 } 35 }
36 36
37 pub fn with_range(mut self, range: TextRange) -> Self { 37 pub fn with_range(mut self, range: TextRange) -> Self {
diff --git a/crates/ra_syntax/src/tests.rs b/crates/ra_syntax/src/tests.rs
index 2533d0c44..912e6aec0 100644
--- a/crates/ra_syntax/src/tests.rs
+++ b/crates/ra_syntax/src/tests.rs
@@ -128,14 +128,8 @@ fn dump_tokens_and_errors(tokens: &[Token], errors: &[SyntaxError], text: &str)
128 writeln!(acc, "{:?} {} {:?}", token.kind, token_len, token_text).unwrap(); 128 writeln!(acc, "{:?} {} {:?}", token.kind, token_len, token_text).unwrap();
129 } 129 }
130 for err in errors { 130 for err in errors {
131 writeln!( 131 writeln!(acc, "> error{:?} token({:?}) msg({})", err.range(), &text[err.range()], err)
132 acc, 132 .unwrap();
133 "> error{:?} token({:?}) msg({})",
134 err.range(),
135 &text[*err.range()],
136 err.message()
137 )
138 .unwrap();
139 } 133 }
140 acc 134 acc
141} 135}