@@ -19,6 +19,7 @@ export get_crate_attributes;
19
19
export list_crate_metadata;
20
20
export crate_dep;
21
21
export get_crate_deps;
22
+ export get_crate_hash;
22
23
export external_resolver;
23
24
24
25
// A function that takes a def_id relative to the crate being searched and
@@ -347,8 +348,8 @@ fn list_meta_items(meta_items: ebml::doc, out: io::writer) {
347
348
}
348
349
}
349
350
350
- fn list_crate_attributes ( md : ebml:: doc , out : io:: writer ) {
351
- out. write_str ( "=Crate Attributes=\n " ) ;
351
+ fn list_crate_attributes ( md : ebml:: doc , hash : str , out : io:: writer ) {
352
+ out. write_str ( # fmt ( "=Crate Attributes (%s) =\n " , hash ) ) ;
352
353
353
354
for attr: ast:: attribute in get_attributes ( md) {
354
355
out. write_str ( #fmt[ "%s\n " , pprust:: attribute_to_str ( attr) ] ) ;
@@ -386,6 +387,12 @@ fn list_crate_deps(data: @[u8], out: io::writer) {
386
387
out. write_str ( "\n " ) ;
387
388
}
388
389
390
+ fn get_crate_hash ( data : @[ u8 ] ) -> str {
391
+ let cratedoc = ebml:: new_doc ( data) ;
392
+ let hashdoc = ebml:: get_doc ( cratedoc, tag_crate_hash) ;
393
+ ret str:: unsafe_from_bytes ( ebml:: doc_data ( hashdoc) ) ;
394
+ }
395
+
389
396
fn list_crate_items ( bytes : @[ u8 ] , md : ebml:: doc , out : io:: writer ) {
390
397
out. write_str ( "=Items=\n " ) ;
391
398
let paths = ebml:: get_doc ( md, tag_paths) ;
@@ -407,8 +414,9 @@ fn list_crate_items(bytes: @[u8], md: ebml::doc, out: io::writer) {
407
414
}
408
415
409
416
fn list_crate_metadata ( bytes : @[ u8 ] , out : io:: writer ) {
417
+ let hash = get_crate_hash ( bytes) ;
410
418
let md = ebml:: new_doc ( bytes) ;
411
- list_crate_attributes ( md, out) ;
419
+ list_crate_attributes ( md, hash , out) ;
412
420
list_crate_deps ( bytes, out) ;
413
421
list_crate_items ( bytes, md, out) ;
414
422
}
0 commit comments