@@ -47,6 +47,17 @@ use syntax::crateid::CrateId;
4747
4848pub type Cmd = @crate_metadata ;
4949
50+ // FIXME: remove unwrap_ after a snapshot
51+ #[ cfg( stage0) ]
52+ fn unwrap_ < T > ( t : T ) -> T {
53+ t
54+ }
55+
56+ #[ cfg( not( stage0) ) ]
57+ fn unwrap_ < T , E > ( r : Result < T , E > ) -> T {
58+ r. unwrap ( )
59+ }
60+
5061// A function that takes a def_id relative to the crate being searched and
5162// returns a def_id relative to the compilation environment, i.e. if we hit a
5263// def_id for an item defined in another crate, somebody needs to figure out
@@ -59,15 +70,15 @@ fn lookup_hash<'a>(d: ebml::Doc<'a>, eq_fn: |&[u8]| -> bool,
5970 let table = reader:: get_doc ( index, tag_index_table) ;
6071 let hash_pos = table. start + ( hash % 256 * 4 ) as uint ;
6172 let pos = u64_from_be_bytes ( d. data , hash_pos, 4 ) as uint ;
62- let tagged_doc = reader:: doc_at ( d. data , pos) ;
73+ let tagged_doc = unwrap_ ( reader:: doc_at ( d. data , pos) ) ;
6374
6475 let belt = tag_index_buckets_bucket_elt;
6576
6677 let mut ret = None ;
6778 reader:: tagged_docs ( tagged_doc. doc , belt, |elt| {
6879 let pos = u64_from_be_bytes ( elt. data , elt. start , 4 ) as uint ;
6980 if eq_fn ( elt. data . slice ( elt. start + 4 , elt. end ) ) {
70- ret = Some ( reader:: doc_at ( d. data , pos) . doc ) ;
81+ ret = Some ( unwrap_ ( reader:: doc_at ( d. data , pos) ) . doc ) ;
7182 false
7283 } else {
7384 true
@@ -853,7 +864,7 @@ pub fn get_item_variances(cdata: Cmd, id: ast::NodeId) -> ty::ItemVariances {
853864 let item_doc = lookup_item ( id, data) ;
854865 let variance_doc = reader:: get_doc ( item_doc, tag_item_variances) ;
855866 let mut decoder = reader:: Decoder ( variance_doc) ;
856- Decodable :: decode ( & mut decoder)
867+ unwrap_ ( Decodable :: decode ( & mut decoder) )
857868}
858869
859870pub fn get_provided_trait_methods ( intr : @IdentInterner , cdata : Cmd ,
0 commit comments