Skip to content

Commit a5bf63e

Browse files
committed
transpile: Remove override_ty param from convert_const_macro_expansion
1 parent b50f942 commit a5bf63e

3 files changed

Lines changed: 5 additions & 11 deletions

File tree

c2rust-transpile/src/translator/enums.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff 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.

c2rust-transpile/src/translator/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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(

c2rust-transpile/src/translator/pointers.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff 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;

0 commit comments

Comments
 (0)