@@ -220,32 +220,41 @@ fn get_metadata_section(str filename) -> option::t[vec[u8]] {
220
220
ret option:: none[ vec[ u8] ] ;
221
221
}
222
222
223
- fn load_library_crate( & session:: session sess, span span, ast :: crate_num cnum ,
223
+ fn load_library_crate( & session:: session sess, span span,
224
224
& ast:: ident ident, & ( @ast:: meta_item) [ ] metas,
225
- & vec[ str] library_search_paths) {
225
+ & vec[ str] library_search_paths)
226
+ -> tup( str, vec[ u8] ) {
227
+
226
228
alt ( find_library_crate( sess, ident, metas, library_search_paths) ) {
227
229
case ( some( ?t) ) {
228
- auto cstore = sess. get_cstore( ) ;
229
- auto cmeta = rec( name=ident,
230
- data=t. _1,
231
- cnum_map = new_int_hash[ ast:: crate_num] ( ) ) ;
232
- cstore:: set_crate_data( cstore, cnum, cmeta) ;
233
- cstore:: add_used_crate_file( cstore, t. _0) ;
234
- ret;
230
+ ret t;
231
+ }
232
+ case ( none) {
233
+ sess. span_fatal( span, #fmt( "can't find crate for '%s'" , ident) ) ;
235
234
}
236
- case ( _) { }
237
235
}
238
- sess. span_fatal( span, #fmt( "can't find crate for '%s'" , ident) ) ;
239
236
}
240
237
241
238
fn resolve_crate( env e, ast:: ident ident, ( @ast:: meta_item) [ ] metas,
242
239
span span) -> ast:: crate_num {
243
240
if ( !e. crate_cache. contains_key( ident) ) {
241
+ auto cinfo = load_library_crate( e. sess, span, ident, metas,
242
+ e. library_search_paths) ;
243
+
244
+ auto cfilename = cinfo. _0;
245
+ auto cdata = cinfo. _1;
246
+
247
+ auto cmeta = rec( name=ident,
248
+ data=cdata,
249
+ cnum_map = new_int_hash[ ast:: crate_num] ( ) ) ;
250
+
244
251
auto cnum = e. next_crate_num;
245
- load_library_crate( e. sess, span, cnum, ident,
246
- metas, e. library_search_paths) ;
247
- e. crate_cache. insert( ident, e. next_crate_num) ;
252
+ e. crate_cache. insert( ident, cnum) ;
248
253
e. next_crate_num += 1 ;
254
+
255
+ auto cstore = e. sess. get_cstore( ) ;
256
+ cstore:: set_crate_data( cstore, cnum, cmeta) ;
257
+ cstore:: add_used_crate_file( cstore, cfilename) ;
249
258
ret cnum;
250
259
} else {
251
260
ret e. crate_cache. get( ident) ;
0 commit comments