Skip to content

Commit 0bb986a

Browse files
committed
transpile: handle TagGenericExpr node for generics
1 parent 4548624 commit 0bb986a

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

c2rust-transpile/src/c_ast/conversion.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,6 +2001,19 @@ impl ConversionContext {
20012001
self.expr_possibly_as_stmt(expected_ty, new_id, node, e)
20022002
}
20032003

2004+
ASTEntryTag::TagGenericExpr if expected_ty & (EXPR | STMT) != 0 => {
2005+
let wrapped = node.children[0].expect("Expected generic expression");
2006+
let ty_old = node.type_id.expect("Expected expression to have type");
2007+
let ty = self.visit_qualified_type(ty_old);
2008+
2009+
// Use the existing `Paren` kind instead of adding a new one
2010+
// that would just be a no-op wrapper around the inner
2011+
// expression
2012+
let expr = CExprKind::Paren(ty, self.visit_expr(wrapped));
2013+
2014+
self.expr_possibly_as_stmt(expected_ty, new_id, node, expr);
2015+
}
2016+
20042017
// Declarations
20052018
ASTEntryTag::TagFunctionDecl if expected_ty & OTHER_DECL != 0 => {
20062019
let name = from_value::<String>(node.extras[0].clone())

0 commit comments

Comments
 (0)