aboutsummaryrefslogtreecommitdiff
path: root/rust
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2024-11-06 13:03:45 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2024-12-10 18:44:06 +0100
commit90868c3dcec755f567426d1fad64e7611053778e (patch)
treec8f86f150afbd9338a8b7ad348ae88291da28347 /rust
parent97ed1e9c8e2b0744508ef61cac8a23bb1e107820 (diff)
downloadqemu-90868c3dcec755f567426d1fad64e7611053778e.zip
qemu-90868c3dcec755f567426d1fad64e7611053778e.tar.gz
qemu-90868c3dcec755f567426d1fad64e7611053778e.tar.bz2
rust: cargo: store desired warning levels in workspace Cargo.toml
An extra benefit of workspaces is that they allow to place lint level settings in a single Cargo.toml; the settings are then inherited by packages in the workspace. Correspondingly, teach rustc_args.py to get the unexpected_cfgs configuration from the workspace Cargo.toml. Note that it is still possible to allow or deny warnings per crate or module, via the #![] attribute syntax. The rust/qemu-api/src/bindings.rs file is an example. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'rust')
-rw-r--r--rust/Cargo.toml8
-rw-r--r--rust/hw/char/pl011/Cargo.toml3
-rw-r--r--rust/qemu-api-macros/Cargo.toml3
-rw-r--r--rust/qemu-api/Cargo.toml5
-rw-r--r--rust/qemu-api/meson.build2
5 files changed, 17 insertions, 4 deletions
diff --git a/rust/Cargo.toml b/rust/Cargo.toml
index 0c94d50..4bb52bf 100644
--- a/rust/Cargo.toml
+++ b/rust/Cargo.toml
@@ -5,3 +5,11 @@ members = [
"qemu-api",
"hw/char/pl011",
]
+
+[workspace.lints.rust]
+unexpected_cfgs = { level = "deny", check-cfg = [
+ 'cfg(MESON)', 'cfg(HAVE_GLIB_WITH_ALIGNED_ALLOC)',
+ 'cfg(has_offset_of)'] }
+
+# Prohibit code that is forbidden in Rust 2024
+unsafe_op_in_unsafe_fn = "deny"
diff --git a/rust/hw/char/pl011/Cargo.toml b/rust/hw/char/pl011/Cargo.toml
index a373906..58f3e85 100644
--- a/rust/hw/char/pl011/Cargo.toml
+++ b/rust/hw/char/pl011/Cargo.toml
@@ -21,3 +21,6 @@ bilge = { version = "0.2.0" }
bilge-impl = { version = "0.2.0" }
qemu_api = { path = "../../../qemu-api" }
qemu_api_macros = { path = "../../../qemu-api-macros" }
+
+[lints]
+workspace = true
diff --git a/rust/qemu-api-macros/Cargo.toml b/rust/qemu-api-macros/Cargo.toml
index a8f7377..5a27b52 100644
--- a/rust/qemu-api-macros/Cargo.toml
+++ b/rust/qemu-api-macros/Cargo.toml
@@ -20,3 +20,6 @@ proc-macro = true
proc-macro2 = "1"
quote = "1"
syn = { version = "2", features = ["extra-traits"] }
+
+[lints]
+workspace = true
diff --git a/rust/qemu-api/Cargo.toml b/rust/qemu-api/Cargo.toml
index cc716d7..669f288 100644
--- a/rust/qemu-api/Cargo.toml
+++ b/rust/qemu-api/Cargo.toml
@@ -23,6 +23,5 @@ version_check = "~0.9"
default = []
allocator = []
-[lints.rust]
-unexpected_cfgs = { level = "warn", check-cfg = ['cfg(MESON)', 'cfg(HAVE_GLIB_WITH_ALIGNED_ALLOC)',
- 'cfg(has_offset_of)'] }
+[lints]
+workspace = true
diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build
index 1ed7967..d719c13 100644
--- a/rust/qemu-api/meson.build
+++ b/rust/qemu-api/meson.build
@@ -1,5 +1,5 @@
_qemu_api_cfg = run_command(rustc_args,
- '--config-headers', config_host_h, '--features', '--lints', files('Cargo.toml'),
+ '--config-headers', config_host_h, '--features', files('Cargo.toml'),
capture: true, check: true).stdout().strip().splitlines()
# _qemu_api_cfg += ['--cfg', 'feature="allocator"']