@@ -58,17 +58,10 @@ type scopes = list[scope];
58
58
59
59
tag import_state {
60
60
todo( @ast : : view_item, scopes) ; // only used for explicit imports
61
-
62
61
resolving( span) ;
63
- resolved ( option:: t[ def] ,
64
-
65
- /* value */
66
- option:: t[ def] ,
67
-
68
- /* type */
69
- option:: t[ def] ) ;
70
- /* module */
71
-
62
+ resolved ( option:: t[ def] , /* value */
63
+ option:: t[ def] , /* type */
64
+ option:: t[ def] ) ; /* module */
72
65
}
73
66
74
67
type ext_hash = hashmap [ tup ( def_id, str, namespace) , def] ;
@@ -94,8 +87,7 @@ tag mod_index_entry {
94
87
mie_view_item( @ast : : view_item) ;
95
88
mie_item ( @ast:: item) ;
96
89
mie_native_item ( @ast:: native_item) ;
97
- mie_tag_variant ( @ast:: item, /* tag item */ uint) ;
98
- /* variant index */
90
+ mie_tag_variant ( @ast:: item /* tag item */ , uint /* variant index */ ) ;
99
91
100
92
}
101
93
@@ -445,24 +437,29 @@ fn add_constr(&@env e, node_id id, &ty::constr_def c) {
445
437
446
438
447
439
// Import resolution
448
- fn resolve_import( & env e, & @ast:: view_item it, & scopes sc) {
440
+ fn resolve_import( & env e, & @ast:: view_item it, scopes sc) {
449
441
auto defid;
450
442
auto ids;
443
+ auto name;
451
444
alt ( it. node) {
452
- case ( ast:: view_item_import( _ , ?_ids, ?_id) ) {
445
+ case ( ast:: view_item_import( ?_name , ?_ids, ?_id) ) {
453
446
defid = local_def( _id) ;
454
447
ids = _ids;
448
+ name = _name;
455
449
}
456
450
}
457
451
e. imports. insert( defid. _1, resolving( it. span) ) ;
458
452
auto n_idents = ivec:: len( ids) ;
459
453
auto end_id = ids. ( n_idents - 1 u) ;
454
+ // Ignore the current scope if this import would shadow itself.
455
+ if ( str :: eq( name, ids. ( 0 ) ) ) {
456
+ sc = std:: list:: cdr( sc) ;
457
+ }
460
458
if ( n_idents == 1 u) {
461
- auto next_sc = std:: list:: cdr( sc) ;
462
459
register( e, defid, it. span, end_id,
463
- lookup_in_scope( e, next_sc , it. span, end_id, ns_value) ,
464
- lookup_in_scope( e, next_sc , it. span, end_id, ns_type) ,
465
- lookup_in_scope( e, next_sc , it. span, end_id, ns_module) ) ;
460
+ lookup_in_scope( e, sc , it. span, end_id, ns_value) ,
461
+ lookup_in_scope( e, sc , it. span, end_id, ns_type) ,
462
+ lookup_in_scope( e, sc , it. span, end_id, ns_module) ) ;
466
463
remove_if_unresolved( e. imports, defid. _1) ;
467
464
} else {
468
465
auto dcur = alt( lookup_in_scope( e, sc, it. span, ids. ( 0 ) , ns_module) ) {
0 commit comments