From 6a46b48dcd67e2a03fd557493fb4bdb44c814cda Mon Sep 17 00:00:00 2001 From: Mikhail Zabaluev Date: Thu, 9 Nov 2023 16:38:00 +0200 Subject: [PATCH] Update rustc option for instrument-coverage (#1377) * chore: update rustc flag for instrument-coverage In nightly, the compiler flag graduated from -Z to -C (stable options). * CI: link dead code for coverage Throw in -C link-dead-code into the compiler flags for the nightly-coverage CI job. * Fix prelude imports Remove imports that are reported as unused by the nightly compiler, override the lint for the vec macro import that is actually used. * Restore vec macro import in prelude Override the lint more selectively, specifically for this macro re-export. --- .github/workflows/test.yml | 2 +- config/src/prelude.rs | 1 - light-client-verifier/src/prelude.rs | 7 ++----- proto/src/prelude.rs | 5 +++-- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4461986a0..bea99c508 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -110,7 +110,7 @@ jobs: components: llvm-tools-preview - run: cargo test-all-features env: - RUSTFLAGS: '-Zinstrument-coverage' + RUSTFLAGS: '-C instrument-coverage -C link-dead-code' LLVM_PROFILE_FILE: '%p-%m.profraw' - name: Install grcov run: | diff --git a/config/src/prelude.rs b/config/src/prelude.rs index aa9a20b65..c000154db 100644 --- a/config/src/prelude.rs +++ b/config/src/prelude.rs @@ -2,7 +2,6 @@ // https://doc.rust-lang.org/src/alloc/prelude/v1.rs.html pub use alloc::{ borrow::ToOwned, - boxed::Box, format, string::{String, ToString}, vec, diff --git a/light-client-verifier/src/prelude.rs b/light-client-verifier/src/prelude.rs index 57a0cedc3..ca8015e71 100644 --- a/light-client-verifier/src/prelude.rs +++ b/light-client-verifier/src/prelude.rs @@ -1,13 +1,10 @@ // Re-export according to alloc::prelude::v1 because it is not yet stabilized // https://doc.rust-lang.org/src/alloc/prelude/v1.rs.html +#[allow(unused_imports)] +pub use alloc::vec; pub use alloc::{ - borrow::ToOwned, boxed::Box, - format, string::{String, ToString}, - vec, vec::Vec, }; -// will be included in 2021 edition. -pub use core::convert::{TryFrom, TryInto}; pub use core::prelude::v1::*; diff --git a/proto/src/prelude.rs b/proto/src/prelude.rs index aa9a20b65..593052fb3 100644 --- a/proto/src/prelude.rs +++ b/proto/src/prelude.rs @@ -1,11 +1,12 @@ // Re-export according to alloc::prelude::v1 because it is not yet stabilized // https://doc.rust-lang.org/src/alloc/prelude/v1.rs.html + +#[allow(unused_imports)] +pub use alloc::vec; pub use alloc::{ borrow::ToOwned, - boxed::Box, format, string::{String, ToString}, - vec, vec::Vec, }; pub use core::prelude::v1::*;