@@ -366,25 +366,31 @@ pub struct ImportResolution {
366
366
/// The privacy of this `use` directive (whether it's `use` or
367
367
/// `pub use`.
368
368
privacy : Privacy ,
369
- id : node_id ,
370
369
371
370
// The number of outstanding references to this name. When this reaches
372
371
// zero, outside modules can count on the targets being correct. Before
373
372
// then, all bets are off; future imports could override this name.
374
-
375
373
outstanding_references : uint ,
376
374
377
375
/// The value that this `use` directive names, if there is one.
378
376
value_target : Option < Target > ,
377
+ /// The source node of the `use` directive leading to the value target
378
+ /// being non-none
379
+ value_id : node_id ,
380
+
379
381
/// The type that this `use` directive names, if there is one.
380
382
type_target : Option < Target > ,
383
+ /// The source node of the `use` directive leading to the type target
384
+ /// being non-none
385
+ type_id : node_id ,
381
386
}
382
387
383
388
pub fn ImportResolution ( privacy : Privacy ,
384
389
id : node_id ) -> ImportResolution {
385
390
ImportResolution {
386
391
privacy : privacy,
387
- id : id,
392
+ type_id : id,
393
+ value_id : id,
388
394
outstanding_references : 0 ,
389
395
value_target : None ,
390
396
type_target : None ,
@@ -399,6 +405,13 @@ impl ImportResolution {
399
405
ValueNS => return copy self . value_target
400
406
}
401
407
}
408
+
409
+ fn id ( & self , namespace : Namespace ) -> node_id {
410
+ match namespace {
411
+ TypeNS => self . type_id ,
412
+ ValueNS => self . value_id ,
413
+ }
414
+ }
402
415
}
403
416
404
417
/// The link from a module up to its nearest parent node.
@@ -1920,7 +1933,8 @@ impl Resolver {
1920
1933
1921
1934
// the source of this name is different now
1922
1935
resolution. privacy = privacy;
1923
- resolution. id = id;
1936
+ resolution. type_id = id;
1937
+ resolution. value_id = id;
1924
1938
}
1925
1939
None => {
1926
1940
debug!( "( building import directive) creating new") ;
@@ -2118,7 +2132,7 @@ impl Resolver {
2118
2132
containing_module,
2119
2133
target,
2120
2134
source,
2121
- import_directive. span ) ;
2135
+ import_directive) ;
2122
2136
}
2123
2137
GlobImport => {
2124
2138
let privacy = import_directive. privacy ;
@@ -2181,7 +2195,7 @@ impl Resolver {
2181
2195
containing_module : @mut Module ,
2182
2196
target : ident ,
2183
2197
source : ident ,
2184
- span : span )
2198
+ directive : & ImportDirective )
2185
2199
-> ResolveResult < ( ) > {
2186
2200
debug ! ( "(resolving single import) resolving `%s` = `%s::%s` from \
2187
2201
`%s`",
@@ -2270,9 +2284,10 @@ impl Resolver {
2270
2284
return UnboundResult ;
2271
2285
}
2272
2286
Some ( target) => {
2273
- this. used_imports . insert ( import_resolution. id ) ;
2287
+ let id = import_resolution. id ( namespace) ;
2288
+ this. used_imports . insert ( id) ;
2274
2289
return BoundResult ( target. target_module ,
2275
- target. bindings ) ;
2290
+ target. bindings ) ;
2276
2291
}
2277
2292
}
2278
2293
}
@@ -2323,8 +2338,10 @@ impl Resolver {
2323
2338
2324
2339
match value_result {
2325
2340
BoundResult ( target_module, name_bindings) => {
2341
+ debug ! ( "(resolving single import) found value target" ) ;
2326
2342
import_resolution. value_target =
2327
2343
Some ( Target ( target_module, name_bindings) ) ;
2344
+ import_resolution. value_id = directive. id ;
2328
2345
}
2329
2346
UnboundResult => { /* Continue. */ }
2330
2347
UnknownResult => {
@@ -2333,8 +2350,10 @@ impl Resolver {
2333
2350
}
2334
2351
match type_result {
2335
2352
BoundResult ( target_module, name_bindings) => {
2353
+ debug ! ( "(resolving single import) found type target" ) ;
2336
2354
import_resolution. type_target =
2337
2355
Some ( Target ( target_module, name_bindings) ) ;
2356
+ import_resolution. type_id = directive. id ;
2338
2357
}
2339
2358
UnboundResult => { /* Continue. */ }
2340
2359
UnknownResult => {
@@ -2383,6 +2402,7 @@ impl Resolver {
2383
2402
}
2384
2403
}
2385
2404
2405
+ let span = directive. span ;
2386
2406
if resolve_fail {
2387
2407
self . session . span_err ( span, fmt ! ( "unresolved import: there is no `%s` in `%s`" ,
2388
2408
* self . session. str_of( source) ,
@@ -2774,7 +2794,7 @@ impl Resolver {
2774
2794
Some ( target) => {
2775
2795
debug ! ( "(resolving item in lexical scope) using \
2776
2796
import resolution") ;
2777
- self . used_imports . insert ( import_resolution. id ) ;
2797
+ self . used_imports . insert ( import_resolution. id ( namespace ) ) ;
2778
2798
return Success ( copy target) ;
2779
2799
}
2780
2800
}
@@ -3043,7 +3063,7 @@ impl Resolver {
3043
3063
import_resolution. privacy == Public => {
3044
3064
debug ! ( "(resolving name in module) resolved to \
3045
3065
import") ;
3046
- self . used_imports . insert ( import_resolution. id ) ;
3066
+ self . used_imports . insert ( import_resolution. id ( namespace ) ) ;
3047
3067
return Success ( copy target) ;
3048
3068
}
3049
3069
Some ( _) => {
@@ -4525,7 +4545,8 @@ impl Resolver {
4525
4545
namespace) ) {
4526
4546
( Some ( def) , Some ( Public ) ) => {
4527
4547
// Found it.
4528
- self . used_imports. insert( import_resolution. id) ;
4548
+ let id = import_resolution. id( namespace) ;
4549
+ self . used_imports. insert( id) ;
4529
4550
return ImportNameDefinition ( def) ;
4530
4551
}
4531
4552
( Some ( _) , _) | ( None , _) => {
@@ -5140,7 +5161,7 @@ impl Resolver {
5140
5161
& mut found_traits,
5141
5162
trait_def_id, name) ;
5142
5163
self . used_imports. insert(
5143
- import_resolution. id ) ;
5164
+ import_resolution. type_id ) ;
5144
5165
}
5145
5166
}
5146
5167
_ => {
0 commit comments