Skip to content

Commit 8c209ca

Browse files
committed
transpile: Remove override_ty param from convert_const_macro_expansion
1 parent 314cfc3 commit 8c209ca

4 files changed

Lines changed: 6 additions & 11 deletions

File tree

c2rust-transpile/src/translator/enums.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl<'c> Translation<'c> {
100100
if self.is_variant_of_enum(enum_id, enum_constant_id) =>
101101
{
102102
// `enum`s shouldn't need portable `override_ty`s.
103-
let expr_is_macro = self.expr_is_expanded_macro(ctx, expr, None);
103+
let expr_is_macro = self.expr_is_expanded_macro(ctx, expr);
104104

105105
// If this DeclRef expanded to a const macro, we actually need to insert a cast,
106106
// because the translation of a const macro skips implicit casts in its context.

c2rust-transpile/src/translator/macros.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ impl<'c> Translation<'c> {
148148
&self,
149149
ctx: ExprContext,
150150
expr_id: CExprId,
151-
override_ty: Option<CQualTypeId>,
152151
) -> TranslationResult<Option<WithStmts<Box<Expr>>>> {
153152
let macros = match self.ast_context.macro_invocations.get(&expr_id) {
154153
Some(macros) => macros.as_slice(),
@@ -201,6 +200,7 @@ impl<'c> Translation<'c> {
201200
// determined by the surrounding context.
202201
// Since the expansion sites are expecting a particular type, we need to cast it here
203202
// if it differs from the `const` type.
203+
let override_ty = self.expr_override_types.get(&expr_id).copied();
204204
let expr_ty = override_ty.or_else(|| self.ast_context[expr_id].kind.get_qual_type());
205205
if let Some(expr_ty) = expr_ty {
206206
self.convert_cast(
@@ -249,14 +249,9 @@ impl<'c> Translation<'c> {
249249
))))
250250
}
251251

252-
pub fn expr_is_expanded_macro(
253-
&self,
254-
ctx: ExprContext,
255-
expr_id: CExprId,
256-
override_ty: Option<CQualTypeId>,
257-
) -> bool {
252+
pub fn expr_is_expanded_macro(&self, ctx: ExprContext, expr_id: CExprId) -> bool {
258253
matches!(
259-
self.convert_const_macro_expansion(ctx, expr_id, override_ty),
254+
self.convert_const_macro_expansion(ctx, expr_id),
260255
Ok(Some(_))
261256
)
262257
}

c2rust-transpile/src/translator/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3686,7 +3686,7 @@ impl<'c> Translation<'c> {
36863686

36873687
let override_ty = self.expr_override_types.get(&expr_id).copied();
36883688

3689-
if let Some(converted) = self.convert_const_macro_expansion(ctx, expr_id, override_ty)? {
3689+
if let Some(converted) = self.convert_const_macro_expansion(ctx, expr_id)? {
36903690
return Ok(converted);
36913691
}
36923692

c2rust-transpile/src/translator/pointers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl<'c> Translation<'c> {
103103
.ast_context
104104
.get_pointee_qual_type(pointer_cty.ctype)
105105
.ok_or_else(|| TranslationError::generic("Address-of should return a pointer"))?;
106-
let arg_is_macro = arg.map_or(false, |arg| self.expr_is_expanded_macro(ctx, arg, None));
106+
let arg_is_macro = arg.map_or(false, |arg| self.expr_is_expanded_macro(ctx, arg));
107107

108108
let mut needs_cast = false;
109109
let mut ref_cast_pointee_ty = None;

0 commit comments

Comments
 (0)