@@ -1178,18 +1178,18 @@ impl<'a> hir::lowering::Resolver for Resolver<'a> {
1178
1178
}
1179
1179
1180
1180
trait Named {
1181
- fn name ( & self ) -> Name ;
1181
+ fn ident ( & self ) -> Ident ;
1182
1182
}
1183
1183
1184
1184
impl Named for ast:: PathSegment {
1185
- fn name ( & self ) -> Name {
1186
- self . identifier . name
1185
+ fn ident ( & self ) -> Ident {
1186
+ self . identifier
1187
1187
}
1188
1188
}
1189
1189
1190
1190
impl Named for hir:: PathSegment {
1191
- fn name ( & self ) -> Name {
1192
- self . name
1191
+ fn ident ( & self ) -> Ident {
1192
+ Ident :: with_empty_ctxt ( self . name )
1193
1193
}
1194
1194
}
1195
1195
@@ -1364,7 +1364,7 @@ impl<'a> Resolver<'a> {
1364
1364
/// Resolves the given module path from the given root `search_module`.
1365
1365
fn resolve_module_path_from_root ( & mut self ,
1366
1366
mut search_module : Module < ' a > ,
1367
- module_path : & [ Name ] ,
1367
+ module_path : & [ Ident ] ,
1368
1368
index : usize ,
1369
1369
span : Option < Span > )
1370
1370
-> ResolveResult < Module < ' a > > {
@@ -1387,7 +1387,7 @@ impl<'a> Resolver<'a> {
1387
1387
// upward though scope chains; we simply resolve names directly in
1388
1388
// modules as we go.
1389
1389
while index < module_path_len {
1390
- let name = module_path[ index] ;
1390
+ let name = module_path[ index] . name ;
1391
1391
match self . resolve_name_in_module ( search_module, name, TypeNS , false , span) {
1392
1392
Failed ( _) => {
1393
1393
let segment_name = name. as_str ( ) ;
@@ -1441,7 +1441,7 @@ impl<'a> Resolver<'a> {
1441
1441
/// Attempts to resolve the module part of an import directive or path
1442
1442
/// rooted at the given module.
1443
1443
fn resolve_module_path ( & mut self ,
1444
- module_path : & [ Name ] ,
1444
+ module_path : & [ Ident ] ,
1445
1445
use_lexical_scope : UseLexicalScopeFlag ,
1446
1446
span : Option < Span > )
1447
1447
-> ResolveResult < Module < ' a > > {
@@ -1479,7 +1479,7 @@ impl<'a> Resolver<'a> {
1479
1479
// This is not a crate-relative path. We resolve the
1480
1480
// first component of the path in the current lexical
1481
1481
// scope and then proceed to resolve below that.
1482
- let ident = Ident :: with_empty_ctxt ( module_path[ 0 ] ) ;
1482
+ let ident = module_path[ 0 ] ;
1483
1483
let lexical_binding =
1484
1484
self . resolve_ident_in_lexical_scope ( ident, TypeNS , span) ;
1485
1485
if let Some ( binding) = lexical_binding. and_then ( LexicalScopeBinding :: item) {
@@ -1577,11 +1577,11 @@ impl<'a> Resolver<'a> {
1577
1577
/// Resolves a "module prefix". A module prefix is one or both of (a) `self::`;
1578
1578
/// (b) some chain of `super::`.
1579
1579
/// grammar: (SELF MOD_SEP ) ? (SUPER MOD_SEP) *
1580
- fn resolve_module_prefix ( & mut self , module_path : & [ Name ] , span : Option < Span > )
1580
+ fn resolve_module_prefix ( & mut self , module_path : & [ Ident ] , span : Option < Span > )
1581
1581
-> ResolveResult < ModulePrefixResult < ' a > > {
1582
1582
// Start at the current module if we see `self` or `super`, or at the
1583
1583
// top of the crate otherwise.
1584
- let mut i = match & * module_path[ 0 ] . as_str ( ) {
1584
+ let mut i = match & * module_path[ 0 ] . name . as_str ( ) {
1585
1585
"self" => 1 ,
1586
1586
"super" => 0 ,
1587
1587
_ => return Success ( NoPrefixFound ) ,
@@ -1591,7 +1591,7 @@ impl<'a> Resolver<'a> {
1591
1591
self . module_map [ & self . current_module . normal_ancestor_id . unwrap ( ) ] ;
1592
1592
1593
1593
// Now loop through all the `super`s we find.
1594
- while i < module_path. len ( ) && "super" == module_path[ i] . as_str ( ) {
1594
+ while i < module_path. len ( ) && "super" == module_path[ i] . name . as_str ( ) {
1595
1595
debug ! ( "(resolving module prefix) resolving `super` at {}" ,
1596
1596
module_to_string( & containing_module) ) ;
1597
1597
if let Some ( parent) = containing_module. parent {
@@ -2681,12 +2681,8 @@ impl<'a> Resolver<'a> {
2681
2681
namespace : Namespace )
2682
2682
-> Result < & ' a NameBinding < ' a > ,
2683
2683
bool /* true if an error was reported */ > {
2684
- let module_path = segments. split_last ( )
2685
- . unwrap ( )
2686
- . 1
2687
- . iter ( )
2688
- . map ( |ps| ps. identifier . name )
2689
- . collect :: < Vec < _ > > ( ) ;
2684
+ let module_path =
2685
+ segments. split_last ( ) . unwrap ( ) . 1 . iter ( ) . map ( |ps| ps. identifier ) . collect :: < Vec < _ > > ( ) ;
2690
2686
2691
2687
let containing_module;
2692
2688
match self . resolve_module_path ( & module_path, UseLexicalScope , Some ( span) ) {
@@ -2715,7 +2711,7 @@ impl<'a> Resolver<'a> {
2715
2711
bool /* true if an error was reported */ >
2716
2712
where T : Named ,
2717
2713
{
2718
- let module_path = segments. split_last ( ) . unwrap ( ) . 1 . iter ( ) . map ( T :: name ) . collect :: < Vec < _ > > ( ) ;
2714
+ let module_path = segments. split_last ( ) . unwrap ( ) . 1 . iter ( ) . map ( T :: ident ) . collect :: < Vec < _ > > ( ) ;
2719
2715
let root_module = self . graph_root ;
2720
2716
2721
2717
let containing_module;
@@ -2734,7 +2730,7 @@ impl<'a> Resolver<'a> {
2734
2730
}
2735
2731
}
2736
2732
2737
- let name = segments. last ( ) . unwrap ( ) . name ( ) ;
2733
+ let name = segments. last ( ) . unwrap ( ) . ident ( ) . name ;
2738
2734
let result =
2739
2735
self . resolve_name_in_module ( containing_module, name, namespace, false , Some ( span) ) ;
2740
2736
result. success ( ) . ok_or ( false )
@@ -2976,9 +2972,8 @@ impl<'a> Resolver<'a> {
2976
2972
msg = format ! ( "did you mean {}?" , msg) ;
2977
2973
} else {
2978
2974
// we display a help message if this is a module
2979
- let name_path = path. segments . iter ( )
2980
- . map ( |seg| seg. identifier . name )
2981
- . collect :: < Vec < _ > > ( ) ;
2975
+ let name_path: Vec < _ > =
2976
+ path. segments . iter ( ) . map ( |seg| seg. identifier ) . collect ( ) ;
2982
2977
2983
2978
match self . resolve_module_path ( & name_path[ ..] ,
2984
2979
UseLexicalScope ,
@@ -3317,7 +3312,7 @@ impl<'a> Resolver<'a> {
3317
3312
}
3318
3313
} ;
3319
3314
3320
- let segments: Vec < _ > = path. segments . iter ( ) . map ( |seg| seg. identifier . name ) . collect ( ) ;
3315
+ let segments: Vec < _ > = path. segments . iter ( ) . map ( |seg| seg. identifier ) . collect ( ) ;
3321
3316
let mut path_resolution = err_path_resolution ( ) ;
3322
3317
let vis = match self . resolve_module_path ( & segments, DontUseLexicalScope , Some ( path. span ) ) {
3323
3318
Success ( module) => {
@@ -3469,26 +3464,24 @@ impl<'a> Resolver<'a> {
3469
3464
}
3470
3465
}
3471
3466
3472
- fn names_to_string ( names : & [ Name ] ) -> String {
3467
+ fn names_to_string ( names : & [ Ident ] ) -> String {
3473
3468
let mut first = true ;
3474
3469
let mut result = String :: new ( ) ;
3475
- for name in names {
3470
+ for ident in names {
3476
3471
if first {
3477
3472
first = false
3478
3473
} else {
3479
3474
result. push_str ( "::" )
3480
3475
}
3481
- result. push_str ( & name. as_str ( ) ) ;
3476
+ result. push_str ( & ident . name . as_str ( ) ) ;
3482
3477
}
3483
3478
result
3484
3479
}
3485
3480
3486
3481
fn path_names_to_string ( path : & Path , depth : usize ) -> String {
3487
- let names: Vec < ast:: Name > = path. segments [ ..path. segments . len ( ) - depth]
3488
- . iter ( )
3489
- . map ( |seg| seg. identifier . name )
3490
- . collect ( ) ;
3491
- names_to_string ( & names[ ..] )
3482
+ let names: Vec < _ > =
3483
+ path. segments [ ..path. segments . len ( ) - depth] . iter ( ) . map ( |seg| seg. identifier ) . collect ( ) ;
3484
+ names_to_string ( & names)
3492
3485
}
3493
3486
3494
3487
/// When an entity with a given name is not available in scope, we search for
@@ -3551,15 +3544,15 @@ fn show_candidates(session: &mut DiagnosticBuilder,
3551
3544
fn module_to_string ( module : Module ) -> String {
3552
3545
let mut names = Vec :: new ( ) ;
3553
3546
3554
- fn collect_mod ( names : & mut Vec < ast :: Name > , module : Module ) {
3547
+ fn collect_mod ( names : & mut Vec < Ident > , module : Module ) {
3555
3548
if let ModuleKind :: Def ( _, name) = module. kind {
3556
3549
if let Some ( parent) = module. parent {
3557
- names. push ( name) ;
3550
+ names. push ( Ident :: with_empty_ctxt ( name) ) ;
3558
3551
collect_mod ( names, parent) ;
3559
3552
}
3560
3553
} else {
3561
3554
// danger, shouldn't be ident?
3562
- names. push ( token:: intern ( "<opaque>" ) ) ;
3555
+ names. push ( token:: str_to_ident ( "<opaque>" ) ) ;
3563
3556
collect_mod ( names, module. parent . unwrap ( ) ) ;
3564
3557
}
3565
3558
}
@@ -3568,7 +3561,7 @@ fn module_to_string(module: Module) -> String {
3568
3561
if names. is_empty ( ) {
3569
3562
return "???" . to_string ( ) ;
3570
3563
}
3571
- names_to_string ( & names. into_iter ( ) . rev ( ) . collect :: < Vec < ast :: Name > > ( ) )
3564
+ names_to_string ( & names. into_iter ( ) . rev ( ) . collect :: < Vec < _ > > ( ) )
3572
3565
}
3573
3566
3574
3567
fn err_path_resolution ( ) -> PathResolution {
0 commit comments