Skip to content

asm! lints should be based on cfg rather than target #127938

Open

Description

@tgross35

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

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jul 18, 2024
  2. tgross35 commented on Jul 18, 2024

    @tgross35
    MemberAuthor

    @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.

  3. tgross35 commented on Jul 18, 2024

    @tgross35
    MemberAuthor

    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.

  4. added
    C-enhancementCategory: An issue proposing an enhancement or a PR with one.
    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.
    A-inline-assemblyArea: Inline assembly (`asm!(…)`)
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jul 18, 2024
  5. tgross35 commented on Jul 18, 2024

    @tgross35
    MemberAuthor

    More info in #127935 (comment)

  6. changed the title [-]`asm!` lints based on `cfg` rather than target[/-] [+]`asm!` lints should be based on `cfg` rather than target[/+] on Sep 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-inline-assemblyArea: Inline assembly (`asm!(…)`)A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions