aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/parsing
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-03-13 08:24:19 +0000
committerGitHub <[email protected]>2020-03-13 08:24:19 +0000
commitbe3cf01c15cd48877046e675f4a0ff31b8a08798 (patch)
tree23e3903d5d9c7d72c32eb73649dd36b24eba6d38 /crates/ra_syntax/src/parsing
parent2f9f409538553fc709bbcad1a5c76968f36e5968 (diff)
parent88c944f96b426955933b77ca68c92990734769be (diff)
Merge #3570
3570: Remove some TextUnit->usize escapees r=matklad a=CAD97 As spotted during [a review of all uses of `text_unit::TextUnit::to_usize`](https://github.com/rust-analyzer/text_unit/pull/12#issuecomment-598512370). Legitimate uses do remain. Co-authored-by: CAD97 <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/parsing')
-rw-r--r--crates/ra_syntax/src/parsing/lexer.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/crates/ra_syntax/src/parsing/lexer.rs b/crates/ra_syntax/src/parsing/lexer.rs
index f2684c852..d1baaa607 100644
--- a/crates/ra_syntax/src/parsing/lexer.rs
+++ b/crates/ra_syntax/src/parsing/lexer.rs
@@ -65,7 +65,7 @@ pub fn tokenize(text: &str) -> (Vec<Token>, Vec<SyntaxError>) {
65/// Beware that unescape errors are not checked at tokenization time. 65/// Beware that unescape errors are not checked at tokenization time.
66pub fn lex_single_syntax_kind(text: &str) -> Option<(SyntaxKind, Option<SyntaxError>)> { 66pub fn lex_single_syntax_kind(text: &str) -> Option<(SyntaxKind, Option<SyntaxError>)> {
67 lex_first_token(text) 67 lex_first_token(text)
68 .filter(|(token, _)| token.len.to_usize() == text.len()) 68 .filter(|(token, _)| token.len == TextUnit::of_str(text))
69 .map(|(token, error)| (token.kind, error)) 69 .map(|(token, error)| (token.kind, error))
70} 70}
71 71
@@ -75,7 +75,7 @@ pub fn lex_single_syntax_kind(text: &str) -> Option<(SyntaxKind, Option<SyntaxEr
75/// Beware that unescape errors are not checked at tokenization time. 75/// Beware that unescape errors are not checked at tokenization time.
76pub fn lex_single_valid_syntax_kind(text: &str) -> Option<SyntaxKind> { 76pub fn lex_single_valid_syntax_kind(text: &str) -> Option<SyntaxKind> {
77 lex_first_token(text) 77 lex_first_token(text)
78 .filter(|(token, error)| !error.is_some() && token.len.to_usize() == text.len()) 78 .filter(|(token, error)| !error.is_some() && token.len == TextUnit::of_str(text))
79 .map(|(token, _error)| token.kind) 79 .map(|(token, _error)| token.kind)
80} 80}
81 81