@@ -2510,12 +2510,24 @@ impl Ident {
25102510        Ident :: new ( self . name ,  span. with_ctxt ( self . span . ctxt ( ) ) ) 
25112511    } 
25122512
2513-     /// Creates a new ident with the same span and name with leading quote removed, if any. 
2514- /// If called on an empty ident, or with name just a single quote, returns an empty ident which is invalid. 
2513+     /// Creates a new ident with the same span and name with leading quotes removed, if any. 
2514+ /// If called on an empty ident, or with name just single quotes, returns an empty ident which is invalid. 
2515+ /// Creating empty ident will trigger debug assertions. 
2516+ /// Use `without_first_quote_checked` instead if not certain this will return valid ident. 
25152517pub  fn  without_first_quote ( self )  -> Ident  { 
25162518        Ident :: new ( Symbol :: intern ( self . as_str ( ) . trim_start_matches ( '\'' ) ) ,  self . span ) 
25172519    } 
25182520
2521+     /// Creates a new ident with the same span and name with leading quotes removed, if any. 
2522+ /// If called on an empty ident, or with name just single quotes, returns `None`. 
2523+ /// If you are certain this will return valid ident, use `without_first_quote` instead. 
2524+ pub  fn  without_first_quote_checked ( self )  -> Option < Ident >  { 
2525+         match  Symbol :: intern ( self . as_str ( ) . trim_start_matches ( '\'' ) )  { 
2526+             sym:: empty => None , 
2527+             name => Some ( Ident :: new ( name,  self . span ) ) , 
2528+         } 
2529+     } 
2530+ 
25192531    /// "Normalize" ident for use in comparisons using "item hygiene". 
25202532/// Identifiers with same string value become same if they came from the same macro 2.0 macro 
25212533/// (e.g., `macro` item, but not `macro_rules` item) and stay different if they came from 
@@ -3099,15 +3111,16 @@ impl Ident {
30993111    } 
31003112
31013113    pub  fn  is_raw_lifetime_guess ( self )  -> bool  { 
3102-         // Check that the name isn't just a  single quote . 
3114+         // Ident name might be an empty string or just  single quotes, so call checked function . 
31033115        // `self.without_first_quote()` would return empty ident, which triggers debug assert. 
3104-         if  self . name . as_str ( )  == "'"  { 
3105-             return  false ; 
3116+         match  self . without_first_quote_checked ( )  { 
3117+             None  => false , 
3118+             Some ( ident_without_apostrophe)  => { 
3119+                 ident_without_apostrophe. name  != self . name 
3120+                     && ident_without_apostrophe. name . can_be_raw ( ) 
3121+                     && ident_without_apostrophe. is_reserved_lifetime ( ) 
3122+             } 
31063123        } 
3107-         let  ident_without_apostrophe = self . without_first_quote ( ) ; 
3108-         ident_without_apostrophe. name  != self . name 
3109-             && ident_without_apostrophe. name . can_be_raw ( ) 
3110-             && ident_without_apostrophe. is_reserved_lifetime ( ) 
31113124    } 
31123125
31133126    pub  fn  guess_print_mode ( self )  -> IdentPrintMode  { 
0 commit comments