22
33use std:: fmt;
44
5- use syntax:: { ast, utils:: is_raw_identifier, SmolStr } ;
5+ use syntax:: { ast, format_smolstr , utils:: is_raw_identifier, SmolStr } ;
66
77/// `Name` is a wrapper around string, which is used in hir for both references
88/// and declarations. In theory, names should also carry hygiene info, but we are
@@ -69,8 +69,8 @@ impl Name {
6969 }
7070
7171 /// Shortcut to create inline plain text name. Panics if `text.len() > 22`
72- const fn new_inline ( text : & str ) -> Name {
73- Name :: new_text ( SmolStr :: new_inline ( text) )
72+ const fn new_static ( text : & ' static str ) -> Name {
73+ Name :: new_text ( SmolStr :: new_static ( text) )
7474 }
7575
7676 /// Resolve a name from the text of token.
@@ -83,7 +83,7 @@ impl Name {
8383 // Rust, e.g. "try" in Rust 2015. Even in such cases, we keep track of them in their
8484 // escaped form.
8585 None if is_raw_identifier ( raw_text) => {
86- Name :: new_text ( SmolStr :: from_iter ( [ "r#" , raw_text] ) )
86+ Name :: new_text ( format_smolstr ! ( "r#{} " , raw_text) )
8787 }
8888 _ => Name :: new_text ( raw_text. into ( ) ) ,
8989 }
@@ -99,7 +99,7 @@ impl Name {
9999 /// name is equal only to itself. It's not clear how to implement this in
100100 /// salsa though, so we punt on that bit for a moment.
101101 pub const fn missing ( ) -> Name {
102- Name :: new_inline ( "[missing name]" )
102+ Name :: new_static ( "[missing name]" )
103103 }
104104
105105 /// Returns true if this is a fake name for things missing in the source code. See
@@ -119,7 +119,7 @@ impl Name {
119119 use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
120120 static CNT : AtomicUsize = AtomicUsize :: new ( 0 ) ;
121121 let c = CNT . fetch_add ( 1 , Ordering :: Relaxed ) ;
122- Name :: new_text ( format ! ( "<ra@gennew>{c}" ) . into ( ) )
122+ Name :: new_text ( format_smolstr ! ( "<ra@gennew>{c}" ) )
123123 }
124124
125125 /// Returns the tuple index this name represents if it is a tuple field.
@@ -260,7 +260,7 @@ pub mod known {
260260 $(
261261 #[ allow( bad_style) ]
262262 pub const $ident: super :: Name =
263- super :: Name :: new_inline ( stringify!( $ident) ) ;
263+ super :: Name :: new_static ( stringify!( $ident) ) ;
264264 ) *
265265 } ;
266266 }
@@ -471,11 +471,11 @@ pub mod known {
471471 ) ;
472472
473473 // self/Self cannot be used as an identifier
474- pub const SELF_PARAM : super :: Name = super :: Name :: new_inline ( "self" ) ;
475- pub const SELF_TYPE : super :: Name = super :: Name :: new_inline ( "Self" ) ;
474+ pub const SELF_PARAM : super :: Name = super :: Name :: new_static ( "self" ) ;
475+ pub const SELF_TYPE : super :: Name = super :: Name :: new_static ( "Self" ) ;
476476
477- pub const STATIC_LIFETIME : super :: Name = super :: Name :: new_inline ( "'static" ) ;
478- pub const DOLLAR_CRATE : super :: Name = super :: Name :: new_inline ( "$crate" ) ;
477+ pub const STATIC_LIFETIME : super :: Name = super :: Name :: new_static ( "'static" ) ;
478+ pub const DOLLAR_CRATE : super :: Name = super :: Name :: new_static ( "$crate" ) ;
479479
480480 #[ macro_export]
481481 macro_rules! name {
0 commit comments