Skip to content

Commit dcb20d7

Browse files
Daniel BloomDaniel-Aaron-Bloom
authored andcommitted
Add support for $crate to Ident
1 parent 1a90510 commit dcb20d7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

proc_macro/src/bridge/symbol.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl Symbol {
3333
/// Validates and normalizes before converting it to a symbol.
3434
pub(crate) fn new_ident(string: &str, is_raw: bool) -> Self {
3535
// Fast-path: check if this is a valid ASCII identifier
36-
if Self::is_valid_ascii_ident(string.as_bytes()) {
36+
if Self::is_valid_ascii_ident(string.as_bytes()) || string == "$crate" {
3737
if is_raw && !Self::can_be_raw(string) {
3838
panic!("`{}` cannot be a raw identifier", string);
3939
}
@@ -79,7 +79,7 @@ impl Symbol {
7979
// Mimics the behavior of `Symbol::can_be_raw` from `rustc_span`
8080
fn can_be_raw(string: &str) -> bool {
8181
match string {
82-
"_" | "super" | "self" | "Self" | "crate" => false,
82+
"_" | "super" | "self" | "Self" | "crate" | "$crate" => false,
8383
_ => true,
8484
}
8585
}

0 commit comments

Comments
 (0)