@@ -136,7 +136,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
136
136
137
137
let mut module_path: Vec < _ > = prefix. segments . iter ( )
138
138
. chain ( path. segments . iter ( ) )
139
- . map ( |seg| seg. ident )
139
+ . map ( |seg| ( seg. ident , Some ( seg . id ) ) )
140
140
. collect ( ) ;
141
141
142
142
debug ! ( "build_reduced_graph_for_use_tree: module_path={:?}" , module_path) ;
@@ -172,7 +172,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
172
172
// ergonomically unacceptable.
173
173
let emit_uniform_paths_canary =
174
174
!uniform_paths_canary_emitted &&
175
- module_path. get ( 0 ) . map_or ( false , |ident| {
175
+ module_path. get ( 0 ) . map_or ( false , |( ident, _ ) | {
176
176
!ident. is_path_segment_keyword ( )
177
177
} ) ;
178
178
if emit_uniform_paths_canary {
@@ -182,13 +182,13 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
182
182
183
183
let source = module_path[ 0 ] ;
184
184
// Helper closure to emit a canary with the given base path.
185
- let emit = |this : & mut Self , base : Option < Ident > | {
185
+ let emit = |this : & mut Self , base : Option < ( Ident , Option < NodeId > ) > | {
186
186
let subclass = SingleImport {
187
187
target : Ident {
188
188
name : keywords:: Underscore . name ( ) . gensymed ( ) ,
189
- span : source. span ,
189
+ span : source. 0 . span ,
190
190
} ,
191
- source,
191
+ source : source . 0 ,
192
192
result : PerNS {
193
193
type_ns : Cell :: new ( Err ( Undetermined ) ) ,
194
194
value_ns : Cell :: new ( Err ( Undetermined ) ) ,
@@ -199,7 +199,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
199
199
this. add_import_directive (
200
200
base. into_iter ( ) . collect ( ) ,
201
201
subclass. clone ( ) ,
202
- source. span ,
202
+ source. 0 . span ,
203
203
id,
204
204
root_use_tree. span ,
205
205
root_id,
@@ -210,15 +210,15 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
210
210
} ;
211
211
212
212
// A single simple `self::x` canary.
213
- emit ( self , Some ( Ident {
213
+ emit ( self , Some ( ( Ident {
214
214
name : keywords:: SelfValue . name ( ) ,
215
- span : source. span ,
216
- } ) ) ;
215
+ span : source. 0 . span ,
216
+ } , source . 1 ) ) ) ;
217
217
218
218
// One special unprefixed canary per block scope around
219
219
// the import, to detect items unreachable by `self::x`.
220
220
let orig_current_module = self . current_module ;
221
- let mut span = source. span . modern ( ) ;
221
+ let mut span = source. 0 . span . modern ( ) ;
222
222
loop {
223
223
match self . current_module . kind {
224
224
ModuleKind :: Block ( ..) => emit ( self , None ) ,
@@ -244,10 +244,10 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
244
244
245
245
if nested {
246
246
// Correctly handle `self`
247
- if source. name == keywords:: SelfValue . name ( ) {
247
+ if source. 0 . name == keywords:: SelfValue . name ( ) {
248
248
type_ns_only = true ;
249
249
250
- let empty_prefix = module_path. last ( ) . map_or ( true , |ident| {
250
+ let empty_prefix = module_path. last ( ) . map_or ( true , |( ident, _ ) | {
251
251
ident. name == keywords:: CrateRoot . name ( )
252
252
} ) ;
253
253
if empty_prefix {
@@ -263,20 +263,20 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
263
263
// Replace `use foo::self;` with `use foo;`
264
264
source = module_path. pop ( ) . unwrap ( ) ;
265
265
if rename. is_none ( ) {
266
- ident = source;
266
+ ident = source. 0 ;
267
267
}
268
268
}
269
269
} else {
270
270
// Disallow `self`
271
- if source. name == keywords:: SelfValue . name ( ) {
271
+ if source. 0 . name == keywords:: SelfValue . name ( ) {
272
272
resolve_error ( self ,
273
273
use_tree. span ,
274
274
ResolutionError :: SelfImportsOnlyAllowedWithin ) ;
275
275
}
276
276
277
277
// Disallow `use $crate;`
278
- if source. name == keywords:: DollarCrate . name ( ) && module_path. is_empty ( ) {
279
- let crate_root = self . resolve_crate_root ( source) ;
278
+ if source. 0 . name == keywords:: DollarCrate . name ( ) && module_path. is_empty ( ) {
279
+ let crate_root = self . resolve_crate_root ( source. 0 ) ;
280
280
let crate_name = match crate_root. kind {
281
281
ModuleKind :: Def ( _, name) => name,
282
282
ModuleKind :: Block ( ..) => unreachable ! ( ) ,
@@ -286,11 +286,11 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
286
286
// while the current crate doesn't have a valid `crate_name`.
287
287
if crate_name != keywords:: Invalid . name ( ) {
288
288
// `crate_name` should not be interpreted as relative.
289
- module_path. push ( Ident {
289
+ module_path. push ( ( Ident {
290
290
name : keywords:: CrateRoot . name ( ) ,
291
- span : source. span ,
292
- } ) ;
293
- source. name = crate_name;
291
+ span : source. 0 . span ,
292
+ } , Some ( self . session . next_node_id ( ) ) ) ) ;
293
+ source. 0 . name = crate_name;
294
294
}
295
295
if rename. is_none ( ) {
296
296
ident. name = crate_name;
@@ -311,7 +311,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
311
311
312
312
let subclass = SingleImport {
313
313
target : ident,
314
- source,
314
+ source : source . 0 ,
315
315
result : PerNS {
316
316
type_ns : Cell :: new ( Err ( Undetermined ) ) ,
317
317
value_ns : Cell :: new ( Err ( Undetermined ) ) ,
@@ -349,13 +349,6 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
349
349
) ;
350
350
}
351
351
ast:: UseTreeKind :: Nested ( ref items) => {
352
- let prefix = ast:: Path {
353
- segments : module_path. into_iter ( )
354
- . map ( |ident| ast:: PathSegment :: from_ident ( ident) )
355
- . collect ( ) ,
356
- span : path. span ,
357
- } ;
358
-
359
352
// Ensure there is at most one `self` in the list
360
353
let self_spans = items. iter ( ) . filter_map ( |& ( ref use_tree, _) | {
361
354
if let ast:: UseTreeKind :: Simple ( ..) = use_tree. kind {
@@ -379,6 +372,17 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
379
372
}
380
373
381
374
for & ( ref tree, id) in items {
375
+ let prefix = ast:: Path {
376
+ segments : module_path. iter ( )
377
+ . map ( |ident| {
378
+ let mut seg = ast:: PathSegment :: from_ident ( ident. 0 ) ;
379
+ seg. id = self . session . next_node_id ( ) ;
380
+ seg
381
+ } )
382
+ . collect ( ) ,
383
+ span : path. span ,
384
+ } ;
385
+
382
386
self . build_reduced_graph_for_use_tree (
383
387
root_use_tree,
384
388
root_id,
0 commit comments