@@ -111,16 +111,23 @@ pub(crate) fn handle_enum<R: ReaderType>(
111111 while let Ok ( Some ( child) ) = children. next ( ) {
112112 if child. entry ( ) . tag ( ) == constants:: DW_TAG_enumerator {
113113 let name = debug_info_builder_context. get_name ( dwarf, unit, child. entry ( ) ) ?;
114- let attr = & child
115- . entry ( )
116- . attr ( constants:: DW_AT_const_value )
117- . unwrap ( )
118- . unwrap ( ) ;
119- if let Some ( value) = get_attr_as_u64 ( attr) {
120- enumeration_builder. insert ( name, value) ;
121- } else {
122- log:: error!( "Unhandled enum member value type - please report this" ) ;
123- return None ;
114+ match & child. entry ( ) . attr ( constants:: DW_AT_const_value ) {
115+ Ok ( Some ( attr) ) => {
116+ if let Some ( value) = get_attr_as_u64 ( attr) {
117+ enumeration_builder. insert ( name, value) ;
118+ } else {
119+ // Somehow the child entry is not a const value.
120+ log:: error!( "Unhandled enum member value type for `{}`" , name) ;
121+ }
122+ }
123+ Ok ( None ) => {
124+ // Somehow the child entry does not have a const value.
125+ log:: error!( "Enum member `{}` has no constant value attribute" , name) ;
126+ }
127+ Err ( e) => {
128+ log:: error!( "Error parsing next attribute entry for `{}`: {}" , name, e) ;
129+ return None ;
130+ }
124131 }
125132 }
126133 }
@@ -133,7 +140,7 @@ pub(crate) fn handle_enum<R: ReaderType>(
133140 Some ( Type :: enumeration (
134141 & enumeration_builder. finalize ( ) ,
135142 // TODO: This looks bad, look at the comment in [`Type::width`].
136- width. try_into ( ) . unwrap ( ) ,
143+ width. try_into ( ) . expect ( "Enum cannot be zero width" ) ,
137144 false ,
138145 ) )
139146}
0 commit comments