1616use macros:: { InvocationData , ParentScope , LegacyScope } ;
1717use resolve_imports:: ImportDirective ;
1818use resolve_imports:: ImportDirectiveSubclass :: { self , GlobImport , SingleImport } ;
19- use { Module , ModuleData , ModuleKind , NameBinding , NameBindingKind , ToNameBinding } ;
19+ use { Module , ModuleData , ModuleKind , NameBinding , NameBindingKind , Segment , ToNameBinding } ;
2020use { ModuleOrUniformRoot , PerNS , Resolver , ResolverArenas , ExternPreludeEntry } ;
2121use Namespace :: { self , TypeNS , ValueNS , MacroNS } ;
2222use { resolve_error, resolve_struct_error, ResolutionError } ;
@@ -122,7 +122,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
122122 use_tree : & ast:: UseTree ,
123123 id : NodeId ,
124124 vis : ty:: Visibility ,
125- parent_prefix : & [ Ident ] ,
125+ parent_prefix : & [ Segment ] ,
126126 mut uniform_paths_canary_emitted : bool ,
127127 nested : bool ,
128128 item : & Item ,
@@ -139,10 +139,10 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
139139 self . session . features_untracked ( ) . uniform_paths ;
140140
141141 let prefix_iter = || parent_prefix. iter ( ) . cloned ( )
142- . chain ( use_tree. prefix . segments . iter ( ) . map ( |seg| seg. ident ) ) ;
142+ . chain ( use_tree. prefix . segments . iter ( ) . map ( |seg| seg. into ( ) ) ) ;
143143 let prefix_start = prefix_iter ( ) . next ( ) ;
144- let starts_with_non_keyword = prefix_start. map_or ( false , |( ident , _ ) | {
145- !ident. is_path_segment_keyword ( )
144+ let starts_with_non_keyword = prefix_start. map_or ( false , |seg | {
145+ !seg . ident . is_path_segment_keyword ( )
146146 } ) ;
147147
148148 // Imports are resolved as global by default, prepend `CrateRoot`,
@@ -156,7 +156,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
156156 } ;
157157 let root = if inject_crate_root {
158158 let span = use_tree. prefix . span . shrink_to_lo ( ) ;
159- Some ( Ident :: new ( keywords:: CrateRoot . name ( ) , span) )
159+ Some ( Segment :: from_ident ( Ident :: new ( keywords:: CrateRoot . name ( ) , span) ) )
160160 } else {
161161 None
162162 } ;
@@ -202,13 +202,13 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
202202 let source = prefix_start. unwrap ( ) ;
203203
204204 // Helper closure to emit a canary with the given base path.
205- let emit = |this : & mut Self , base : Option < ( Ident , Option < NodeId > ) > | {
205+ let emit = |this : & mut Self , base : Option < Segment > | {
206206 let subclass = SingleImport {
207207 target : Ident {
208208 name : keywords:: Underscore . name ( ) . gensymed ( ) ,
209- span : source. 0 . span ,
209+ span : source. ident . span ,
210210 } ,
211- source : source. 0 ,
211+ source : source. ident ,
212212 result : PerNS {
213213 type_ns : Cell :: new ( Err ( Undetermined ) ) ,
214214 value_ns : Cell :: new ( Err ( Undetermined ) ) ,
@@ -219,7 +219,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
219219 this. add_import_directive (
220220 base. into_iter ( ) . collect ( ) ,
221221 subclass. clone ( ) ,
222- source. 0 . span ,
222+ source. ident . span ,
223223 id,
224224 root_use_tree. span ,
225225 root_id,
@@ -230,15 +230,18 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
230230 } ;
231231
232232 // A single simple `self::x` canary.
233- emit ( self , Some ( ( Ident {
234- name : keywords:: SelfValue . name ( ) ,
235- span : source. 0 . span ,
236- } , source. 1 ) ) ) ;
233+ emit ( self , Some ( Segment {
234+ ident : Ident {
235+ name : keywords:: SelfValue . name ( ) ,
236+ span : source. ident . span ,
237+ } ,
238+ id : source. id
239+ } ) ) ;
237240
238241 // One special unprefixed canary per block scope around
239242 // the import, to detect items unreachable by `self::x`.
240243 let orig_current_module = self . current_module ;
241- let mut span = source. 0 . span . modern ( ) ;
244+ let mut span = source. ident . span . modern ( ) ;
242245 loop {
243246 match self . current_module . kind {
244247 ModuleKind :: Block ( ..) => emit ( self , None ) ,
@@ -265,11 +268,11 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
265268
266269 if nested {
267270 // Correctly handle `self`
268- if source. 0 . name == keywords:: SelfValue . name ( ) {
271+ if source. ident . name == keywords:: SelfValue . name ( ) {
269272 type_ns_only = true ;
270273
271- let empty_prefix = module_path. last ( ) . map_or ( true , |( ident , _ ) | {
272- ident. name == keywords:: CrateRoot . name ( )
274+ let empty_prefix = module_path. last ( ) . map_or ( true , |seg | {
275+ seg . ident . name == keywords:: CrateRoot . name ( )
273276 } ) ;
274277 if empty_prefix {
275278 resolve_error (
@@ -284,20 +287,20 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
284287 // Replace `use foo::self;` with `use foo;`
285288 source = module_path. pop ( ) . unwrap ( ) ;
286289 if rename. is_none ( ) {
287- ident = source. 0 ;
290+ ident = source. ident ;
288291 }
289292 }
290293 } else {
291294 // Disallow `self`
292- if source. 0 . name == keywords:: SelfValue . name ( ) {
295+ if source. ident . name == keywords:: SelfValue . name ( ) {
293296 resolve_error ( self ,
294297 use_tree. span ,
295298 ResolutionError :: SelfImportsOnlyAllowedWithin ) ;
296299 }
297300
298301 // Disallow `use $crate;`
299- if source. 0 . name == keywords:: DollarCrate . name ( ) && module_path. is_empty ( ) {
300- let crate_root = self . resolve_crate_root ( source. 0 ) ;
302+ if source. ident . name == keywords:: DollarCrate . name ( ) && module_path. is_empty ( ) {
303+ let crate_root = self . resolve_crate_root ( source. ident ) ;
301304 let crate_name = match crate_root. kind {
302305 ModuleKind :: Def ( _, name) => name,
303306 ModuleKind :: Block ( ..) => unreachable ! ( ) ,
@@ -307,11 +310,14 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
307310 // while the current crate doesn't have a valid `crate_name`.
308311 if crate_name != keywords:: Invalid . name ( ) {
309312 // `crate_name` should not be interpreted as relative.
310- module_path. push ( ( Ident {
311- name : keywords:: CrateRoot . name ( ) ,
312- span : source. 0 . span ,
313- } , Some ( self . session . next_node_id ( ) ) ) ) ;
314- source. 0 . name = crate_name;
313+ module_path. push ( Segment {
314+ ident : Ident {
315+ name : keywords:: CrateRoot . name ( ) ,
316+ span : source. ident . span ,
317+ } ,
318+ id : Some ( self . session . next_node_id ( ) ) ,
319+ } ) ;
320+ source. ident . name = crate_name;
315321 }
316322 if rename. is_none ( ) {
317323 ident. name = crate_name;
@@ -332,7 +338,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
332338
333339 let subclass = SingleImport {
334340 target : ident,
335- source : source. 0 ,
341+ source : source. ident ,
336342 result : PerNS {
337343 type_ns : Cell :: new ( Err ( Undetermined ) ) ,
338344 value_ns : Cell :: new ( Err ( Undetermined ) ) ,
@@ -392,17 +398,6 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
392398 e. emit ( ) ;
393399 }
394400
395- let prefix = ast:: Path {
396- segments : module_path. into_iter ( )
397- . map ( |( ident, id) | {
398- let mut seg = ast:: PathSegment :: from_ident ( ident) ;
399- seg. id = id. expect ( "Missing node id" ) ;
400- seg
401- } )
402- . collect ( ) ,
403- span : path. span ,
404- } ;
405-
406401 for & ( ref tree, id) in items {
407402 self . build_reduced_graph_for_use_tree (
408403 root_use_tree,
0 commit comments