This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -537,7 +537,14 @@ impl IdentifierKind {
537537 pub fn classify ( new_name : & str ) -> Result < IdentifierKind > {
538538 match parser:: LexedStr :: single_token ( new_name) {
539539 Some ( res) => match res {
540- ( SyntaxKind :: IDENT , _) => Ok ( IdentifierKind :: Ident ) ,
540+ ( SyntaxKind :: IDENT , _) => {
541+ if let Some ( inner) = new_name. strip_prefix ( "r#" ) {
542+ if matches ! ( inner, "self" | "crate" | "super" | "Self" ) {
543+ bail ! ( "Invalid name: `{}` cannot be a raw identifier" , inner) ;
544+ }
545+ }
546+ Ok ( IdentifierKind :: Ident )
547+ }
541548 ( T ! [ _] , _) => Ok ( IdentifierKind :: Underscore ) ,
542549 ( SyntaxKind :: LIFETIME_IDENT , _) if new_name != "'static" && new_name != "'_" => {
543550 Ok ( IdentifierKind :: Lifetime )
Original file line number Diff line number Diff line change @@ -562,6 +562,15 @@ impl Foo {
562562 ) ;
563563 }
564564
565+ #[ test]
566+ fn test_rename_mod_invalid_raw_ident ( ) {
567+ check (
568+ "r#self" ,
569+ r#"mod foo$0 {}"# ,
570+ "error: Invalid name: `self` cannot be a raw identifier" ,
571+ ) ;
572+ }
573+
565574 #[ test]
566575 fn test_rename_for_local ( ) {
567576 check (
You can’t perform that action at this time.
0 commit comments