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
|
@ -2,7 +2,7 @@
|
|||
|
||||
use itertools::Itertools;
|
||||
|
||||
use crate::{ast, match_ast, AstNode};
|
||||
use crate::{ast, match_ast, AstNode, SyntaxKind};
|
||||
|
||||
pub fn path_to_string_stripping_turbo_fish(path: &ast::Path) -> String {
|
||||
path.syntax()
|
||||
|
@ -23,6 +23,11 @@ pub fn path_to_string_stripping_turbo_fish(path: &ast::Path) -> String {
|
|||
.join("::")
|
||||
}
|
||||
|
||||
pub fn is_raw_identifier(name: &str) -> bool {
|
||||
let is_keyword = SyntaxKind::from_keyword(name).is_some();
|
||||
is_keyword && !matches!(name, "self" | "crate" | "super" | "Self")
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::path_to_string_stripping_turbo_fish;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue