@@ -553,16 +553,14 @@ pub fn get_type<'a, 'tcx>(cdata: Cmd, id: DefIndex, tcx: TyCtxt<'a, 'tcx, 'tcx>)
553
553
pub fn get_stability ( cdata : Cmd , id : DefIndex ) -> Option < attr:: Stability > {
554
554
let item = cdata. lookup_item ( id) ;
555
555
reader:: maybe_get_doc ( item, tag_items_data_item_stability) . map ( |doc| {
556
- let mut decoder = reader:: Decoder :: new ( doc) ;
557
- Decodable :: decode ( & mut decoder) . unwrap ( )
556
+ Decodable :: decode ( & mut doc. opaque ( ) ) . unwrap ( )
558
557
} )
559
558
}
560
559
561
560
pub fn get_deprecation ( cdata : Cmd , id : DefIndex ) -> Option < attr:: Deprecation > {
562
561
let item = cdata. lookup_item ( id) ;
563
562
reader:: maybe_get_doc ( item, tag_items_data_item_deprecation) . map ( |doc| {
564
- let mut decoder = reader:: Decoder :: new ( doc) ;
565
- Decodable :: decode ( & mut decoder) . unwrap ( )
563
+ Decodable :: decode ( & mut doc. opaque ( ) ) . unwrap ( )
566
564
} )
567
565
}
568
566
@@ -579,19 +577,12 @@ pub fn get_parent_impl(cdata: Cmd, id: DefIndex) -> Option<DefId> {
579
577
580
578
pub fn get_repr_attrs ( cdata : Cmd , id : DefIndex ) -> Vec < attr:: ReprAttr > {
581
579
let item = cdata. lookup_item ( id) ;
582
- match reader:: maybe_get_doc ( item, tag_items_data_item_repr) . map ( |doc| {
583
- let mut decoder = reader:: Decoder :: new ( doc) ;
584
- Decodable :: decode ( & mut decoder) . unwrap ( )
585
- } ) {
586
- Some ( attrs) => attrs,
587
- None => Vec :: new ( ) ,
588
- }
580
+ reader:: maybe_get_doc ( item, tag_items_data_item_repr) . map_or ( vec ! [ ] , |doc| {
581
+ Decodable :: decode ( & mut doc. opaque ( ) ) . unwrap ( )
582
+ } )
589
583
}
590
584
591
- pub fn get_impl_polarity < ' tcx > ( cdata : Cmd ,
592
- id : DefIndex )
593
- -> Option < hir:: ImplPolarity >
594
- {
585
+ pub fn get_impl_polarity ( cdata : Cmd , id : DefIndex ) -> Option < hir:: ImplPolarity > {
595
586
let item_doc = cdata. lookup_item ( id) ;
596
587
let fam = item_family ( item_doc) ;
597
588
match fam {
@@ -602,15 +593,14 @@ pub fn get_impl_polarity<'tcx>(cdata: Cmd,
602
593
}
603
594
}
604
595
605
- pub fn get_custom_coerce_unsized_kind < ' tcx > (
596
+ pub fn get_custom_coerce_unsized_kind (
606
597
cdata : Cmd ,
607
598
id : DefIndex )
608
599
-> Option < ty:: adjustment:: CustomCoerceUnsized >
609
600
{
610
601
let item_doc = cdata. lookup_item ( id) ;
611
602
reader:: maybe_get_doc ( item_doc, tag_impl_coerce_unsized_kind) . map ( |kind_doc| {
612
- let mut decoder = reader:: Decoder :: new ( kind_doc) ;
613
- Decodable :: decode ( & mut decoder) . unwrap ( )
603
+ Decodable :: decode ( & mut kind_doc. opaque ( ) ) . unwrap ( )
614
604
} )
615
605
}
616
606
@@ -989,8 +979,7 @@ pub fn get_trait_item_def_ids(cdata: Cmd, id: DefIndex)
989
979
pub fn get_item_variances ( cdata : Cmd , id : DefIndex ) -> Vec < ty:: Variance > {
990
980
let item_doc = cdata. lookup_item ( id) ;
991
981
let variance_doc = reader:: get_doc ( item_doc, tag_item_variances) ;
992
- let mut decoder = reader:: Decoder :: new ( variance_doc) ;
993
- Decodable :: decode ( & mut decoder) . unwrap ( )
982
+ Decodable :: decode ( & mut variance_doc. opaque ( ) ) . unwrap ( )
994
983
}
995
984
996
985
pub fn get_provided_trait_methods < ' a , ' tcx > ( cdata : Cmd ,
@@ -1109,10 +1098,7 @@ pub fn get_struct_field_names(cdata: Cmd, id: DefIndex) -> Vec<ast::Name> {
1109
1098
1110
1099
fn get_attributes ( md : rbml:: Doc ) -> Vec < ast:: Attribute > {
1111
1100
reader:: maybe_get_doc ( md, tag_attributes) . map_or ( vec ! [ ] , |attrs_doc| {
1112
- let mut decoder = reader:: Decoder :: new ( attrs_doc) ;
1113
- let mut attrs: Vec < ast:: Attribute > = decoder. read_opaque ( |opaque_decoder, _| {
1114
- Decodable :: decode ( opaque_decoder)
1115
- } ) . unwrap ( ) ;
1101
+ let mut attrs = Vec :: < ast:: Attribute > :: decode ( & mut attrs_doc. opaque ( ) ) . unwrap ( ) ;
1116
1102
1117
1103
// Need new unique IDs: old thread-local IDs won't map to new threads.
1118
1104
for attr in attrs. iter_mut ( ) {
@@ -1575,18 +1561,14 @@ pub fn get_imported_filemaps(metadata: &[u8]) -> Vec<syntax_pos::FileMap> {
1575
1561
let cm_doc = reader:: get_doc ( crate_doc, tag_codemap) ;
1576
1562
1577
1563
reader:: tagged_docs ( cm_doc, tag_codemap_filemap) . map ( |filemap_doc| {
1578
- let mut decoder = reader:: Decoder :: new ( filemap_doc) ;
1579
- decoder. read_opaque ( |opaque_decoder, _| {
1580
- Decodable :: decode ( opaque_decoder)
1581
- } ) . unwrap ( )
1564
+ Decodable :: decode ( & mut filemap_doc. opaque ( ) ) . unwrap ( )
1582
1565
} ) . collect ( )
1583
1566
}
1584
1567
1585
1568
pub fn closure_kind ( cdata : Cmd , closure_id : DefIndex ) -> ty:: ClosureKind {
1586
1569
let closure_doc = cdata. lookup_item ( closure_id) ;
1587
1570
let closure_kind_doc = reader:: get_doc ( closure_doc, tag_items_closure_kind) ;
1588
- let mut decoder = reader:: Decoder :: new ( closure_kind_doc) ;
1589
- ty:: ClosureKind :: decode ( & mut decoder) . unwrap ( )
1571
+ ty:: ClosureKind :: decode ( & mut closure_kind_doc. opaque ( ) ) . unwrap ( )
1590
1572
}
1591
1573
1592
1574
pub fn closure_ty < ' a , ' tcx > ( cdata : Cmd , closure_id : DefIndex , tcx : TyCtxt < ' a , ' tcx , ' tcx > )
@@ -1606,8 +1588,7 @@ pub fn def_key(cdata: Cmd, id: DefIndex) -> hir_map::DefKey {
1606
1588
fn item_def_key ( item_doc : rbml:: Doc ) -> hir_map:: DefKey {
1607
1589
match reader:: maybe_get_doc ( item_doc, tag_def_key) {
1608
1590
Some ( def_key_doc) => {
1609
- let mut decoder = reader:: Decoder :: new ( def_key_doc) ;
1610
- let simple_key = def_key:: DefKey :: decode ( & mut decoder) . unwrap ( ) ;
1591
+ let simple_key = def_key:: DefKey :: decode ( & mut def_key_doc. opaque ( ) ) . unwrap ( ) ;
1611
1592
let name = reader:: maybe_get_doc ( item_doc, tag_paths_data_name) . map ( |name| {
1612
1593
token:: intern ( name. as_str ( ) ) . as_str ( )
1613
1594
} ) ;
0 commit comments