@@ -73,7 +73,7 @@ use syntax_pos::Span;
73
73
const HIR_ID_COUNTER_LOCKED : u32 = 0xFFFFFFFF ;
74
74
75
75
pub struct LoweringContext < ' a > {
76
- crate_root : Option < & ' static str > ,
76
+ crate_root : Option < Symbol > ,
77
77
78
78
/// Used to assign ids to HIR nodes that do not directly correspond to an AST node.
79
79
sess : & ' a Session ,
@@ -164,8 +164,8 @@ pub trait Resolver {
164
164
fn resolve_str_path (
165
165
& mut self ,
166
166
span : Span ,
167
- crate_root : Option < & str > ,
168
- components : & [ & str ] ,
167
+ crate_root : Option < Symbol > ,
168
+ components : & [ Symbol ] ,
169
169
is_value : bool ,
170
170
) -> hir:: Path ;
171
171
}
@@ -228,7 +228,7 @@ pub fn lower_crate(
228
228
dep_graph. assert_ignored ( ) ;
229
229
230
230
LoweringContext {
231
- crate_root : std_inject:: injected_crate_name ( ) ,
231
+ crate_root : std_inject:: injected_crate_name ( ) . map ( Symbol :: intern ) ,
232
232
sess,
233
233
cstore,
234
234
resolver,
@@ -1149,7 +1149,7 @@ impl<'a> LoweringContext<'a> {
1149
1149
] . into ( ) ) ,
1150
1150
) ;
1151
1151
let gen_future = self . expr_std_path (
1152
- unstable_span, & [ " future" , " from_generator" ] , None , ThinVec :: new ( ) ) ;
1152
+ unstable_span, & [ sym :: future, sym :: from_generator] , None , ThinVec :: new ( ) ) ;
1153
1153
hir:: ExprKind :: Call ( P ( gen_future) , hir_vec ! [ generator] )
1154
1154
}
1155
1155
@@ -2548,7 +2548,7 @@ impl<'a> LoweringContext<'a> {
2548
2548
2549
2549
// ::std::future::Future<future_params>
2550
2550
let future_path =
2551
- self . std_path ( span, & [ " future" , " Future" ] , Some ( future_params) , false ) ;
2551
+ self . std_path ( span, & [ sym :: future, sym :: Future ] , Some ( future_params) , false ) ;
2552
2552
2553
2553
hir:: GenericBound :: Trait (
2554
2554
hir:: PolyTraitRef {
@@ -4194,7 +4194,7 @@ impl<'a> LoweringContext<'a> {
4194
4194
|x : P < hir:: Expr > | x. into_inner ( ) ,
4195
4195
) ;
4196
4196
block. expr = Some ( this. wrap_in_try_constructor (
4197
- " from_ok" , tail, unstable_span) ) ;
4197
+ sym :: from_ok, tail, unstable_span) ) ;
4198
4198
hir:: ExprKind :: Block ( P ( block) , None )
4199
4199
} )
4200
4200
}
@@ -4336,7 +4336,7 @@ impl<'a> LoweringContext<'a> {
4336
4336
self . expr_call_std_assoc_fn (
4337
4337
id,
4338
4338
e. span ,
4339
- & [ " ops" , " RangeInclusive" ] ,
4339
+ & [ sym :: ops, sym :: RangeInclusive ] ,
4340
4340
"new" ,
4341
4341
hir_vec ! [ e1, e2] ,
4342
4342
)
@@ -4345,11 +4345,11 @@ impl<'a> LoweringContext<'a> {
4345
4345
use syntax:: ast:: RangeLimits :: * ;
4346
4346
4347
4347
let path = match ( e1, e2, lims) {
4348
- ( & None , & None , HalfOpen ) => " RangeFull" ,
4349
- ( & Some ( ..) , & None , HalfOpen ) => " RangeFrom" ,
4350
- ( & None , & Some ( ..) , HalfOpen ) => " RangeTo" ,
4351
- ( & Some ( ..) , & Some ( ..) , HalfOpen ) => " Range" ,
4352
- ( & None , & Some ( ..) , Closed ) => " RangeToInclusive" ,
4348
+ ( & None , & None , HalfOpen ) => sym :: RangeFull ,
4349
+ ( & Some ( ..) , & None , HalfOpen ) => sym :: RangeFrom ,
4350
+ ( & None , & Some ( ..) , HalfOpen ) => sym :: RangeTo ,
4351
+ ( & Some ( ..) , & Some ( ..) , HalfOpen ) => sym :: Range ,
4352
+ ( & None , & Some ( ..) , Closed ) => sym :: RangeToInclusive ,
4353
4353
( & Some ( ..) , & Some ( ..) , Closed ) => unreachable ! ( ) ,
4354
4354
( _, & None , Closed ) => self . diagnostic ( )
4355
4355
. span_fatal ( e. span , "inclusive range with no end" )
@@ -4367,7 +4367,7 @@ impl<'a> LoweringContext<'a> {
4367
4367
. collect :: < P < [ hir:: Field ] > > ( ) ;
4368
4368
4369
4369
let is_unit = fields. is_empty ( ) ;
4370
- let struct_path = [ " ops" , path] ;
4370
+ let struct_path = [ sym :: ops, path] ;
4371
4371
let struct_path = self . std_path ( e. span , & struct_path, None , is_unit) ;
4372
4372
let struct_path = hir:: QPath :: Resolved ( None , P ( struct_path) ) ;
4373
4373
@@ -4656,7 +4656,7 @@ impl<'a> LoweringContext<'a> {
4656
4656
let match_expr = {
4657
4657
let iter = P ( self . expr_ident ( head_sp, iter, iter_pat_nid) ) ;
4658
4658
let ref_mut_iter = self . expr_mut_addr_of ( head_sp, iter) ;
4659
- let next_path = & [ " iter" , " Iterator" , " next" ] ;
4659
+ let next_path = & [ sym :: iter, sym :: Iterator , sym :: next] ;
4660
4660
let next_expr = P ( self . expr_call_std_path (
4661
4661
head_sp,
4662
4662
next_path,
@@ -4723,7 +4723,8 @@ impl<'a> LoweringContext<'a> {
4723
4723
4724
4724
// `match ::std::iter::IntoIterator::into_iter(<head>) { ... }`
4725
4725
let into_iter_expr = {
4726
- let into_iter_path = & [ "iter" , "IntoIterator" , "into_iter" ] ;
4726
+ let into_iter_path =
4727
+ & [ sym:: iter, sym:: IntoIterator , sym:: into_iter] ;
4727
4728
P ( self . expr_call_std_path (
4728
4729
head_sp,
4729
4730
into_iter_path,
@@ -4780,7 +4781,7 @@ impl<'a> LoweringContext<'a> {
4780
4781
// expand <expr>
4781
4782
let sub_expr = self . lower_expr ( sub_expr) ;
4782
4783
4783
- let path = & [ " ops" , " Try" , " into_result" ] ;
4784
+ let path = & [ sym :: ops, sym :: Try , sym :: into_result] ;
4784
4785
P ( self . expr_call_std_path (
4785
4786
unstable_span,
4786
4787
path,
@@ -4822,12 +4823,12 @@ impl<'a> LoweringContext<'a> {
4822
4823
let err_ident = self . str_to_ident ( "err" ) ;
4823
4824
let ( err_local, err_local_nid) = self . pat_ident ( try_span, err_ident) ;
4824
4825
let from_expr = {
4825
- let from_path = & [ " convert" , " From" , " from" ] ;
4826
+ let from_path = & [ sym :: convert, sym :: From , sym :: from] ;
4826
4827
let err_expr = self . expr_ident ( try_span, err_ident, err_local_nid) ;
4827
4828
self . expr_call_std_path ( try_span, from_path, hir_vec ! [ err_expr] )
4828
4829
} ;
4829
4830
let from_err_expr =
4830
- self . wrap_in_try_constructor ( " from_error" , from_expr, unstable_span) ;
4831
+ self . wrap_in_try_constructor ( sym :: from_error, from_expr, unstable_span) ;
4831
4832
let thin_attrs = ThinVec :: from ( attrs) ;
4832
4833
let catch_scope = self . catch_scopes . last ( ) . map ( |x| * x) ;
4833
4834
let ret_expr = if let Some ( catch_node) = catch_scope {
@@ -5057,7 +5058,7 @@ impl<'a> LoweringContext<'a> {
5057
5058
fn expr_call_std_path (
5058
5059
& mut self ,
5059
5060
span : Span ,
5060
- path_components : & [ & str ] ,
5061
+ path_components : & [ Symbol ] ,
5061
5062
args : hir:: HirVec < hir:: Expr > ,
5062
5063
) -> hir:: Expr {
5063
5064
let path = P ( self . expr_std_path ( span, path_components, None , ThinVec :: new ( ) ) ) ;
@@ -5077,7 +5078,7 @@ impl<'a> LoweringContext<'a> {
5077
5078
& mut self ,
5078
5079
ty_path_id : hir:: HirId ,
5079
5080
span : Span ,
5080
- ty_path_components : & [ & str ] ,
5081
+ ty_path_components : & [ Symbol ] ,
5081
5082
assoc_fn_name : & str ,
5082
5083
args : hir:: HirVec < hir:: Expr > ,
5083
5084
) -> hir:: ExprKind {
@@ -5119,7 +5120,7 @@ impl<'a> LoweringContext<'a> {
5119
5120
fn expr_std_path (
5120
5121
& mut self ,
5121
5122
span : Span ,
5122
- components : & [ & str ] ,
5123
+ components : & [ Symbol ] ,
5123
5124
params : Option < P < hir:: GenericArgs > > ,
5124
5125
attrs : ThinVec < Attribute > ,
5125
5126
) -> hir:: Expr {
@@ -5250,25 +5251,25 @@ impl<'a> LoweringContext<'a> {
5250
5251
}
5251
5252
5252
5253
fn pat_ok ( & mut self , span : Span , pat : P < hir:: Pat > ) -> P < hir:: Pat > {
5253
- self . pat_std_enum ( span, & [ " result" , " Result" , "Ok" ] , hir_vec ! [ pat] )
5254
+ self . pat_std_enum ( span, & [ sym :: result, sym :: Result , sym :: Ok ] , hir_vec ! [ pat] )
5254
5255
}
5255
5256
5256
5257
fn pat_err ( & mut self , span : Span , pat : P < hir:: Pat > ) -> P < hir:: Pat > {
5257
- self . pat_std_enum ( span, & [ " result" , " Result" , " Err" ] , hir_vec ! [ pat] )
5258
+ self . pat_std_enum ( span, & [ sym :: result, sym :: Result , sym :: Err ] , hir_vec ! [ pat] )
5258
5259
}
5259
5260
5260
5261
fn pat_some ( & mut self , span : Span , pat : P < hir:: Pat > ) -> P < hir:: Pat > {
5261
- self . pat_std_enum ( span, & [ " option" , " Option" , " Some" ] , hir_vec ! [ pat] )
5262
+ self . pat_std_enum ( span, & [ sym :: option, sym :: Option , sym :: Some ] , hir_vec ! [ pat] )
5262
5263
}
5263
5264
5264
5265
fn pat_none ( & mut self , span : Span ) -> P < hir:: Pat > {
5265
- self . pat_std_enum ( span, & [ " option" , " Option" , " None" ] , hir_vec ! [ ] )
5266
+ self . pat_std_enum ( span, & [ sym :: option, sym :: Option , sym :: None ] , hir_vec ! [ ] )
5266
5267
}
5267
5268
5268
5269
fn pat_std_enum (
5269
5270
& mut self ,
5270
5271
span : Span ,
5271
- components : & [ & str ] ,
5272
+ components : & [ Symbol ] ,
5272
5273
subpats : hir:: HirVec < P < hir:: Pat > > ,
5273
5274
) -> P < hir:: Pat > {
5274
5275
let path = self . std_path ( span, components, None , true ) ;
@@ -5321,7 +5322,7 @@ impl<'a> LoweringContext<'a> {
5321
5322
fn std_path (
5322
5323
& mut self ,
5323
5324
span : Span ,
5324
- components : & [ & str ] ,
5325
+ components : & [ Symbol ] ,
5325
5326
params : Option < P < hir:: GenericArgs > > ,
5326
5327
is_value : bool ,
5327
5328
) -> hir:: Path {
@@ -5520,11 +5521,11 @@ impl<'a> LoweringContext<'a> {
5520
5521
5521
5522
fn wrap_in_try_constructor (
5522
5523
& mut self ,
5523
- method : & ' static str ,
5524
+ method : Symbol ,
5524
5525
e : hir:: Expr ,
5525
5526
unstable_span : Span ,
5526
5527
) -> P < hir:: Expr > {
5527
- let path = & [ " ops" , " Try" , method] ;
5528
+ let path = & [ sym :: ops, sym :: Try , method] ;
5528
5529
let from_err = P ( self . expr_std_path ( unstable_span, path, None ,
5529
5530
ThinVec :: new ( ) ) ) ;
5530
5531
P ( self . expr_call ( e. span , from_err, hir_vec ! [ e] ) )
@@ -5594,15 +5595,15 @@ impl<'a> LoweringContext<'a> {
5594
5595
let new_unchecked_expr_kind = self . expr_call_std_assoc_fn (
5595
5596
pin_ty_id,
5596
5597
span,
5597
- & [ " pin" , " Pin" ] ,
5598
+ & [ sym :: pin, sym :: Pin ] ,
5598
5599
"new_unchecked" ,
5599
5600
hir_vec ! [ ref_mut_pinned] ,
5600
5601
) ;
5601
5602
let new_unchecked = P ( self . expr ( span, new_unchecked_expr_kind, ThinVec :: new ( ) ) ) ;
5602
5603
let unsafe_expr = self . expr_unsafe ( new_unchecked) ;
5603
5604
P ( self . expr_call_std_path (
5604
5605
gen_future_span,
5605
- & [ " future" , " poll_with_tls_context" ] ,
5606
+ & [ sym :: future, sym :: poll_with_tls_context] ,
5606
5607
hir_vec ! [ unsafe_expr] ,
5607
5608
) )
5608
5609
} ;
@@ -5616,7 +5617,7 @@ impl<'a> LoweringContext<'a> {
5616
5617
let x_expr = P ( self . expr_ident ( span, x_ident, x_pat_hid) ) ;
5617
5618
let ready_pat = self . pat_std_enum (
5618
5619
span,
5619
- & [ " task" , " Poll" , " Ready" ] ,
5620
+ & [ sym :: task, sym :: Poll , sym :: Ready ] ,
5620
5621
hir_vec ! [ x_pat] ,
5621
5622
) ;
5622
5623
let break_x = self . with_loop_scope ( loop_node_id, |this| {
@@ -5633,7 +5634,7 @@ impl<'a> LoweringContext<'a> {
5633
5634
let pending_arm = {
5634
5635
let pending_pat = self . pat_std_enum (
5635
5636
span,
5636
- & [ " task" , " Poll" , " Pending" ] ,
5637
+ & [ sym :: task, sym :: Poll , sym :: Pending ] ,
5637
5638
hir_vec ! [ ] ,
5638
5639
) ;
5639
5640
let empty_block = P ( self . expr_block_empty ( span) ) ;
0 commit comments