From e00922d113e5f998893419dedae511043890f9fa Mon Sep 17 00:00:00 2001 From: Veetaha Date: Mon, 10 Feb 2020 02:08:49 +0200 Subject: ra_syntax: SyntaxError::range() now returns by value --- crates/ra_syntax/src/parsing/reparsing.rs | 2 +- crates/ra_syntax/src/syntax_error.rs | 4 ++-- crates/ra_syntax/src/tests.rs | 10 ++-------- 3 files changed, 5 insertions(+), 11 deletions(-) (limited to 'crates/ra_syntax/src') 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( } res.extend(new_errors.into_iter().map(|new_err| { // fighting borrow checker with a variable ;) - let offseted_range = *new_err.range() + range_before_reparse.start(); + let offseted_range = new_err.range() + range_before_reparse.start(); new_err.with_range(offseted_range) })); 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 { pub fn message(&self) -> &str { &self.0 } - pub fn range(&self) -> &TextRange { - &self.1 + pub fn range(&self) -> TextRange { + self.1 } 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) writeln!(acc, "{:?} {} {:?}", token.kind, token_len, token_text).unwrap(); } for err in errors { - writeln!( - acc, - "> error{:?} token({:?}) msg({})", - err.range(), - &text[*err.range()], - err.message() - ) - .unwrap(); + writeln!(acc, "> error{:?} token({:?}) msg({})", err.range(), &text[err.range()], err) + .unwrap(); } acc } -- cgit v1.2.3