mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Make is_raw_identifier()
public util function
This commit is contained in:
parent
646f973857
commit
92fdfb548e
3 changed files with 9 additions and 10 deletions
|
@ -12,7 +12,7 @@
|
|||
use itertools::Itertools;
|
||||
use stdx::{format_to, never};
|
||||
|
||||
use crate::{ast, AstNode, SourceFile, SyntaxKind, SyntaxToken};
|
||||
use crate::{ast, utils::is_raw_identifier, AstNode, SourceFile, SyntaxKind, SyntaxToken};
|
||||
|
||||
/// While the parent module defines basic atomic "constructors", the `ext`
|
||||
/// module defines shortcuts for common things.
|
||||
|
@ -111,8 +111,7 @@ pub fn name_ref(name_ref: &str) -> ast::NameRef {
|
|||
ast_from_text(&format!("fn f() {{ {raw_escape}{name_ref}; }}"))
|
||||
}
|
||||
fn raw_ident_esc(ident: &str) -> &'static str {
|
||||
let is_keyword = parser::SyntaxKind::from_keyword(ident).is_some();
|
||||
if is_keyword && !matches!(ident, "self" | "crate" | "super" | "Self") {
|
||||
if is_raw_identifier(ident) {
|
||||
"r#"
|
||||
} else {
|
||||
""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue