@@ -88,6 +88,7 @@ type def_map = hashmap[uint,def];
88
88
89
89
type env = rec ( crate_map crate_map,
90
90
def_map def_map,
91
+ hashmap[ def_id, @ast:: item] ast_map ,
91
92
hashmap[ ast:: def_num, import_state] imports ,
92
93
hashmap[ ast:: def_num, @indexed_mod] mod_map ,
93
94
hashmap[ def_id, vec[ ident] ] ext_map ,
@@ -107,6 +108,7 @@ tag namespace {
107
108
fn resolve_crate ( session sess, @ast:: crate crate) -> def_map {
108
109
auto e = @rec ( crate_map = new_uint_hash[ ast:: crate_num] ( ) ,
109
110
def_map = new_uint_hash[ def] ( ) ,
111
+ ast_map = new_def_hash[ @ast:: item] ( ) ,
110
112
imports = new_int_hash[ import_state] ( ) ,
111
113
mod_map = new_int_hash[ @indexed_mod] ( ) ,
112
114
ext_map = new_def_hash[ vec[ ident] ] ( ) ,
@@ -157,14 +159,31 @@ fn map_crate(&@env e, &ast::crate c) {
157
159
e. mod_map . insert ( defid. _1 ,
158
160
@rec ( m=some ( md) , index=index_mod ( md) ,
159
161
glob_imports=vec:: empty[ def] ( ) ) ) ;
162
+ e. ast_map . insert ( defid, i) ;
160
163
}
161
164
case ( ast:: item_native_mod ( _, ?nmd, ?defid) ) {
162
165
e. mod_map . insert ( defid. _1 ,
163
166
@rec ( m=none[ ast:: _mod] ,
164
167
index=index_nmod ( nmd) ,
165
168
glob_imports=vec:: empty[ def] ( ) ) ) ;
169
+ e. ast_map . insert ( defid, i) ;
170
+ }
171
+ case ( ast:: item_const ( _, _, _, ?defid, _) ) {
172
+ e. ast_map . insert ( defid, i) ;
173
+ }
174
+ case ( ast:: item_fn ( _, _, _, ?defid, _) ) {
175
+ e. ast_map . insert ( defid, i) ;
176
+ }
177
+ case ( ast:: item_ty ( _, _, _, ?defid, _) ) {
178
+ e. ast_map . insert ( defid, i) ;
179
+ }
180
+ case ( ast:: item_tag ( _, _, _, ?defid, _) ) {
181
+ e. ast_map . insert ( defid, i) ;
182
+ }
183
+ case ( ast:: item_obj ( _, _, _, ?obj_def_ids, _) ) {
184
+ e. ast_map . insert ( obj_def_ids. ty , i) ;
185
+ e. ast_map . insert ( obj_def_ids. ctor , i) ;
166
186
}
167
- case ( _) { }
168
187
}
169
188
}
170
189
@@ -899,6 +918,10 @@ fn lookup_glob_in_mod(&env e, @indexed_mod info, list[def] m, &span sp,
899
918
} else if ( vec:: len ( matches) == 1 u) {
900
919
ret some[ def] ( matches. ( 0 ) ) ;
901
920
} else {
921
+ for ( def match in matches) {
922
+ e. sess . span_note ( e. ast_map . get ( ast:: def_id_of_def ( match ) ) . span ,
923
+ "'" + id + "' is defined here." ) ;
924
+ }
902
925
e. sess . span_err ( sp, "'" + id + "' is glob-imported from" +
903
926
" multiple different modules." ) ;
904
927
fail;
0 commit comments