rust: small cleanups to Cargo.toml files
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
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -1 +0,0 @@ -# `qemu-api-macros` - Utility macros for defining QEMU devices
Signature · 1 line
2.48.1
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.1Some items of Cargo.toml (readme, homepage, repository) are only present because of
clippy::cargowarnings being enabled inrust/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.Signed-off-by Paolo Bonzini <[email protected]>
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
PATCH 2/2 rust: include rust_version in Cargo.toml
In reply to Paolo BonziniTell 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
@@ -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
@@ -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
@@ -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
@@ -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
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@@ -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
-0extern "C" fn pl011_clock_needed (opaque: *mut c_void ) ->bool {let state =NonNull ::new (opaque).unwrap ().cast ::<PL011State >();unsafe { state.as_ref ().migrate_clock }
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.rsQuoted 5 lines
index
8a157a663fb..dbef93f6cb3100644rust/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
-1use crate ::device::{PL011Registers ,PL011State }; -#[allow(clippy::missing_const_for_fn)] It seems like a rebase nit since the commit
7d0520398f7f("rust: preferNonNull::newto 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
-0let state =NonNull ::new (opaque).unwrap ().cast ::<PL011State >();unsafe { state.as_ref ().migrate_clock }Reviewed-by Zhao Liu <[email protected]>