Skip to contentSkip to conversation

rust: small cleanups to Cargo.toml files

PATCH In review Paolo Bonzini 2 participants 6 messages Jan 29, 2025 – Feb 6, 2025 Rust

lore
Share & tools
lore
#0 lore raw

cover rust: small cleanups to Cargo.toml files

Remove duplicate or stale information, and add the rustc version to help clippy produce good warnings.

Paolo

Paolo Bonzini (2):
rust: remove unnecessary Cargo.toml metadata
rust: include rust_version in Cargo.toml

 rust/hw/char/pl011/Cargo.toml          |  4 +---
 rust/hw/char/pl011/README.md           | 31 --------------------------
 rust/hw/char/pl011/src/device_class.rs |  1 -
 rust/hw/char/pl011/src/lib.rs          | 14 +++++-------
 rust/qemu-api-macros/Cargo.toml        |  4 +---
 rust/qemu-api-macros/README.md         |  1 -
 rust/qemu-api/Cargo.toml               |  1 +
 7 files changed, 9 insertions(+), 47 deletions(-)
 delete mode 100644 rust/hw/char/pl011/README.md
 delete mode 100644 rust/qemu-api-macros/README.md
Signature · 1 line
2.48.1
#1 lore raw

PATCH 1/2 rust: remove unnecessary Cargo.toml metadata

Some items of Cargo.toml (readme, homepage, repository) are only present because of clippy::cargo warnings being enabled in rust/hw/char/pl011/src/lib.rs. But these items are not particularly useful and would be all the same for all Cargo.toml files in the QEMU workspace. Clean them up.

---
 rust/hw/char/pl011/Cargo.toml   |  3 ---
 rust/hw/char/pl011/README.md    | 31 -------------------------------
 rust/hw/char/pl011/src/lib.rs   | 14 ++++++--------
 rust/qemu-api-macros/Cargo.toml |  3 ---
 rust/qemu-api-macros/README.md  |  1 -
 5 files changed, 6 insertions(+), 46 deletions(-)
 delete mode 100644 rust/hw/char/pl011/README.md
 delete mode 100644 rust/qemu-api-macros/README.md
rust/hw/char/pl011/Cargo.toml +0 -3
index 58f3e859f7e..2b4097864df 100644
@@ -4,10 +4,7 @@ version = "0.1.0"
 edition = "2021"
 authors = ["Manos Pitsidianakis <[email protected]>"]
 license = "GPL-2.0-or-later"
-readme = "README.md"
-homepage = "https://www.qemu.org"
 description = "pl011 device model for QEMU"
-repository = "https://gitlab.com/epilys/rust-for-qemu"
 resolver = "2"
 publish = false
 keywords = []
rust/hw/char/pl011/README.md deleted +0 -31
deleted file mode 100644
index cd7dea31634..00000000000
@@ -1,31 +0,0 @@
-# PL011 QEMU Device Model
-
-This library implements a device model for the PrimeCell® UART (PL011)
-device in QEMU.
-
-## Build static lib
-
-Host build target must be explicitly specified:
-
-```sh
-cargo build --target x86_64-unknown-linux-gnu
-```
-
-Replace host target triplet if necessary.
-
-## Generate Rust documentation
-
-To generate docs for this crate, including private items:
-
-```sh
-cargo doc --no-deps --document-private-items --target x86_64-unknown-linux-gnu
-```
-
-To include direct dependencies like `bilge` (bitmaps for register types):
-
-```sh
-cargo tree --depth 1 -e normal --prefix none \
- | cut -d' ' -f1 \
- | xargs printf -- '-p %s\n' \
- | xargs cargo doc --no-deps --document-private-items --target x86_64-unknown-linux-gnu
-```
rust/hw/char/pl011/src/lib.rs +6 -8
index e2df4586bcc..e704daf6e3e 100644
@@ -1,13 +1,12 @@
 // Copyright 2024, Linaro Limited
 // Author(s): Manos Pitsidianakis <[email protected]>
 // SPDX-License-Identifier: GPL-2.0-or-later
-//
-// PL011 QEMU Device Model
-//
-// This library implements a device model for the PrimeCell® UART (PL011)
-// device in QEMU.
-//
-#![doc = include_str!("../README.md")]
+
+//! PL011 QEMU Device Model
+//!
+//! This library implements a device model for the PrimeCell® UART (PL011)
+//! device in QEMU.
+//!
 //! # Library crate
 //!
 //! See [`PL011State`](crate::device::PL011State) for the device model type and
@@ -18,7 +17,6 @@
     clippy::suspicious,
     clippy::complexity,
     clippy::perf,
-    clippy::cargo,
     clippy::nursery,
     clippy::style
 )]
rust/qemu-api-macros/Cargo.toml +0 -3
index 5a27b52ee6e..b9b4baecddb 100644
@@ -4,10 +4,7 @@ version = "0.1.0"
 edition = "2021"
 authors = ["Manos Pitsidianakis <[email protected]>"]
 license = "GPL-2.0-or-later"
-readme = "README.md"
-homepage = "https://www.qemu.org"
 description = "Rust bindings for QEMU - Utility macros"
-repository = "https://gitlab.com/qemu-project/qemu/"
 resolver = "2"
 publish = false
 keywords = []
rust/qemu-api-macros/README.md deleted +0 -1
deleted file mode 100644
index f60f54ac4be..00000000000
@@ -1 +0,0 @@
-# `qemu-api-macros` - Utility macros for defining QEMU devices
Signature · 1 line
2.48.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] rust: remove unnecessary Cargo.toml metadata

Quoted 12 lines · Paolo Bonzini

Date: Wed, 29 Jan 2025 09:37:03 +0100
From: Paolo Bonzini <[email protected]>
Subject: [PATCH 1/2] rust: remove unnecessary Cargo.toml metadata
X-Mailer: git-send-email 2.48.1

Some items of Cargo.toml (readme, homepage, repository) are only present because of clippy::cargo warnings being enabled in rust/hw/char/pl011/src/lib.rs. But these items are not particularly useful and would be all the same for all Cargo.toml files in the QEMU workspace. Clean them up.

Quoted 10 lines
---
 rust/hw/char/pl011/Cargo.toml   |  3 ---
 rust/hw/char/pl011/README.md    | 31 -------------------------------
 rust/hw/char/pl011/src/lib.rs   | 14 ++++++--------
 rust/qemu-api-macros/Cargo.toml |  3 ---
 rust/qemu-api-macros/README.md  |  1 -
 5 files changed, 6 insertions(+), 46 deletions(-)
 delete mode 100644 rust/hw/char/pl011/README.md
 delete mode 100644 rust/qemu-api-macros/README.md
#3 lore raw

PATCH 2/2 rust: include rust_version in Cargo.toml

In reply to Paolo Bonzini

Tell clippy the minimum supported Rust version for QEMU.

---
 rust/hw/char/pl011/Cargo.toml          | 1 +
 rust/hw/char/pl011/src/device_class.rs | 1 -
 rust/qemu-api-macros/Cargo.toml        | 1 +
 rust/qemu-api/Cargo.toml               | 1 +
 4 files changed, 3 insertions(+), 1 deletion(-)
rust/hw/char/pl011/Cargo.toml +1 -0
index 2b4097864df..f2296cad58b 100644
@@ -9,6 +9,7 @@ resolver = "2"
 publish = false
 keywords = []
 categories = []
+rust-version = "1.63.0"
 
 [lib]
 crate-type = ["staticlib"]
rust/hw/char/pl011/src/device_class.rs +0 -1
index 8a157a663fb..dbef93f6cb3 100644
@@ -12,7 +12,6 @@
 
 use crate::device::{PL011Registers, PL011State};
 
-#[allow(clippy::missing_const_for_fn)]
 extern "C" fn pl011_clock_needed(opaque: *mut c_void) -> bool {
     let state = NonNull::new(opaque).unwrap().cast::<PL011State>();
     unsafe { state.as_ref().migrate_clock }
rust/qemu-api-macros/Cargo.toml +1 -0
index b9b4baecddb..89dee1cfb39 100644
@@ -9,6 +9,7 @@ resolver = "2"
 publish = false
 keywords = []
 categories = []
+rust-version = "1.63.0"
 
 [lib]
 proc-macro = true
rust/qemu-api/Cargo.toml +1 -0
index 4aa22f31986..a51dd142852 100644
@@ -12,6 +12,7 @@ resolver = "2"
 publish = false
 keywords = []
 categories = []
+rust-version = "1.63.0"
 
 [dependencies]
 qemu_api_macros = { path = "../qemu-api-macros" }
Signature · 1 line
2.48.1
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] rust: include rust_version in Cargo.toml

rust/hw/char/pl011/src/device_class.rs line 15

Quoted 9 lines
rust/hw/char/pl011/src/device_class.rs +0 -1
index 8a157a663fb..dbef93f6cb3 100644
@@ -12,7 +12,6 @@
 
 use crate::device::{PL011Registers, PL011State};
 
-#[allow(clippy::missing_const_for_fn)]

It seems like a rebase nit since the commit 7d0520398f7f ("rust: prefer NonNull::new to assertions"), which is not worth an extra commit either.

rust/hw/char/pl011/src/device_class.rs line 17

Quoted 3 lines
rust/hw/char/pl011/src/device_class.rs +0 -0
 extern "C" fn pl011_clock_needed(opaque: *mut c_void) -> bool {
     let state = NonNull::new(opaque).unwrap().cast::<PL011State>();
     unsafe { state.as_ref().migrate_clock }
#5 lore raw

Re: [PATCH 2/2] rust: include rust_version in Cargo.toml

Il gio 6 feb 2025, 11:42 Zhao Liu <[email protected]> ha scritto:

Quoted 7 lines

Review

Quoted 1 line
(quoted diff) +0 -0

b/rust/hw/char/pl011/src/device_class.rs

Quoted 5 lines

index 8a157a663fb..dbef93f6cb3 100644

rust/hw/char/pl011/src/device_class.rs +0 -0
@@ -12,7 +12,6 @@
 
Quoted 7 lines

rust/hw/char/pl011/src/device_class.rs line 15

Quoted 3 lines
rust/hw/char/pl011/src/device_class.rs +0 -1
 use crate::device::{PL011Registers, PL011State};
 
-#[allow(clippy::missing_const_for_fn)]

It seems like a rebase nit since the commit 7d0520398f7f ("rust: prefer NonNull::new to assertions"), which is not worth an extra commit either.

It's not; adding rust_version let's Clippy know that this function cannot be const in all supported versions of the standard library.

Paolo

Quoted 7 lines

extern "C" fn pl011_clock_needed(opaque: *mut c_void) -> bool {

rust/hw/char/pl011/src/device_class.rs line 17

Quoted 2 lines
rust/hw/char/pl011/src/device_class.rs +0 -0
     let state = NonNull::new(opaque).unwrap().cast::<PL011State>();
     unsafe { state.as_ref().migrate_clock }