-
Notifications
You must be signed in to change notification settings - Fork 8
How much should rustc understand the template string? #6
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
Comments
My personal opinion is that this is likely the time time Rust will ever be able to ban assembly syntax or enforce rules to make it more interpretable, so we should take advantage of it (provided these things aren't too unreasonable to implement on the compiler side). Unbanning things later would always be an option, but I doubt many people would be too upset if things like "leading zero means octal literal" or "# maybe starts a comment except when it doesn't" were no longer around. |
I favor minimal preprocessing. I think it's easier for users to understand a rule that "outside the format string is Rust syntax, inside the format string is native-assembler syntax", rather than creating some hybrid of the two syntaxes. Admittedly, register replacements force us to have some Rust syntax inside the format string. But I'd rather keep that as essentially a variant of |
Rust should not attempt to interpret the string at all; the assembler has far more depth than we want to teach Rust on every architecture. |
Clarification question: Do you mean other than the in reg and out reg values being formatted into place? |
I don't think this follows. Just because the assembler has a ton of depth doesn't mean that rustc can't try to interpret the string at all. The current RFC says that the syntax used is GNU assembler syntax which means that lines starting with a period are assembler directives and should have the same meaning regardless of the architecture. Thus, it shouldn't for instance be an issue for the compiler to figure out which directives are used in an inline assembly statement |
There are a range of options here, some of which have already been ruled out based on feasibility / functionality. Some of these might be possible to add after a MVP, but it is worth considering whether doing so would be a breaking change or if small actions now could ensure they aren't:
No understanding, not even of escape characters + register replacements{}
is allowed inside quoted strings and will directly concatenate register names with adjacent characters.Assembly instructions for each architecture are validated against a whitelist, maybe also validating operandsInline asm as syntax: the template string is really a DSL compiled by rustc directly to llvm IR / machine code.The text was updated successfully, but these errors were encountered: