2
2
3
3
use std:: fmt;
4
4
5
- use syntax:: { ast, utils:: is_raw_identifier, SmolStr } ;
5
+ use syntax:: { ast, format_smolstr , utils:: is_raw_identifier, SmolStr } ;
6
6
7
7
/// `Name` is a wrapper around string, which is used in hir for both references
8
8
/// and declarations. In theory, names should also carry hygiene info, but we are
@@ -69,8 +69,8 @@ impl Name {
69
69
}
70
70
71
71
/// 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) )
74
74
}
75
75
76
76
/// Resolve a name from the text of token.
@@ -83,7 +83,7 @@ impl Name {
83
83
// Rust, e.g. "try" in Rust 2015. Even in such cases, we keep track of them in their
84
84
// escaped form.
85
85
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) )
87
87
}
88
88
_ => Name :: new_text ( raw_text. into ( ) ) ,
89
89
}
@@ -99,7 +99,7 @@ impl Name {
99
99
/// name is equal only to itself. It's not clear how to implement this in
100
100
/// salsa though, so we punt on that bit for a moment.
101
101
pub const fn missing ( ) -> Name {
102
- Name :: new_inline ( "[missing name]" )
102
+ Name :: new_static ( "[missing name]" )
103
103
}
104
104
105
105
/// Returns true if this is a fake name for things missing in the source code. See
@@ -119,7 +119,7 @@ impl Name {
119
119
use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
120
120
static CNT : AtomicUsize = AtomicUsize :: new ( 0 ) ;
121
121
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}" ) )
123
123
}
124
124
125
125
/// Returns the tuple index this name represents if it is a tuple field.
@@ -260,7 +260,7 @@ pub mod known {
260
260
$(
261
261
#[ allow( bad_style) ]
262
262
pub const $ident: super :: Name =
263
- super :: Name :: new_inline ( stringify!( $ident) ) ;
263
+ super :: Name :: new_static ( stringify!( $ident) ) ;
264
264
) *
265
265
} ;
266
266
}
@@ -471,11 +471,11 @@ pub mod known {
471
471
) ;
472
472
473
473
// 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" ) ;
476
476
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" ) ;
479
479
480
480
#[ macro_export]
481
481
macro_rules! name {
0 commit comments