rust: restrict missing_const_for_fn to qemu_api crate
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 7 Feb 2025 14:38:40 +0000 (15:38 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 10 Feb 2025 10:18:32 +0000 (11:18 +0100)
missing_const_for_fn is not necessarily useful or good.  For example in
a private API you can always add const later, and in a public API
it can be unnecessarily restrictive to annotate everything with const
(blocking further improvements to the API).

Nevertheless, QEMU turns it on because qemu_api uses const quite
aggressively and therefore it can be handy to have as much as possible
annotated with const.  Outside qemu_api though, not so much: devices
are self contained consumers and if there is nothing that could use
their functions in const contexts that were not anticipated.

Since missing_const_for_fn can be a bit noisy and trigger on trivial
functions that no one would ever call in const context, do not
turn it on everywhere and only keep it in qemu_api as a special case.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
rust/Cargo.toml
rust/qemu-api/src/lib.rs

index 5b6b6ca438251670d37101cdd6fd3c9109b25c09..5b0cb55928677f50f5feb6848ef496c861fe9fbd 100644 (file)
@@ -52,7 +52,6 @@ empty_structs_with_brackets = "deny"
 ignored_unit_patterns = "deny"
 implicit_clone = "deny"
 macro_use_imports = "deny"
-missing_const_for_fn = "deny"
 missing_safety_doc = "deny"
 multiple_crate_versions = "deny"
 mut_mut = "deny"
index 83c6a987c059ad82a6c0bd5efce140aeca31c683..3cf9371cff05999ae862e8c232a71a15b0c8c2d3 100644 (file)
@@ -3,6 +3,7 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 
 #![cfg_attr(not(MESON), doc = include_str!("../README.md"))]
+#![deny(clippy::missing_const_for_fn)]
 
 #[rustfmt::skip]
 pub mod bindings;