@@ -141,7 +141,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
141
141
let prefix_iter = || parent_prefix. iter ( ) . cloned ( )
142
142
. chain ( use_tree. prefix . segments . iter ( ) . map ( |seg| seg. ident ) ) ;
143
143
let prefix_start = prefix_iter ( ) . next ( ) ;
144
- let starts_with_non_keyword = prefix_start. map_or ( false , |ident| {
144
+ let starts_with_non_keyword = prefix_start. map_or ( false , |( ident, _ ) | {
145
145
!ident. is_path_segment_keyword ( )
146
146
} ) ;
147
147
@@ -202,13 +202,13 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
202
202
let source = prefix_start. unwrap ( ) ;
203
203
204
204
// Helper closure to emit a canary with the given base path.
205
- let emit = |this : & mut Self , base : Option < Ident > | {
205
+ let emit = |this : & mut Self , base : Option < ( Ident , Option < NodeId > ) > | {
206
206
let subclass = SingleImport {
207
207
target : Ident {
208
208
name : keywords:: Underscore . name ( ) . gensymed ( ) ,
209
- span : source. span ,
209
+ span : source. 0 . span ,
210
210
} ,
211
- source,
211
+ source : source . 0 ,
212
212
result : PerNS {
213
213
type_ns : Cell :: new ( Err ( Undetermined ) ) ,
214
214
value_ns : Cell :: new ( Err ( Undetermined ) ) ,
@@ -219,7 +219,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
219
219
this. add_import_directive (
220
220
base. into_iter ( ) . collect ( ) ,
221
221
subclass. clone ( ) ,
222
- source. span ,
222
+ source. 0 . span ,
223
223
id,
224
224
root_use_tree. span ,
225
225
root_id,
@@ -230,15 +230,15 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
230
230
} ;
231
231
232
232
// A single simple `self::x` canary.
233
- emit ( self , Some ( Ident {
233
+ emit ( self , Some ( ( Ident {
234
234
name : keywords:: SelfValue . name ( ) ,
235
- span : source. span ,
236
- } ) ) ;
235
+ span : source. 0 . span ,
236
+ } , source . 1 ) ) ) ;
237
237
238
238
// One special unprefixed canary per block scope around
239
239
// the import, to detect items unreachable by `self::x`.
240
240
let orig_current_module = self . current_module ;
241
- let mut span = source. span . modern ( ) ;
241
+ let mut span = source. 0 . span . modern ( ) ;
242
242
loop {
243
243
match self . current_module . kind {
244
244
ModuleKind :: Block ( ..) => emit ( self , None ) ,
@@ -265,10 +265,10 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
265
265
266
266
if nested {
267
267
// Correctly handle `self`
268
- if source. name == keywords:: SelfValue . name ( ) {
268
+ if source. 0 . name == keywords:: SelfValue . name ( ) {
269
269
type_ns_only = true ;
270
270
271
- let empty_prefix = module_path. last ( ) . map_or ( true , |ident| {
271
+ let empty_prefix = module_path. last ( ) . map_or ( true , |( ident, _ ) | {
272
272
ident. name == keywords:: CrateRoot . name ( )
273
273
} ) ;
274
274
if empty_prefix {
@@ -284,20 +284,20 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
284
284
// Replace `use foo::self;` with `use foo;`
285
285
source = module_path. pop ( ) . unwrap ( ) ;
286
286
if rename. is_none ( ) {
287
- ident = source;
287
+ ident = source. 0 ;
288
288
}
289
289
}
290
290
} else {
291
291
// Disallow `self`
292
- if source. name == keywords:: SelfValue . name ( ) {
292
+ if source. 0 . name == keywords:: SelfValue . name ( ) {
293
293
resolve_error ( self ,
294
294
use_tree. span ,
295
295
ResolutionError :: SelfImportsOnlyAllowedWithin ) ;
296
296
}
297
297
298
298
// Disallow `use $crate;`
299
- if source. name == keywords:: DollarCrate . name ( ) && module_path. is_empty ( ) {
300
- let crate_root = self . resolve_crate_root ( source) ;
299
+ if source. 0 . name == keywords:: DollarCrate . name ( ) && module_path. is_empty ( ) {
300
+ let crate_root = self . resolve_crate_root ( source. 0 ) ;
301
301
let crate_name = match crate_root. kind {
302
302
ModuleKind :: Def ( _, name) => name,
303
303
ModuleKind :: Block ( ..) => unreachable ! ( ) ,
@@ -307,11 +307,11 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
307
307
// while the current crate doesn't have a valid `crate_name`.
308
308
if crate_name != keywords:: Invalid . name ( ) {
309
309
// `crate_name` should not be interpreted as relative.
310
- module_path. push ( Ident {
310
+ module_path. push ( ( Ident {
311
311
name : keywords:: CrateRoot . name ( ) ,
312
- span : source. span ,
313
- } ) ;
314
- source. name = crate_name;
312
+ span : source. 0 . span ,
313
+ } , Some ( self . session . next_node_id ( ) ) ) ) ;
314
+ source. 0 . name = crate_name;
315
315
}
316
316
if rename. is_none ( ) {
317
317
ident. name = crate_name;
@@ -332,7 +332,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
332
332
333
333
let subclass = SingleImport {
334
334
target : ident,
335
- source,
335
+ source : source . 0 ,
336
336
result : PerNS {
337
337
type_ns : Cell :: new ( Err ( Undetermined ) ) ,
338
338
value_ns : Cell :: new ( Err ( Undetermined ) ) ,
@@ -393,6 +393,17 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
393
393
}
394
394
395
395
for & ( ref tree, id) in items {
396
+ let prefix = ast:: Path {
397
+ segments : module_path. iter ( )
398
+ . map ( |ident| {
399
+ let mut seg = ast:: PathSegment :: from_ident ( ident. 0 ) ;
400
+ seg. id = self . session . next_node_id ( ) ;
401
+ seg
402
+ } )
403
+ . collect ( ) ,
404
+ span : path. span ,
405
+ } ;
406
+
396
407
self . build_reduced_graph_for_use_tree (
397
408
root_use_tree,
398
409
root_id,
0 commit comments