Skip to content

never_loop false positive with inline assembly label blocks #15673

@TDplai

Description

@TDplai

Summary

When there is an assembly block with labels in a loop, the never_loop lint will issue an error if any of those labels unconditionally break or return.

Lint Name

never_loop

Reproducer

I tried this code:

use std::arch::asm;
pub fn repro() {
    loop {
        unsafe {
            asm! {
                "/* {} */",
                label {
                    break;
                }
            }
        }
    }
}

I saw this happen:

error: this loop never actually loops
  --> src/lib.rs:3:5
   |
 3 | /     loop {
 4 | |         unsafe {
 5 | |             asm! {
 6 | |                 "/* {} */",
...  |
12 | |     }
   | |_____^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#never_loop
   = note: `#[deny(clippy::never_loop)]` on by default

I expected to see this happen:

No error, as the assembly block could (and indeed does) return.

Version

rustc 1.91.0-nightly (4ba1cf9ad 2025-09-12)
binary: rustc
commit-hash: 4ba1cf9ade4c8e2fa10676a50ee34594eb161837
commit-date: 2025-09-12
host: x86_64-unknown-linux-gnu
release: 1.91.0-nightly
LLVM version: 21.1.1

Additional Labels

No response

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions