-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add lint for inline assembly syntax style preference #6092
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @matthiaskrgr (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
26150a9
to
dace477
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution and welcome to Clippy!
Currently Clippy is reluctant to accept new pre-expansion lints, as it's not clear if support for them will be removed at some point in rustc. Moreover, with a pre-expansion lint we would not be able to catch cases like the following:
#![feature(asm)]
macro_rules! nested {
() => {
asm!("");
}
}
fn main() {
unsafe {
nested!();
}
}
Luckily, we don't need a pre-expansion pass. We can move the lints to an early pass, check for expressions whose kind is ExprKind::InlineAsm
, and then check the syntax with
if inline_asm.options.contains(InlineAsmOptions::ATT_SYNTAX) {
// ...
}
r? @ebroto |
dace477
to
040c320
Compare
Neat! That would've saved me a bunch of work 😃 Only downside is |
040c320
to
0690f9c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM modulo the change I've added. If the tests pass I will merge it.
Thanks!
Use a single `only` header command in asm_syntax test
@bors r+ |
📌 Commit 507561e has been approved by |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
changelog: Add lint for inline assembly syntax style preference