Skip to content

Commit 2654c30

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 f1fa7d3 commit 2654c30

File tree

2 files changed

+94
-106
lines changed

2 files changed

+94
-106
lines changed

c2rust-transpile/src/translator/mod.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2202,11 +2202,8 @@ impl<'c> Translation<'c> {
22022202
.kind
22032203
.get_type()
22042204
.ok_or_else(|| format_err!("Invalid expression type"))?;
2205-
let (expr_id, ty) = self
2206-
.ast_context
2207-
.resolve_expr_type_id(id)
2208-
.unwrap_or((id, ty));
2209-
let expr = self.convert_expr(ctx, expr_id, None)?;
2205+
let ty = self.ast_context[id].kind.get_type().unwrap_or(ty);
2206+
let expr = self.convert_expr(ctx, id, None)?;
22102207

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

0 commit comments

Comments
 (0)