-
Notifications
You must be signed in to change notification settings - Fork 2k
Lint: enable empty_loop for no_std crates #6161
Copy link
Copy link
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingC-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesS-needs-discussionStatus: Needs further discussion before merging or work can be startedStatus: Needs further discussion before merging or work can be started
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingC-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesS-needs-discussionStatus: Needs further discussion before merging or work can be startedStatus: Needs further discussion before merging or work can be started
Type
Fields
Give feedbackNo fields configured for issues without a type.
Right now, we have a style lint against the following code:
Note that this is no longer undefined behavior (since rust-lang/rust#77972).
Currently, there is no way to have a
no_stdbinary or library use theempty_looplint.Even adding
#![deny(clippy::empty_loop)]to a crate does nothing. This is because #5086 (fixing #3746), made the lint essentially not exist forno_stdcrates.Furthermore, even in
no_stdcrates, using a "hot" deadloop is almost always not what you want (as it burns a bunch of CPU, and can cause crashes). Even on ano_stdtarget, a user should either:haltorpauseintrinsic.Note,
core::sync::atomic::spin_loop_hintis not a good recommendation here, aspauseisn't meant for dead-loops (it's designed for spin-locks). See rust-lang/rust#77924In my opinion, we should:
empty_looplint forno_stdcrates.no_stdspecific help message.#[panic_handler]sno_stdbinaries (while keeping it on forno_stdlibraries).#[panic_handler].Our documentation for fixing this (on
stdandno_std) is part of #6162CC (people involved with this change last time): @therealprof, @oli-obk, @eddyp, @Areredify, @phansch