aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/tests.rs')
-rw-r--r--crates/ra_syntax/src/tests.rs21
1 files changed, 5 insertions, 16 deletions
diff --git a/crates/ra_syntax/src/tests.rs b/crates/ra_syntax/src/tests.rs
index fb22b9e54..2533d0c44 100644
--- a/crates/ra_syntax/src/tests.rs
+++ b/crates/ra_syntax/src/tests.rs
@@ -5,7 +5,7 @@ use std::{
5 5
6use test_utils::{collect_tests, dir_tests, project_dir, read_text}; 6use test_utils::{collect_tests, dir_tests, project_dir, read_text};
7 7
8use crate::{fuzz, tokenize, Location, SourceFile, SyntaxError, TextRange, Token}; 8use crate::{fuzz, tokenize, SourceFile, SyntaxError, Token};
9 9
10#[test] 10#[test]
11fn lexer_tests() { 11fn lexer_tests() {
@@ -128,25 +128,14 @@ 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 let err_range = location_to_range(err.location());
132 writeln!( 131 writeln!(
133 acc, 132 acc,
134 "> error{:?} token({:?}) msg({})", 133 "> error{:?} token({:?}) msg({})",
135 err.location(), 134 err.range(),
136 &text[err_range], 135 &text[*err.range()],
137 err.kind() 136 err.message()
138 ) 137 )
139 .unwrap(); 138 .unwrap();
140 } 139 }
141 return acc; 140 acc
142
143 // FIXME: copy-pasted this from `ra_ide/src/diagnostics.rs`
144 // `Location` will be refactored soon in new PR, see todos here:
145 // https://github.com/rust-analyzer/rust-analyzer/issues/223
146 fn location_to_range(location: Location) -> TextRange {
147 match location {
148 Location::Offset(offset) => TextRange::offset_len(offset, 1.into()),
149 Location::Range(range) => range,
150 }
151 }
152} 141}