aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/fuzz.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-04-25 11:16:02 +0100
committerGitHub <[email protected]>2020-04-25 11:16:02 +0100
commit29fc409e7fe5b12dcf6bfbcca622d79c4c8fcb72 (patch)
treee42f7bd1490bca66e0786d5bf2b3194aeaa57a93 /crates/ra_syntax/src/fuzz.rs
parent27a7718880d93f55f905da606d108d3b3c682ab4 (diff)
parente87346950039a54c3f0b02d6056cbb92ca38eb28 (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.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 };