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 @@ -97,11 +97,8 @@ impl<'c> Translation<'c> {
9797 CExprKind :: DeclRef ( _, enum_constant_id, _)
9898 if self . is_variant_of_enum ( enum_id, enum_constant_id) =>
9999 {
100- // `enum`s shouldn't need portable `override_ty`s.
101- let expr_is_macro = matches ! (
102- self . convert_const_macro_expansion( ctx, expr, None ) ,
103- Ok ( Some ( _) )
104- ) ;
100+ let expr_is_macro =
101+ matches ! ( self . convert_const_macro_expansion( ctx, expr) , Ok ( Some ( _) ) ) ;
105102
106103 // If this DeclRef expanded to a const macro, we actually need to insert a cast,
107104 // because the translation of a const macro skips implicit casts in its context.
Original file line number Diff line number Diff line change @@ -3800,7 +3800,7 @@ impl<'c> Translation<'c> {
38003800
38013801 let override_ty = self . expr_override_types . get ( & expr_id) . copied ( ) ;
38023802
3803- if let Some ( converted) = self . convert_const_macro_expansion ( ctx, expr_id, override_ty ) ? {
3803+ if let Some ( converted) = self . convert_const_macro_expansion ( ctx, expr_id) ? {
38043804 return Ok ( converted) ;
38053805 }
38063806
@@ -4476,7 +4476,6 @@ impl<'c> Translation<'c> {
44764476 & self ,
44774477 ctx : ExprContext ,
44784478 expr_id : CExprId ,
4479- override_ty : Option < CQualTypeId > ,
44804479 ) -> TranslationResult < Option < WithStmts < Box < Expr > > > > {
44814480 let macros = match self . ast_context . macro_invocations . get ( & expr_id) {
44824481 Some ( macros) => macros. as_slice ( ) ,
@@ -4529,6 +4528,7 @@ impl<'c> Translation<'c> {
45294528 // determined by the surrounding context.
45304529 // Since the expansion sites are expecting a particular type, we need to cast it here
45314530 // if it differs from the `const` type.
4531+ let override_ty = self . expr_override_types . get ( & expr_id) . copied ( ) ;
45324532 let expr_ty = override_ty. or_else ( || self . ast_context [ expr_id] . kind . get_qual_type ( ) ) ;
45334533 if let Some ( expr_ty) = expr_ty {
45344534 self . convert_cast (
Original file line number Diff line number Diff line change @@ -102,10 +102,7 @@ impl<'c> Translation<'c> {
102102 . get_pointee_qual_type ( pointer_cty. ctype )
103103 . ok_or_else ( || TranslationError :: generic ( "Address-of should return a pointer" ) ) ?;
104104 let arg_is_macro = arg. map_or ( false , |arg| {
105- matches ! (
106- self . convert_const_macro_expansion( ctx, arg, None ) ,
107- Ok ( Some ( _) )
108- )
105+ matches ! ( self . convert_const_macro_expansion( ctx, arg) , Ok ( Some ( _) ) )
109106 } ) ;
110107
111108 let mut needs_cast = false ;
You can’t perform that action at this time.
0 commit comments