diff options
Diffstat (limited to 'crates/ra_syntax/src/fuzz.rs')
-rw-r--r-- | crates/ra_syntax/src/fuzz.rs | 15 |
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 | ||
3 | use crate::{validation, AstNode, SourceFile, TextRange, TextUnit}; | 3 | use std::{ |
4 | convert::TryInto, | ||
5 | str::{self, FromStr}, | ||
6 | }; | ||
7 | |||
4 | use ra_text_edit::AtomTextEdit; | 8 | use ra_text_edit::AtomTextEdit; |
5 | use std::str::{self, FromStr}; | 9 | |
10 | use crate::{validation, AstNode, SourceFile, TextRange}; | ||
6 | 11 | ||
7 | fn check_file_invariants(file: &SourceFile) { | 12 | fn 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 }; |