unconditional_recursion
lint false positive on abort-on-drop type.
#138897
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
L-unconditional_recursion
Lint: unconditional_recursion
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Code
Current output
Desired output
No output; compiles as intended.
Rationale and extra context
The lint is semantically incorrect, in that the recursion occurs at most once (after that, the entire program is aborted due to double-panic). The help message is also not useful, because replacing the
panic!()
with aloop {}
changes the program from aborting when droppingDropBomb
, to hanging indefinitely.This is a common construction in
no_std
for anAbortOnDrop
type, usually to stop a program from unwinding out of a piece of unsafe code and leaving broken invariants.Other cases
Rust Version
Anything else?
Playground Link: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=8dbe0e6fb92d8f66787d7c3f14c386a5
The text was updated successfully, but these errors were encountered: