Skip to content

Commit 50d1380

Browse files
authoredFeb 24, 2025··
correctly construct _ as Ident rather than Punctuation (#1202)
This fixes another bug like #1197: `_` is no puctuation -- another case of dtolnay/proc-macro2#475, fall-out of dtolnay/proc-macro2#470. ## Testing This enables building RIOT sources again without `--locked`. I'm not entirely sure, but I think the offending assembly was ```c __ASM ("rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); ``` which gets turned into ```rust asm!( "rev {0}, {1}", lateout(reg) result, inlateout(reg) value => _, options(preserves_flags, pure, readonly) ); ``` where the `_` is the identifier (formerly punctuation) which c2rust trips over.
2 parents 3b1ec86 + 8665b8c commit 50d1380

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed
 

‎c2rust-transpile/src/translator/assembly.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,7 @@ impl<'c> Translation<'c> {
913913
// Emit input and/or output expressions, separated by "=>" if both
914914
push_expr(&mut tokens, mk().paren_expr(constraints_ident));
915915
if let Some(in_expr) = in_expr {
916+
let in_expr_span = in_expr.span();
916917
push_expr(&mut tokens, in_expr);
917918
if out_expr.is_some() {
918919
tokens.push(TokenTree::Punct(Punct::new('=', Joint)));
@@ -923,7 +924,7 @@ impl<'c> Translation<'c> {
923924
tokens.push(TokenTree::Punct(Punct::new('=', Joint)));
924925
tokens.push(TokenTree::Punct(Punct::new('>', Alone)));
925926

926-
tokens.push(TokenTree::Punct(Punct::new('_', Alone)));
927+
tokens.push(TokenTree::Ident(Ident::new("_", in_expr_span)));
927928
}
928929
}
929930
}

0 commit comments

Comments
 (0)
Please sign in to comment.