diff --git a/crates/syntax/src/ast/token_ext.rs b/crates/syntax/src/ast/token_ext.rs index c5ef92733d8..44f967acbc4 100644 --- a/crates/syntax/src/ast/token_ext.rs +++ b/crates/syntax/src/ast/token_ext.rs @@ -8,11 +8,11 @@ use rustc_lexer::unescape::{unescape_literal, Mode}; use crate::{ - ast::{AstToken, Comment, RawString, String, Whitespace}, + ast::{self, AstToken}, TextRange, TextSize, }; -impl Comment { +impl ast::Comment { pub fn kind(&self) -> CommentKind { kind_by_prefix(self.text()) } @@ -80,7 +80,7 @@ fn kind_by_prefix(text: &str) -> CommentKind { panic!("bad comment text: {:?}", text) } -impl Whitespace { +impl ast::Whitespace { pub fn spans_multiple_lines(&self) -> bool { let text = self.text(); text.find('\n').map_or(false, |idx| text[idx + 1..].contains('\n')) @@ -138,19 +138,19 @@ fn text_range_between_quotes(&self) -> Option { } } -impl HasQuotes for String {} -impl HasQuotes for RawString {} +impl HasQuotes for ast::String {} +impl HasQuotes for ast::RawString {} pub trait HasStringValue: HasQuotes { fn value(&self) -> Option>; } -impl HasStringValue for String { +impl HasStringValue for ast::String { fn value(&self) -> Option> { let text = self.text().as_str(); let text = &text[self.text_range_between_quotes()? - self.syntax().text_range().start()]; - let mut buf = std::string::String::with_capacity(text.len()); + let mut buf = String::with_capacity(text.len()); let mut has_error = false; unescape_literal(text, Mode::Str, &mut |_, unescaped_char| match unescaped_char { Ok(c) => buf.push(c), @@ -166,7 +166,7 @@ fn value(&self) -> Option> { } } -impl HasStringValue for RawString { +impl HasStringValue for ast::RawString { fn value(&self) -> Option> { let text = self.text().as_str(); let text = &text[self.text_range_between_quotes()? - self.syntax().text_range().start()]; @@ -174,7 +174,7 @@ fn value(&self) -> Option> { } } -impl RawString { +impl ast::RawString { pub fn map_range_up(&self, range: TextRange) -> Option { let contents_range = self.text_range_between_quotes()?; assert!(TextRange::up_to(contents_range.len()).contains_range(range)); @@ -500,7 +500,7 @@ fn read_identifier<'a, I, F>(chars: &mut std::iter::Peekable, callback: &mut } } -impl HasFormatSpecifier for String { +impl HasFormatSpecifier for ast::String { fn char_ranges( &self, ) -> Option)>> { @@ -521,7 +521,7 @@ fn char_ranges( } } -impl HasFormatSpecifier for RawString { +impl HasFormatSpecifier for ast::RawString { fn char_ranges( &self, ) -> Option)>> {