From 7d7bfb2034001d4cb15df2ddc56d2d350c8da30f Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Fri, 8 Apr 2022 15:11:04 +0000 Subject: [PATCH] build: migrate to Rust 2021 edition Rust 2021 edition has a few improvements over the 2018 edition. Migrate the project to 2021 edition by following recommended migration steps. Luckily, the code itself doesn't require fixing. Bump MSRV to 1.56 as it is required by the 2021 edition. Also fix the clap build dependency to make Cloud Hypervisor build again. Signed-off-by: Wei Liu --- .github/workflows/build.yaml | 2 +- .rustfmt.toml | 2 +- Cargo.toml | 6 +++--- acpi_tables/Cargo.toml | 2 +- api_client/Cargo.toml | 2 +- arch/Cargo.toml | 2 +- block_util/Cargo.toml | 2 +- devices/Cargo.toml | 2 +- event_monitor/Cargo.toml | 2 +- fuzz/Cargo.toml | 2 +- hypervisor/Cargo.toml | 2 +- net_gen/Cargo.toml | 2 +- net_util/Cargo.toml | 2 +- option_parser/Cargo.toml | 2 +- pci/Cargo.toml | 2 +- performance-metrics/Cargo.toml | 2 +- qcow/Cargo.toml | 2 +- rate_limiter/Cargo.toml | 2 +- test_infra/Cargo.toml | 2 +- vfio_user/Cargo.toml | 2 +- vhdx/Cargo.toml | 2 +- vhost_user_block/Cargo.toml | 2 +- vhost_user_net/Cargo.toml | 2 +- virtio-devices/Cargo.toml | 2 +- vm-allocator/Cargo.toml | 2 +- vm-device/Cargo.toml | 2 +- vm-migration/Cargo.toml | 2 +- vm-virtio/Cargo.toml | 2 +- vmm/Cargo.toml | 2 +- 29 files changed, 31 insertions(+), 31 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index a78575dde..ac7ad18f9 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -13,7 +13,7 @@ jobs: - stable - beta - nightly - - 1.54 + - 1.56 target: - x86_64-unknown-linux-gnu - x86_64-unknown-linux-musl diff --git a/.rustfmt.toml b/.rustfmt.toml index c51666e8f..36c419bb3 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -1 +1 @@ -edition = "2018" \ No newline at end of file +edition = "2021" \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 5b5655c17..4a09247f7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "cloud-hypervisor" version = "22.0.0" authors = ["The Cloud Hypervisor Authors"] -edition = "2018" +edition = "2021" default-run = "cloud-hypervisor" build = "build.rs" license = "LICENSE-APACHE & LICENSE-BSD-3-Clause" @@ -10,7 +10,7 @@ description = "Open source Virtual Machine Monitor (VMM) that runs on top of KVM homepage = "https://github.com/cloud-hypervisor/cloud-hypervisor" # Minimum buildable version: # Keep in sync with version in .github/workflows/build.yaml -rust-version = "1.54" +rust-version = "1.56" [profile.release] lto = true @@ -34,7 +34,7 @@ vmm-sys-util = "0.9.0" vm-memory = "0.7.0" [build-dependencies] -clap = { version = "3.1.8", features = ["wrap_help"] } +clap = { version = "3.1.8", features = ["cargo"] } # List of patched crates [patch.crates-io] diff --git a/acpi_tables/Cargo.toml b/acpi_tables/Cargo.toml index 17f9b9b90..930ed9ca3 100644 --- a/acpi_tables/Cargo.toml +++ b/acpi_tables/Cargo.toml @@ -2,7 +2,7 @@ name = "acpi_tables" version = "0.1.0" authors = ["The Cloud Hypervisor Authors"] -edition = "2018" +edition = "2021" [dependencies] vm-memory = "0.7.0" diff --git a/api_client/Cargo.toml b/api_client/Cargo.toml index e9a0105fd..a9656816f 100644 --- a/api_client/Cargo.toml +++ b/api_client/Cargo.toml @@ -2,7 +2,7 @@ name = "api_client" version = "0.1.0" authors = ["The Cloud Hypervisor Authors"] -edition = "2018" +edition = "2021" [dependencies] vmm-sys-util = "0.9.0" diff --git a/arch/Cargo.toml b/arch/Cargo.toml index 076ac6a44..232eacffb 100644 --- a/arch/Cargo.toml +++ b/arch/Cargo.toml @@ -2,7 +2,7 @@ name = "arch" version = "0.1.0" authors = ["The Chromium OS Authors"] -edition = "2018" +edition = "2021" [features] default = [] diff --git a/block_util/Cargo.toml b/block_util/Cargo.toml index c3fa9ce21..ccb338829 100644 --- a/block_util/Cargo.toml +++ b/block_util/Cargo.toml @@ -2,7 +2,7 @@ name = "block_util" version = "0.1.0" authors = ["The Cloud Hypervisor Authors"] -edition = "2018" +edition = "2021" [features] default = [] diff --git a/devices/Cargo.toml b/devices/Cargo.toml index a097e48c3..4a6b5a572 100644 --- a/devices/Cargo.toml +++ b/devices/Cargo.toml @@ -2,7 +2,7 @@ name = "devices" version = "0.1.0" authors = ["The Chromium OS Authors"] -edition = "2018" +edition = "2021" [dependencies] acpi_tables = { path = "../acpi_tables" } diff --git a/event_monitor/Cargo.toml b/event_monitor/Cargo.toml index 96e02502e..1fbf1052f 100644 --- a/event_monitor/Cargo.toml +++ b/event_monitor/Cargo.toml @@ -2,7 +2,7 @@ name = "event_monitor" version = "0.1.0" authors = ["The Cloud Hypervisor Authors"] -edition = "2018" +edition = "2021" [dependencies] libc = "0.2.122" diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index f516b68e1..e7b352a7b 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -3,7 +3,7 @@ name = "cloud-hypervisor-fuzz" version = "0.0.0" authors = ["Automatically generated"] publish = false -edition = "2018" +edition = "2021" [package.metadata] cargo-fuzz = true diff --git a/hypervisor/Cargo.toml b/hypervisor/Cargo.toml index ebbbf1fef..233d3d11d 100644 --- a/hypervisor/Cargo.toml +++ b/hypervisor/Cargo.toml @@ -2,7 +2,7 @@ name = "hypervisor" version = "0.1.0" authors = ["Microsoft Authors"] -edition = "2018" +edition = "2021" license = "Apache-2.0 OR BSD-3-Clause" [features] diff --git a/net_gen/Cargo.toml b/net_gen/Cargo.toml index 0fca6bdff..0a46a5f64 100644 --- a/net_gen/Cargo.toml +++ b/net_gen/Cargo.toml @@ -2,7 +2,7 @@ name = "net_gen" version = "0.1.0" authors = ["The Chromium OS Authors"] -edition = "2018" +edition = "2021" [dependencies] vmm-sys-util = "0.9.0" diff --git a/net_util/Cargo.toml b/net_util/Cargo.toml index 41aedfbe4..497ca2d91 100644 --- a/net_util/Cargo.toml +++ b/net_util/Cargo.toml @@ -2,7 +2,7 @@ name = "net_util" version = "0.1.0" authors = ["The Chromium OS Authors"] -edition = "2018" +edition = "2021" [dependencies] epoll = "4.3.1" diff --git a/option_parser/Cargo.toml b/option_parser/Cargo.toml index e771c2dd0..99a09648a 100644 --- a/option_parser/Cargo.toml +++ b/option_parser/Cargo.toml @@ -2,4 +2,4 @@ name = "option_parser" version = "0.1.0" authors = ["The Cloud Hypervisor Authors"] -edition = "2018" +edition = "2021" diff --git a/pci/Cargo.toml b/pci/Cargo.toml index f96ecd5b9..2baaf7045 100644 --- a/pci/Cargo.toml +++ b/pci/Cargo.toml @@ -2,7 +2,7 @@ name = "pci" version = "0.1.0" authors = ["Samuel Ortiz "] -edition = "2018" +edition = "2021" [features] default = [] diff --git a/performance-metrics/Cargo.toml b/performance-metrics/Cargo.toml index 0d9bb82fe..a9533dc70 100644 --- a/performance-metrics/Cargo.toml +++ b/performance-metrics/Cargo.toml @@ -2,7 +2,7 @@ name = "performance-metrics" version = "0.1.0" authors = ["The Cloud Hypervisor Authors"] -edition = "2018" +edition = "2021" build = "build.rs" [dependencies] diff --git a/qcow/Cargo.toml b/qcow/Cargo.toml index ea2c42deb..fd4c674d8 100644 --- a/qcow/Cargo.toml +++ b/qcow/Cargo.toml @@ -2,7 +2,7 @@ name = "qcow" version = "0.1.0" authors = ["The Chromium OS Authors"] -edition = "2018" +edition = "2021" license = "BSD-3-Clause" [lib] diff --git a/rate_limiter/Cargo.toml b/rate_limiter/Cargo.toml index 42629326b..a886476e5 100644 --- a/rate_limiter/Cargo.toml +++ b/rate_limiter/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rate_limiter" version = "0.1.0" -edition = "2018" +edition = "2021" [dependencies] libc = "0.2.122" diff --git a/test_infra/Cargo.toml b/test_infra/Cargo.toml index d5d4c85f9..cedb73a60 100644 --- a/test_infra/Cargo.toml +++ b/test_infra/Cargo.toml @@ -2,7 +2,7 @@ name = "test_infra" version = "0.1.0" authors = ["The Cloud Hypervisor Authors"] -edition = "2018" +edition = "2021" [dependencies] dirs = "4.0.0" diff --git a/vfio_user/Cargo.toml b/vfio_user/Cargo.toml index 76b3a6271..974d494c2 100644 --- a/vfio_user/Cargo.toml +++ b/vfio_user/Cargo.toml @@ -2,7 +2,7 @@ name = "vfio_user" version = "0.1.0" authors = ["The Cloud Hypervisor Authors"] -edition = "2018" +edition = "2021" [dependencies] anyhow = "1.0.56" diff --git a/vhdx/Cargo.toml b/vhdx/Cargo.toml index 4c0704140..797ab66c8 100644 --- a/vhdx/Cargo.toml +++ b/vhdx/Cargo.toml @@ -2,7 +2,7 @@ name = "vhdx" version = "0.1.0" authors = ["The Cloud Hypervisor Authors"] -edition = "2018" +edition = "2021" license = "Apache-2.0" [dependencies] diff --git a/vhost_user_block/Cargo.toml b/vhost_user_block/Cargo.toml index 30c1d304e..05b3e980f 100644 --- a/vhost_user_block/Cargo.toml +++ b/vhost_user_block/Cargo.toml @@ -2,7 +2,7 @@ name = "vhost_user_block" version = "0.1.0" authors = ["The Cloud Hypervisor Authors"] -edition = "2018" +edition = "2021" [dependencies] block_util = { path = "../block_util" } diff --git a/vhost_user_net/Cargo.toml b/vhost_user_net/Cargo.toml index d6d0f354f..6d9d9e3c9 100644 --- a/vhost_user_net/Cargo.toml +++ b/vhost_user_net/Cargo.toml @@ -2,7 +2,7 @@ name = "vhost_user_net" version = "0.1.0" authors = ["The Cloud Hypervisor Authors"] -edition = "2018" +edition = "2021" [dependencies] clap = { version = "3.1.8", features = ["wrap_help"] } diff --git a/virtio-devices/Cargo.toml b/virtio-devices/Cargo.toml index 9b737ecb6..f55dde7ec 100644 --- a/virtio-devices/Cargo.toml +++ b/virtio-devices/Cargo.toml @@ -2,7 +2,7 @@ name = "virtio-devices" version = "0.1.0" authors = ["The Cloud Hypervisor Authors"] -edition = "2018" +edition = "2021" [features] default = [] diff --git a/vm-allocator/Cargo.toml b/vm-allocator/Cargo.toml index b80d66b14..7398515f1 100644 --- a/vm-allocator/Cargo.toml +++ b/vm-allocator/Cargo.toml @@ -2,7 +2,7 @@ name = "vm-allocator" version = "0.1.0" authors = ["The Chromium OS Authors"] -edition = "2018" +edition = "2021" [dependencies] libc = "0.2.122" diff --git a/vm-device/Cargo.toml b/vm-device/Cargo.toml index 1ef298561..362bb2081 100644 --- a/vm-device/Cargo.toml +++ b/vm-device/Cargo.toml @@ -2,7 +2,7 @@ name = "vm-device" version = "0.1.0" authors = ["The Cloud Hypervisor Authors"] -edition = "2018" +edition = "2021" [features] default = [] diff --git a/vm-migration/Cargo.toml b/vm-migration/Cargo.toml index 87ed67ff6..05738873d 100644 --- a/vm-migration/Cargo.toml +++ b/vm-migration/Cargo.toml @@ -2,7 +2,7 @@ name = "vm-migration" version = "0.1.0" authors = ["The Cloud Hypervisor Authors"] -edition = "2018" +edition = "2021" [dependencies] anyhow = "1.0.56" diff --git a/vm-virtio/Cargo.toml b/vm-virtio/Cargo.toml index 8e9d4a795..007b72e8f 100644 --- a/vm-virtio/Cargo.toml +++ b/vm-virtio/Cargo.toml @@ -2,7 +2,7 @@ name = "vm-virtio" version = "0.1.0" authors = ["The Cloud Hypervisor Authors"] -edition = "2018" +edition = "2021" [features] default = [] diff --git a/vmm/Cargo.toml b/vmm/Cargo.toml index 886bb6ea9..8ef37b6fb 100644 --- a/vmm/Cargo.toml +++ b/vmm/Cargo.toml @@ -2,7 +2,7 @@ name = "vmm" version = "0.1.0" authors = ["The Cloud Hypervisor Authors"] -edition = "2018" +edition = "2021" [features] default = []