Skip to content

Commit 9818912

Browse files
fw-immunantkkysen
authored andcommitted
transpile: const macros: do not resolve expr type
resolving the type ignores all casts, but some casts are nontrivial computations that we cannot elide, e.g. truncating larger types to smaller ones as far as I'm aware we can simply not resolve the expression type here; we'll emit more casts in these cases, but some of those may be load-bearing
1 parent 0437a18 commit 9818912

File tree

1 file changed

+2
-5
lines changed
  • c2rust-transpile/src/translator

1 file changed

+2
-5
lines changed

c2rust-transpile/src/translator/mod.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2174,11 +2174,8 @@ impl<'c> Translation<'c> {
21742174
.kind
21752175
.get_type()
21762176
.ok_or_else(|| format_err!("Invalid expression type"))?;
2177-
let (expr_id, ty) = self
2178-
.ast_context
2179-
.resolve_expr_type_id(id)
2180-
.unwrap_or((id, ty));
2181-
let expr = self.convert_expr(ctx, expr_id, None)?;
2177+
let ty = self.ast_context[id].kind.get_type().unwrap_or(ty);
2178+
let expr = self.convert_expr(ctx, id, None)?;
21822179

21832180
// Join ty and cur_ty to the smaller of the two types. If the
21842181
// types are not cast-compatible, abort the fold.

0 commit comments

Comments
 (0)