Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audit string literals in inline assembly syntax for correct unescaping #95625

Open
petrochenkov opened this issue Apr 3, 2022 · 1 comment
Open
Labels
A-inline-assembly Area: Inline assembly (`asm!(…)`)

Comments

@petrochenkov
Copy link
Contributor

When trying to refresh the status of #60495 I noticed that ast::InlineAsm (and its nested structures) is the only AST structure that uses plain strings String and Symbols.

Other literals in AST use either ast::Lit in contexts where arbitrary literals are supported, of ast::StrLit in contexts where only string literals (possibly raw) are supported.

This is suspicious and may mean that string literals used in inline assembly are not always unescaped as any other Rust string literals.
"Unescaped as any other Rust string literals" means that e.g. "\x72ax" is always treated as semantically equivalent to "rax".

Implementation of inline assembly needs to be audited to make sure that the unescaping happens in all contexts, and some parts of ast::InlineAsm may need to use StrLit instead of plain strings or symbols.

@petrochenkov petrochenkov added the A-inline-assembly Area: Inline assembly (`asm!(…)`) label Apr 3, 2022
@petrochenkov
Copy link
Contributor Author

If StrLit is used in AST for inline assembly, then fn print_string/print_symbol in compiler\rustc_ast_pretty\src\pprust\state.rs should also be eliminated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-inline-assembly Area: Inline assembly (`asm!(…)`)
Projects
None yet
Development

No branches or pull requests

1 participant