diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-04-25 11:16:02 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-04-25 11:16:02 +0100 |
commit | 29fc409e7fe5b12dcf6bfbcca622d79c4c8fcb72 (patch) | |
tree | e42f7bd1490bca66e0786d5bf2b3194aeaa57a93 /crates/ra_syntax/src/fuzz.rs | |
parent | 27a7718880d93f55f905da606d108d3b3c682ab4 (diff) | |
parent | e87346950039a54c3f0b02d6056cbb92ca38eb28 (diff) |
Merge #4131
4131: Switch to text-size r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
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 }; |