diff options
| author | Daniel Bloom <daniel@wormholelabs.xyz> | 2025-04-13 22:17:26 -0700 |
|---|---|---|
| committer | Daniel Bloom <7810950-Daniel.Aaron.Bloom@users.noreply.gitlab.com> | 2025-06-12 01:13:24 -0700 |
| commit | 6d1e93d8cdea975303397d91f726c40f5a7396fd (patch) | |
| tree | 633c1fdcd5d6bc225f57a1e91670d0c0971dc43d /library/proc_macro | |
| parent | fe5c95d4ae33ec9d7831921e448e2daf8264ea42 (diff) | |
| download | rust-6d1e93d8cdea975303397d91f726c40f5a7396fd.tar.gz rust-6d1e93d8cdea975303397d91f726c40f5a7396fd.zip | |
Add support for $crate to Ident
Diffstat (limited to 'library/proc_macro')
| -rw-r--r-- | library/proc_macro/src/bridge/symbol.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/library/proc_macro/src/bridge/symbol.rs b/library/proc_macro/src/bridge/symbol.rs index 6a1cecd69fb..57ca7db9fcd 100644 --- a/library/proc_macro/src/bridge/symbol.rs +++ b/library/proc_macro/src/bridge/symbol.rs @@ -33,7 +33,7 @@ impl Symbol { /// Validates and normalizes before converting it to a symbol. pub(crate) fn new_ident(string: &str, is_raw: bool) -> Self { // Fast-path: check if this is a valid ASCII identifier - if Self::is_valid_ascii_ident(string.as_bytes()) { + if Self::is_valid_ascii_ident(string.as_bytes()) || string == "$crate" { if is_raw && !Self::can_be_raw(string) { panic!("`{}` cannot be a raw identifier", string); } @@ -79,7 +79,7 @@ impl Symbol { // Mimics the behavior of `Symbol::can_be_raw` from `rustc_span` fn can_be_raw(string: &str) -> bool { match string { - "_" | "super" | "self" | "Self" | "crate" => false, + "_" | "super" | "self" | "Self" | "crate" | "$crate" => false, _ => true, } } |
