Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/tt/src/lib.rs')
-rw-r--r--crates/tt/src/lib.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/crates/tt/src/lib.rs b/crates/tt/src/lib.rs
index a54861de95..85daec262c 100644
--- a/crates/tt/src/lib.rs
+++ b/crates/tt/src/lib.rs
@@ -86,10 +86,20 @@ pub enum Spacing {
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Ident {
+ /// Identifier or keyword. Unlike rustc, we keep "r#" prefix when it represents a raw identifier.
pub text: SmolStr,
pub id: TokenId,
}
+impl Ident {
+ /// Constructor intended to be used only by proc macro server. `text` should not contain raw
+ /// identifier prefix.
+ pub fn new_with_is_raw(text: SmolStr, id: TokenId, is_raw: bool) -> Self {
+ let text = if is_raw { SmolStr::from_iter(["r#", &text]) } else { text };
+ Ident { text, id }
+ }
+}
+
impl Leaf {
pub fn id(&self) -> TokenId {
match self {