File tree Expand file tree Collapse file tree
c2rust-transpile/src/translator Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -234,7 +234,7 @@ impl<'c> Translation<'c> {
234234 variants. contains ( & enum_constant_id)
235235 }
236236
237- fn enum_integral_type ( & self , enum_id : CEnumId ) -> CQualTypeId {
237+ pub fn enum_integral_type ( & self , enum_id : CEnumId ) -> CQualTypeId {
238238 match self . ast_context [ enum_id] . kind {
239239 CDeclKind :: Enum {
240240 integral_type : Some ( integral_type) ,
Original file line number Diff line number Diff line change @@ -723,26 +723,35 @@ impl<'c> Translation<'c> {
723723 _ => mk ( ) . lit_expr ( mk ( ) . int_unsuffixed_lit ( 1 ) ) ,
724724 } ;
725725
726- let one_type_id =
727- if let CTypeKind :: Pointer ( ..) = self . ast_context . resolve_type ( arg_type. ctype ) . kind {
728- CQualTypeId :: new (
726+ let mut rhs_type_id = arg_type;
727+ let mut compute_lhs_type_id = arg_type;
728+ let mut compute_res_type_id = ty;
729+
730+ match self . ast_context . resolve_type ( arg_type. ctype ) . kind {
731+ CTypeKind :: Pointer ( ..) => {
732+ rhs_type_id = CQualTypeId :: new (
729733 self . ast_context
730734 . type_for_kind ( & CTypeKind :: Int )
731735 . ok_or_else ( || format_err ! ( "couldn't find type for CTypeKind::Int" ) ) ?,
732- )
733- } else {
734- arg_type
735- } ;
736+ ) ;
737+ }
738+ CTypeKind :: Enum ( enum_id) => {
739+ rhs_type_id = self . enum_integral_type ( enum_id) ;
740+ compute_lhs_type_id = rhs_type_id;
741+ compute_res_type_id = rhs_type_id;
742+ }
743+ _ => { }
744+ } ;
736745
737746 self . convert_assignment_operator_with_rhs (
738747 ctx. used ( ) ,
739748 op,
740749 ty,
741750 arg,
742- one_type_id ,
751+ rhs_type_id ,
743752 WithStmts :: new_val ( one) ,
744- Some ( arg_type ) ,
745- Some ( ty ) ,
753+ Some ( compute_lhs_type_id ) ,
754+ Some ( compute_res_type_id ) ,
746755 )
747756 }
748757
You can’t perform that action at this time.
0 commit comments