]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
rust: use native Meson support for clippy and rustdoc
authorPaolo Bonzini <pbonzini@redhat.com>
Sat, 5 Apr 2025 12:18:17 +0000 (14:18 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 3 Jun 2025 20:42:18 +0000 (22:42 +0200)
Meson has support for invoking clippy and rustdoc on all crates (1.7.0 for
clippy, 1.8.0 for rustdoc).  Use it instead of the homegrown version; this
requires disabling the multiple_crate_versions lint (the only one that was
enabled from the "cargo" group)---which was not particularly useful anyway
because all dependencies are converted by hand into Meson subprojects.

rustfmt is still not supported.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
clippy.toml [moved from rust/clippy.toml with 55% similarity]
docs/devel/rust.rst
meson.build
rust/Cargo.toml
rust/meson.build
scripts/rust/rustc_args.py

similarity index 55%
rename from rust/clippy.toml
rename to clippy.toml
index 58a62c0e632e23137ae1477e1622289e8a60cbbf..9016172983839cc74c95d0a950bef19fbce1fe27 100644 (file)
@@ -1,3 +1,3 @@
-doc-valid-idents = ["PrimeCell", ".."]
+doc-valid-idents = ["IrDA", "PrimeCell", ".."]
 allow-mixed-uninlined-format-args = false
 msrv = "1.77.0"
index f66f2bef60be95e84efeed431c6dde4b09681a34..34d9c7945b7b144a7da8e14ebe6cb45b94581a89 100644 (file)
@@ -37,12 +37,16 @@ output directory (typically ``rust/target/``).  A vanilla invocation
 of Cargo will complain that it cannot find the generated sources,
 which can be fixed in different ways:
 
-* by using special shorthand targets in the QEMU build directory::
+* by using Makefile targets, provided by Meson, that run ``clippy`` or
+  ``rustdoc``:
 
     make clippy
-    make rustfmt
     make rustdoc
 
+A target for ``rustfmt`` is also declared in ``rust/meson.build``:
+
+    make rustfmt
+
 * by invoking ``cargo`` through the Meson `development environment`__
   feature::
 
@@ -50,7 +54,7 @@ which can be fixed in different ways:
     pyvenv/bin/meson devenv -w ../rust cargo fmt
 
   If you are going to use ``cargo`` repeatedly, ``pyvenv/bin/meson devenv``
-  will enter a shell where commands like ``cargo clippy`` just work.
+  will enter a shell where commands like ``cargo fmt`` just work.
 
 __ https://mesonbuild.com/Commands.html#devenv
 
index e85b358d637e51811f87f91382f08b0ee324a6fe..651bd4f7275e0550d99e719d5421d138ba78a87e 100644 (file)
@@ -4404,7 +4404,7 @@ foreach target : target_dirs
                               build_by_default: true,
                               build_always_stale: true)
       rlib = static_library('rust_' + target.underscorify(),
-                            rlib_rs,
+                            structured_sources([], {'.': rlib_rs}),
                             dependencies: target_rust.dependencies(),
                             override_options: ['rust_std=2021', 'build.rust_std=2021'],
                             rust_abi: 'c')
index d9faeecb10ba1db4051b2f3bef2c59860b4a85ac..a00b8ad0bcd933653ba2753e750873dcd1bb3a37 100644 (file)
@@ -63,7 +63,6 @@ ignored_unit_patterns = "deny"
 implicit_clone = "deny"
 macro_use_imports = "deny"
 missing_safety_doc = "deny"
-multiple_crate_versions = "deny"
 mut_mut = "deny"
 needless_bitwise_bool = "deny"
 needless_pass_by_ref_mut = "deny"
index 801f4374dfa0522a27f35d741a07ab917f076183..afce62f4772d0705692b9ddffdb5dd3461ed43b3 100644 (file)
@@ -24,21 +24,9 @@ subdir('hw')
 cargo = find_program('cargo', required: false)
 
 if cargo.found()
-  run_target('clippy',
-    command: [config_host['MESON'], 'devenv',
-              '--workdir', '@CURRENT_SOURCE_DIR@',
-              cargo, 'clippy', '--tests'],
-    depends: bindings_rs)
-
   run_target('rustfmt',
     command: [config_host['MESON'], 'devenv',
               '--workdir', '@CURRENT_SOURCE_DIR@',
               cargo, 'fmt'],
     depends: bindings_rs)
-
-  run_target('rustdoc',
-    command: [config_host['MESON'], 'devenv',
-              '--workdir', '@CURRENT_SOURCE_DIR@',
-              cargo, 'doc', '--no-deps', '--document-private-items'],
-    depends: bindings_rs)
 endif
index 2633157df2aa0b0a166d51c3d8483fa43b250441..63b0748e0d37892e47d51c67a24b58efd26a58a8 100644 (file)
@@ -104,10 +104,7 @@ def generate_lint_flags(cargo_toml: CargoTOML, strict_lints: bool) -> Iterable[s
             else:
                 raise Exception(f"invalid level {level} for {prefix}{lint}")
 
-            # This may change if QEMU ever invokes clippy-driver or rustdoc by
-            # hand.  For now, check the syntax but do not add non-rustc lints to
-            # the command line.
-            if k == "rust" and not (strict_lints and lint in STRICT_LINTS):
+            if not (strict_lints and lint in STRICT_LINTS):
                 lint_list.append(LintFlag(flags=[flag, prefix + lint], priority=priority))
 
     if strict_lints: