aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/fuzz.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/fuzz.rs')
-rw-r--r--crates/ra_syntax/src/fuzz.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/crates/ra_syntax/src/fuzz.rs b/crates/ra_syntax/src/fuzz.rs
index 7012df7f0..10fbe3176 100644
--- a/crates/ra_syntax/src/fuzz.rs
+++ b/crates/ra_syntax/src/fuzz.rs
@@ -1,8 +1,13 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use crate::{validation, AstNode, SourceFile, TextRange, TextUnit}; 3use std::{
4 convert::TryInto,
5 str::{self, FromStr},
6};
7
4use ra_text_edit::AtomTextEdit; 8use ra_text_edit::AtomTextEdit;
5use std::str::{self, FromStr}; 9
10use crate::{validation, AstNode, SourceFile, TextRange};
6 11
7fn check_file_invariants(file: &SourceFile) { 12fn check_file_invariants(file: &SourceFile) {
8 let root = file.syntax(); 13 let root = file.syntax();
@@ -34,10 +39,8 @@ impl CheckReparse {
34 let text = lines.collect::<Vec<_>>().join("\n"); 39 let text = lines.collect::<Vec<_>>().join("\n");
35 let text = format!("{}{}{}", PREFIX, text, SUFFIX); 40 let text = format!("{}{}{}", PREFIX, text, SUFFIX);
36 text.get(delete_start..delete_start.checked_add(delete_len)?)?; // make sure delete is a valid range 41 text.get(delete_start..delete_start.checked_add(delete_len)?)?; // make sure delete is a valid range
37 let delete = TextRange::offset_len( 42 let delete =
38 TextUnit::from_usize(delete_start), 43 TextRange::at(delete_start.try_into().unwrap(), delete_len.try_into().unwrap());
39 TextUnit::from_usize(delete_len),
40 );
41 let edited_text = 44 let edited_text =
42 format!("{}{}{}", &text[..delete_start], &insert, &text[delete_start + delete_len..]); 45 format!("{}{}{}", &text[..delete_start], &insert, &text[delete_start + delete_len..]);
43 let edit = AtomTextEdit { delete, insert }; 46 let edit = AtomTextEdit { delete, insert };