File tree Expand file tree Collapse file tree 2 files changed +4
-15
lines changed Expand file tree Collapse file tree 2 files changed +4
-15
lines changed Original file line number Diff line number Diff line change 1212
1313pub use self :: astencode_tag:: * ;
1414
15- use std:: mem;
1615use back:: svh:: Svh ;
1716
1817// EBML enum definitions and utils shared by the encoder and decoder
@@ -113,7 +112,7 @@ pub const tag_items_data_item_reexport_def_id: uint = 0x39;
113112pub const tag_items_data_item_reexport_name: uint = 0x3a ;
114113
115114// used to encode crate_ctxt side tables
116- #[ derive( Copy , PartialEq ) ]
115+ #[ derive( Copy , PartialEq , FromPrimitive ) ]
117116#[ repr( uint) ]
118117pub enum astencode_tag { // Reserves 0x40 -- 0x5f
119118 tag_ast = 0x40 ,
@@ -146,17 +145,6 @@ pub enum astencode_tag { // Reserves 0x40 -- 0x5f
146145 tag_table_object_cast_map = 0x58 ,
147146}
148147
149- static first_astencode_tag: uint = tag_ast as uint ;
150- static last_astencode_tag: uint = tag_table_object_cast_map as uint ;
151- impl astencode_tag {
152- pub fn from_uint ( value : uint ) -> Option < astencode_tag > {
153- let is_a_tag = first_astencode_tag <= value && value <= last_astencode_tag;
154- if !is_a_tag { None } else {
155- Some ( unsafe { mem:: transmute :: < uint , astencode_tag > ( value) } )
156- }
157- }
158- }
159-
160148pub const tag_item_trait_item_sort: uint = 0x60 ;
161149
162150pub const tag_item_trait_parent_sort: uint = 0x61 ;
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ use syntax::ptr::P;
3838use syntax;
3939
4040use std:: old_io:: Seek ;
41+ use std:: num:: FromPrimitive ;
4142use std:: rc:: Rc ;
4243
4344use rbml:: io:: SeekableMemWriter ;
@@ -1836,8 +1837,8 @@ fn decode_side_tables(dcx: &DecodeContext,
18361837 debug ! ( ">> Side table document with tag 0x{:x} \
18371838 found for id {} (orig {})",
18381839 tag, id, id0) ;
1839-
1840- match c :: astencode_tag :: from_uint ( tag ) {
1840+ let decoded_tag : Option < c :: astencode_tag > = FromPrimitive :: from_uint ( tag ) ;
1841+ match decoded_tag {
18411842 None => {
18421843 dcx. tcx . sess . bug (
18431844 & format ! ( "unknown tag found in side tables: {:x}" ,
You can’t perform that action at this time.
0 commit comments