Skip to content

Commit 1815f3e

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 98dcfaf commit 1815f3e

File tree

2 files changed

+97
-108
lines changed

2 files changed

+97
-108
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)