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

asm! lints based on cfg rather than target #127938

Open
tgross35 opened this issue Jul 18, 2024 · 3 comments
Open

asm! lints based on cfg rather than target #127938

tgross35 opened this issue Jul 18, 2024 · 3 comments
Labels
A-inline-assembly Area: Inline assembly (`asm!(…)`) A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@tgross35
Copy link
Contributor

tgross35 commented Jul 18, 2024

For example:

#[cfg(target_arch = "x86")]
fn foo() {
    unsafe { asm!("0: jmp 0b") };
}

This currently raises binary_asm_labels only if targeting x86. Ideally we would be able to raise the lint regardless of what the current target is.

Requested in #127821 and #127935

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 18, 2024
@tgross35
Copy link
Contributor Author

tgross35 commented Jul 18, 2024

@estebank I'm a bit light on the details here, and not sure I understand it fully. Do we do anything like this at the current time? It would be great if we could validate assembly for all targets (actual correctness, not just lints), but block-level cfg seems to make that difficult.

@tgross35
Copy link
Contributor Author

Oh, did you mean if cfg!(...) rather than attribute config? That seems potentially easier, but I have no clue what level of support these things have.

@tgross35 tgross35 added C-enhancement Category: An issue proposing an enhancement or a PR with one. A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. A-inline-assembly Area: Inline assembly (`asm!(…)`) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jul 18, 2024
@tgross35
Copy link
Contributor Author

More info in #127935 (comment)

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!(…)`) A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants