From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-rust@nongnu.org
Subject: [PATCH 7/9] rust: move strict lints handling to meson.build
Date: Thu, 27 Nov 2025 14:20:34 +0100 [thread overview]
Message-ID: <20251127132036.84384-8-pbonzini@redhat.com> (raw)
In-Reply-To: <20251127132036.84384-1-pbonzini@redhat.com>
Simplify rustc_args.py, and align its code with what Meson's own Cargo.toml
translator does in v1.10.
Bump unknown_lints to "forbid", so that it will certainly override Cargo.toml's
"allow" level.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
meson.build | 7 +++----
scripts/rust/rustc_args.py | 20 ++------------------
2 files changed, 5 insertions(+), 22 deletions(-)
diff --git a/meson.build b/meson.build
index 270181038bf..e6a11cefdb7 100644
--- a/meson.build
+++ b/meson.build
@@ -128,14 +128,13 @@ if have_rust
rustc_args = [find_program('scripts/rust/rustc_args.py'),
'--rustc-version', rustc.version(),
'--workspace', meson.project_source_root() / 'rust']
- if get_option('strict_rust_lints')
- rustc_args += ['--strict-lints']
- endif
-
rustfmt = find_program('rustfmt', required: false)
rustc_lint_args = run_command(rustc_args, '--lints',
capture: true, check: true).stdout().strip().splitlines()
+ if get_option('strict_rust_lints')
+ rustc_lint_args += ['-Dwarnings', '-Funknown_lints']
+ endif
# Apart from procedural macros, our Rust executables will often link
# with C code, so include all the libraries that C code needs. This
diff --git a/scripts/rust/rustc_args.py b/scripts/rust/rustc_args.py
index 63b0748e0d3..8fb77785350 100644
--- a/scripts/rust/rustc_args.py
+++ b/scripts/rust/rustc_args.py
@@ -35,8 +35,6 @@
except ImportError:
import tomli as tomllib
-STRICT_LINTS = {"unknown_lints", "warnings"}
-
class CargoTOML:
tomldata: Mapping[Any, Any]
@@ -82,7 +80,7 @@ class LintFlag:
priority: int
-def generate_lint_flags(cargo_toml: CargoTOML, strict_lints: bool) -> Iterable[str]:
+def generate_lint_flags(cargo_toml: CargoTOML) -> Iterable[str]:
"""Converts Cargo.toml lints to rustc -A/-D/-F/-W flags."""
toml_lints = cargo_toml.lints
@@ -104,13 +102,6 @@ def generate_lint_flags(cargo_toml: CargoTOML, strict_lints: bool) -> Iterable[s
else:
raise Exception(f"invalid level {level} for {prefix}{lint}")
- if not (strict_lints and lint in STRICT_LINTS):
- lint_list.append(LintFlag(flags=[flag, prefix + lint], priority=priority))
-
- if strict_lints:
- for lint in STRICT_LINTS:
- lint_list.append(LintFlag(flags=["-D", lint], priority=1000000))
-
lint_list.sort(key=lambda x: x.priority)
for lint in lint_list:
yield from lint.flags
@@ -187,13 +178,6 @@ def main() -> None:
required=False,
default="1.0.0",
)
- parser.add_argument(
- "--strict-lints",
- action="store_true",
- dest="strict_lints",
- help="apply stricter checks (for nightly Rust)",
- default=False,
- )
args = parser.parse_args()
if args.verbose:
logging.basicConfig(level=logging.DEBUG)
@@ -207,7 +191,7 @@ def main() -> None:
cargo_toml = CargoTOML(args.cargo_toml, None)
if args.lints:
- for tok in generate_lint_flags(cargo_toml, args.strict_lints):
+ for tok in generate_lint_flags(cargo_toml):
print(tok)
if rustc_version >= (1, 80):
--
2.51.1
next prev parent reply other threads:[~2025-11-27 13:22 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-27 13:20 [PATCH 0/9] rust: build system and other cleanups Paolo Bonzini
2025-11-27 13:20 ` [PATCH 1/9] rust: remove leftover bindings/ Paolo Bonzini
2025-12-03 9:11 ` Zhao Liu
2025-11-27 13:20 ` [PATCH 2/9] rust: remove unused --cfg arguments Paolo Bonzini
2025-12-03 10:25 ` Zhao Liu
2025-11-27 13:20 ` [PATCH 3/9] rust: remove unnecessary repetitive options Paolo Bonzini
2025-12-03 10:37 ` Zhao Liu
2025-11-27 13:20 ` [PATCH 4/9] rust/bql: make bindings public Paolo Bonzini
2025-12-03 10:58 ` Zhao Liu
2025-11-27 13:20 ` [PATCH 5/9] rust: do not copy the SysBusDevice Paolo Bonzini
2025-12-03 10:59 ` Zhao Liu
2025-11-27 13:20 ` [PATCH 6/9] rust: fix reference to MemoryRegion Paolo Bonzini
2025-12-03 11:00 ` Zhao Liu
2025-11-27 13:20 ` Paolo Bonzini [this message]
2025-12-03 15:29 ` [PATCH 7/9] rust: move strict lints handling to meson.build Zhao Liu
2025-11-27 13:20 ` [PATCH 8/9] rust: Do not link qemuutil into Rust rlibs Paolo Bonzini
2025-11-27 13:20 ` [PATCH 9/9] rust: only link the Rust part of the code into devices Paolo Bonzini
2025-12-03 9:32 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251127132036.84384-8-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-rust@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).