Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check failed with the latest version of cargo clippy #44

Closed
xiaoyuxlu opened this issue Mar 7, 2024 · 3 comments · Fixed by #52 or #54
Closed

Check failed with the latest version of cargo clippy #44

xiaoyuxlu opened this issue Mar 7, 2024 · 3 comments · Fixed by #52 or #54
Assignees

Comments

@xiaoyuxlu
Copy link
Collaborator

steps:

  1. use to latest nightly cargo clippy
    $ cargo clippy --version
    clippy 0.1.78 (b6d2d84 2024-03-05)
  2. run cargo clippy -- -D warnings -A clippy::only-used-in-recursion -A incomplete-features -A clippy::bad_bit_mask -A clippy::derivable_impls

expected result:
No error

actual results:

cargo clippy -- -D warnings -A clippy::only-used-in-recursion -A incomplete-features -A clippy::bad_bit_mask -A clippy::derivable_impls

....
....

error: the item `Box` is imported redundantly
   --> executor/src/executor.rs:9:13
    |
9   |     alloc::{boxed::Box, collections::vec_deque::VecDeque, sync::Arc},
    |             ^^^^^^^^^^
    |
   ::: /home/xiaoyu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13
    |
125 |     pub use super::v1::*;
    |             --------- the item `Box` is already defined here
    |
    = note: `-D unused-imports` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(unused_imports)]`

error: the item `Box` is imported redundantly
   --> executor/src/lib.rs:13:5
    |
13  | use alloc::boxed::Box;
    |     ^^^^^^^^^^^^^^^^^
    |
   ::: /home/xiaoyu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13
    |
125 |     pub use super::v1::*;
    |             --------- the item `Box` is already defined here

error: could not compile `executor` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
error: the item `Vec` is imported redundantly
   --> spdmlib/src/protocol/mod.rs:6:5
    |
6   | use alloc::vec::Vec;
    |     ^^^^^^^^^^^^^^^
    |
   ::: /home/xiaoyu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:115:13
    |
115 |     pub use super::v1::*;
    |             --------- the item `Vec` is already defined here
    |
    = note: `-D unused-imports` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(unused_imports)]`

error: the item `From` is imported redundantly
   --> spdmlib/src/protocol/algo.rs:9:5
    |
9   | use core::convert::From;
    |     ^^^^^^^^^^^^^^^^^^^
    |
   ::: /home/xiaoyu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:115:13
    |
115 |     pub use super::v1::*;
    |             --------- the item `From` is already defined here

error: the item `Box` is imported redundantly
   --> spdmlib/src/protocol/algo.rs:11:5
    |
11  | use alloc::boxed::Box;
    |     ^^^^^^^^^^^^^^^^^
    |
   ::: /home/xiaoyu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:115:13
    |
115 |     pub use super::v1::*;
    |             --------- the item `Box` is already defined here

error: the item `Box` is imported redundantly
   --> spdmlib/src/common/key_schedule.rs:10:5
    |
10  | use alloc::boxed::Box;
    |     ^^^^^^^^^^^^^^^^^
    |
   ::: /home/xiaoyu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:115:13
    |
115 |     pub use super::v1::*;
    |             --------- the item `Box` is already defined here

error: the item `SpdmCodec` is imported redundantly
 --> spdmlib/src/common/opaque.rs:5:5
  |
5 | use super::spdm_codec::SpdmCodec;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6 | use super::*;
  |     -------- the item `SpdmCodec` is already imported here

error: the item `SPDM_STATUS_BUFFER_FULL` is imported redundantly
 --> spdmlib/src/common/opaque.rs:7:32
  |
6 | use super::*;
  |     -------- the item `SPDM_STATUS_BUFFER_FULL` is already imported here
7 | use crate::error::{SpdmStatus, SPDM_STATUS_BUFFER_FULL, SPDM_STATUS_UNSUPPORTED_CAP};
  |                                ^^^^^^^^^^^^^^^^^^^^^^^

error: the item `Codec` is imported redundantly
 --> spdmlib/src/common/opaque.rs:8:18
  |
6 | use super::*;
  |     -------- the item `Codec` is already imported here
7 | use crate::error::{SpdmStatus, SPDM_STATUS_BUFFER_FULL, SPDM_STATUS_UNSUPPORTED_CAP};
8 | use codec::{u24, Codec, Reader, Writer};
  |                  ^^^^^

error: the item `Reader` is imported redundantly
 --> spdmlib/src/common/opaque.rs:8:25
  |
6 | use super::*;
  |     -------- the item `Reader` is already imported here
7 | use crate::error::{SpdmStatus, SPDM_STATUS_BUFFER_FULL, SPDM_STATUS_UNSUPPORTED_CAP};
8 | use codec::{u24, Codec, Reader, Writer};
  |                         ^^^^^^

error: the item `Writer` is imported redundantly
 --> spdmlib/src/common/opaque.rs:8:33
  |
6 | use super::*;
  |     -------- the item `Writer` is already imported here
7 | use crate::error::{SpdmStatus, SPDM_STATUS_BUFFER_FULL, SPDM_STATUS_UNSUPPORTED_CAP};
8 | use codec::{u24, Codec, Reader, Writer};
  |                                 ^^^^^^

error: the item `config` is imported redundantly
  --> spdmlib/src/common/session.rs:6:5
   |
6  | use crate::config;
   |     ^^^^^^^^^^^^^
...
22 | use super::*;
   |     -------- the item `config` is already imported here

error: the item `crypto` is imported redundantly
  --> spdmlib/src/common/session.rs:7:5
   |
7  | use crate::crypto;
   |     ^^^^^^^^^^^^^
...
22 | use super::*;
   |     -------- the item `crypto` is already imported here

error: the item `SpdmResult` is imported redundantly
  --> spdmlib/src/common/session.rs:8:5
   |
8  | use crate::error::SpdmResult;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^
...
22 | use super::*;
   |     -------- the item `SpdmResult` is already imported here

error: the item `SPDM_STATUS_CRYPTO_ERROR` is imported redundantly
  --> spdmlib/src/common/session.rs:11:5
   |
11 | use crate::error::SPDM_STATUS_CRYPTO_ERROR;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
22 | use super::*;
   |     -------- the item `SPDM_STATUS_CRYPTO_ERROR` is already imported here

error: the item `SPDM_STATUS_INVALID_STATE_LOCAL` is imported redundantly
  --> spdmlib/src/common/session.rs:13:5
   |
13 | use crate::error::SPDM_STATUS_INVALID_STATE_LOCAL;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
22 | use super::*;
   |     -------- the item `SPDM_STATUS_INVALID_STATE_LOCAL` is already imported here

error: the item `Codec` is imported redundantly
  --> spdmlib/src/common/session.rs:20:13
   |
20 | use codec::{Codec, Reader, Writer};
   |             ^^^^^
21 |
22 | use super::*;
   |     -------- the item `Codec` is already imported here

error: the item `Reader` is imported redundantly
  --> spdmlib/src/common/session.rs:20:20
   |
20 | use codec::{Codec, Reader, Writer};
   |                    ^^^^^^
21 |
22 | use super::*;
   |     -------- the item `Reader` is already imported here

error: the item `Writer` is imported redundantly
  --> spdmlib/src/common/session.rs:20:28
   |
20 | use codec::{Codec, Reader, Writer};
   |                            ^^^^^^
21 |
22 | use super::*;
   |     -------- the item `Writer` is already imported here

error: the item `Box` is imported redundantly
   --> spdmlib/src/common/spdm_codec.rs:17:5
    |
17  | use alloc::boxed::Box;
    |     ^^^^^^^^^^^^^^^^^
    |
   ::: /home/xiaoyu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:115:13
    |
115 |     pub use super::v1::*;
    |             --------- the item `Box` is already defined here

error: the item `Box` is imported redundantly
   --> spdmlib/src/common/mod.rs:14:5
    |
14  | use alloc::boxed::Box;
    |     ^^^^^^^^^^^^^^^^^
    |
   ::: /home/xiaoyu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:115:13
    |
115 |     pub use super::v1::*;
    |             --------- the item `Box` is already defined here

error: the item `Box` is imported redundantly
   --> spdmlib/src/crypto/crypto_callbacks.rs:8:5
    |
8   | use alloc::boxed::Box;
    |     ^^^^^^^^^^^^^^^^^
    |
   ::: /home/xiaoyu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:115:13
    |
115 |     pub use super::v1::*;
    |             --------- the item `Box` is already defined here

error: the item `Vec` is imported redundantly
   --> spdmlib/src/crypto/spdm_ring/cert_operation_impl.rs:7:5
    |
7   | use alloc::vec::Vec;
    |     ^^^^^^^^^^^^^^^
    |
   ::: /home/xiaoyu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:115:13
    |
115 |     pub use super::v1::*;
    |             --------- the item `Vec` is already defined here

error: the item `Box` is imported redundantly
   --> spdmlib/src/crypto/spdm_ring/dhe_impl.rs:6:5
    |
6   | use alloc::boxed::Box;
    |     ^^^^^^^^^^^^^^^^^
    |
   ::: /home/xiaoyu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:115:13
    |
115 |     pub use super::v1::*;
    |             --------- the item `Box` is already defined here

error: the item `Box` is imported redundantly
   --> spdmlib/src/crypto/spdm_ring/hash_impl.rs:38:9
    |
38  |     use alloc::boxed::Box;
    |         ^^^^^^^^^^^^^^^^^
    |
   ::: /home/xiaoyu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:115:13
    |
115 |     pub use super::v1::*;
    |             --------- the item `Box` is already defined here

error: the item `Box` is imported redundantly
   --> spdmlib/src/crypto/mod.rs:243:9
    |
243 |     use alloc::boxed::Box;
    |         ^^^^^^^^^^^^^^^^^
    |
   ::: /home/xiaoyu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:115:13
    |
115 |     pub use super::v1::*;
    |             --------- the item `Box` is already defined here

error: the item `SpdmCodec` is imported redundantly
 --> spdmlib/src/message/capability.rs:5:5
  |
5 | use crate::common::spdm_codec::SpdmCodec;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6 | use crate::error::SPDM_STATUS_BUFFER_FULL;
7 | use crate::message::*;
  |     ----------------- the item `SpdmCodec` is already imported here

error: the item `SPDM_STATUS_BUFFER_FULL` is imported redundantly
 --> spdmlib/src/message/capability.rs:6:5
  |
6 | use crate::error::SPDM_STATUS_BUFFER_FULL;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7 | use crate::message::*;
  |     ----------------- the item `SPDM_STATUS_BUFFER_FULL` is already imported here

error: the item `SpdmStatus` is imported redundantly
 --> spdmlib/src/message/capability.rs:8:21
  |
7 | use crate::message::*;
  |     ----------------- the item `SpdmStatus` is already imported here
8 | use crate::{common, error::SpdmStatus};
  |                     ^^^^^^^^^^^^^^^^^

error: the item `Codec` is imported redundantly
 --> spdmlib/src/message/capability.rs:9:13
  |
7 | use crate::message::*;
  |     ----------------- the item `Codec` is already imported here
8 | use crate::{common, error::SpdmStatus};
9 | use codec::{Codec, Reader, Writer};
  |             ^^^^^

error: the item `Reader` is imported redundantly
 --> spdmlib/src/message/capability.rs:9:20
  |
7 | use crate::message::*;
  |     ----------------- the item `Reader` is already imported here
8 | use crate::{common, error::SpdmStatus};
9 | use codec::{Codec, Reader, Writer};
  |                    ^^^^^^

error: the item `Writer` is imported redundantly
 --> spdmlib/src/message/capability.rs:9:28
  |
7 | use crate::message::*;
  |     ----------------- the item `Writer` is already imported here
8 | use crate::{common, error::SpdmStatus};
9 | use codec::{Codec, Reader, Writer};
  |                            ^^^^^^

error: the item `Box` is imported redundantly
   --> spdmlib/src/requester/finish_req.rs:11:5
    |
11  | use alloc::boxed::Box;
    |     ^^^^^^^^^^^^^^^^^
    |
   ::: /home/xiaoyu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:115:13
    |
115 |     pub use super::v1::*;
    |             --------- the item `Box` is already defined here

error: the item `Box` is imported redundantly
   --> spdmlib/src/requester/key_exchange_req.rs:6:5
    |
6   | use alloc::boxed::Box;
    |     ^^^^^^^^^^^^^^^^^
    |
   ::: /home/xiaoyu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:115:13
    |
115 |     pub use super::v1::*;
    |             --------- the item `Box` is already defined here

error: the item `SpdmMeasurementSummaryHashType` is imported redundantly
  --> spdmlib/src/requester/key_exchange_req.rs:26:23
   |
19 | use crate::protocol::*;
   |     ------------------ the item `SpdmMeasurementSummaryHashType` is already imported here
...
26 | use crate::protocol::{SpdmMeasurementSummaryHashType, SpdmSignatureStruct, SpdmVersion};
   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: the item `SpdmSignatureStruct` is imported redundantly
  --> spdmlib/src/requester/key_exchange_req.rs:26:55
   |
19 | use crate::protocol::*;
   |     ------------------ the item `SpdmSignatureStruct` is already imported here
...
26 | use crate::protocol::{SpdmMeasurementSummaryHashType, SpdmSignatureStruct, SpdmVersion};
   |                                                       ^^^^^^^^^^^^^^^^^^^

error: the item `SpdmVersion` is imported redundantly
  --> spdmlib/src/requester/key_exchange_req.rs:26:76
   |
19 | use crate::protocol::*;
   |     ------------------ the item `SpdmVersion` is already imported here
...
26 | use crate::protocol::{SpdmMeasurementSummaryHashType, SpdmSignatureStruct, SpdmVersion};
   |                                                                            ^^^^^^^^^^^

error: the item `SpdmMeasurementSummaryHashType` is imported redundantly
  --> spdmlib/src/requester/psk_exchange_req.rs:14:5
   |
14 | use crate::protocol::SpdmMeasurementSummaryHashType;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15 | use crate::protocol::*;
   |     ------------------ the item `SpdmMeasurementSummaryHashType` is already imported here

error: the item `Box` is imported redundantly
   --> spdmlib/src/requester/psk_finish_req.rs:13:5
    |
13  | use alloc::boxed::Box;
    |     ^^^^^^^^^^^^^^^^^
    |
   ::: /home/xiaoyu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:115:13
    |
115 |     pub use super::v1::*;
    |             --------- the item `Box` is already defined here

error: the item `gen_array_clone` is imported redundantly
  --> spdmlib/src/responder/digest_rsp.rs:16:5
   |
12 | use crate::protocol::*;
   |     ------------------ the item `gen_array_clone` is already imported here
...
16 | use crate::protocol::gen_array_clone;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: the item `Box` is imported redundantly
   --> spdmlib/src/responder/digest_rsp.rs:17:5
    |
17  | use alloc::boxed::Box;
    |     ^^^^^^^^^^^^^^^^^
    |
   ::: /home/xiaoyu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:115:13
    |
115 |     pub use super::v1::*;
    |             --------- the item `Box` is already defined here

error: the item `SpdmResult` is imported redundantly
  --> spdmlib/src/responder/finish_rsp.rs:8:5
   |
8  | use crate::error::SpdmResult;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^
...
12 | use crate::error::*;
   |     --------------- the item `SpdmResult` is already imported here

error: the item `SPDM_STATUS_CRYPTO_ERROR` is imported redundantly
  --> spdmlib/src/responder/finish_rsp.rs:9:5
   |
9  | use crate::error::SPDM_STATUS_CRYPTO_ERROR;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
12 | use crate::error::*;
   |     --------------- the item `SPDM_STATUS_CRYPTO_ERROR` is already imported here

error: the item `SPDM_STATUS_INVALID_MSG_FIELD` is imported redundantly
  --> spdmlib/src/responder/finish_rsp.rs:10:5
   |
10 | use crate::error::SPDM_STATUS_INVALID_MSG_FIELD;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
11 | use crate::error::SPDM_STATUS_INVALID_STATE_LOCAL;
12 | use crate::error::*;
   |     --------------- the item `SPDM_STATUS_INVALID_MSG_FIELD` is already imported here

error: the item `SPDM_STATUS_INVALID_STATE_LOCAL` is imported redundantly
  --> spdmlib/src/responder/finish_rsp.rs:11:5
   |
11 | use crate::error::SPDM_STATUS_INVALID_STATE_LOCAL;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12 | use crate::error::*;
   |     --------------- the item `SPDM_STATUS_INVALID_STATE_LOCAL` is already imported here

error: the item `Box` is imported redundantly
   --> spdmlib/src/responder/finish_rsp.rs:17:5
    |
17  | use alloc::boxed::Box;
    |     ^^^^^^^^^^^^^^^^^
    |
   ::: /home/xiaoyu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:115:13
    |
115 |     pub use super::v1::*;
    |             --------- the item `Box` is already defined here

error: the item `Box` is imported redundantly
   --> spdmlib/src/responder/key_exchange_rsp.rs:24:5
    |
24  | use alloc::boxed::Box;
    |     ^^^^^^^^^^^^^^^^^
    |
   ::: /home/xiaoyu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:115:13
    |
115 |     pub use super::v1::*;
    |             --------- the item `Box` is already defined here

error: the item `Box` is imported redundantly
   --> spdmlib/src/responder/psk_exchange_rsp.rs:25:5
    |
25  | use alloc::boxed::Box;
    |     ^^^^^^^^^^^^^^^^^
    |
   ::: /home/xiaoyu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:115:13
    |
115 |     pub use super::v1::*;
    |             --------- the item `Box` is already defined here

error: the feature `async_fn_in_trait` has been stable since 1.75.0 and no longer requires an attribute to enable
 --> spdmlib/src/lib.rs:9:12
  |
9 | #![feature(async_fn_in_trait)]
  |            ^^^^^^^^^^^^^^^^^
  |
  = note: `-D stable-features` implied by `-D warnings`
  = help: to override `-D warnings` add `#[allow(stable_features)]`

error: in a `match` scrutinee, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a `let`
  --> spdmlib/src/crypto/spdm_ring/dhe_impl.rs:41:89
   |
41 |           match ring::agreement::agree_ephemeral(self.0, &peer_public_key, |key_material| {
   |  _________________________________________________________________________________________^
42 | |             final_key.extend_from_slice(key_material);
43 | |         }) {
   | |_________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#blocks_in_conditions
   = note: `-D clippy::blocks-in-conditions` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(clippy::blocks_in_conditions)]`

error: in a `match` scrutinee, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a `let`
  --> spdmlib/src/crypto/spdm_ring/dhe_impl.rs:79:89
   |
79 |           match ring::agreement::agree_ephemeral(self.0, &peer_public_key, |key_material| {
   |  _________________________________________________________________________________________^
80 | |             final_key.extend_from_slice(key_material);
81 | |         }) {
   | |_________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#blocks_in_conditions

error: you seem to use `.enumerate()` and immediately discard the index
   --> spdmlib/src/requester/key_exchange_req.rs:107:35
    |
107 |           for (_, local_version) in self
    |  ___________________________________^
108 | |             .common
109 | |             .config_info
110 | |             .secure_spdm_version
111 | |             .iter()
112 | |             .flatten()
113 | |             .enumerate()
    | |________________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_enumerate_index
    = note: `-D clippy::unused-enumerate-index` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::unused_enumerate_index)]`
help: remove the `.enumerate()` call
    |
107 ~         for local_version in self
108 +             .common
109 +             .config_info
110 +             .secure_spdm_version
111 +             .iter()
112 +             .flatten()
    |

error: you seem to use `.enumerate()` and immediately discard the index
   --> spdmlib/src/requester/psk_exchange_req.rs:94:35
    |
94  |           for (_, local_version) in self
    |  ___________________________________^
95  | |             .common
96  | |             .config_info
97  | |             .secure_spdm_version
98  | |             .iter()
99  | |             .flatten()
100 | |             .enumerate()
    | |________________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_enumerate_index
help: remove the `.enumerate()` call
    |
94  ~         for local_version in self
95  +             .common
96  +             .config_info
97  +             .secure_spdm_version
98  +             .iter()
99  +             .flatten()
    |

error: you seem to use `.enumerate()` and immediately discard the index
   --> spdmlib/src/responder/key_exchange_rsp.rs:153:47
    |
153 |                       for (_, local_version) in self
    |  _______________________________________________^
154 | |                         .common
155 | |                         .config_info
156 | |                         .secure_spdm_version
157 | |                         .iter()
158 | |                         .flatten()
159 | |                         .enumerate()
    | |____________________________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_enumerate_index
help: remove the `.enumerate()` call
    |
153 ~                     for local_version in self
154 +                         .common
155 +                         .config_info
156 +                         .secure_spdm_version
157 +                         .iter()
158 +                         .flatten()
    |

error: you seem to use `.enumerate()` and immediately discard the index
   --> spdmlib/src/responder/psk_exchange_rsp.rs:148:47
    |
148 |                       for (_, local_version) in self
    |  _______________________________________________^
149 | |                         .common
150 | |                         .config_info
151 | |                         .secure_spdm_version
152 | |                         .iter()
153 | |                         .flatten()
154 | |                         .enumerate()
    | |____________________________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_enumerate_index
help: remove the `.enumerate()` call
    |
148 ~                     for local_version in self
149 +                         .common
150 +                         .config_info
151 +                         .secure_spdm_version
152 +                         .iter()
153 +                         .flatten()
    |

error: you seem to use `.enumerate()` and immediately discard the index
  --> spdmlib/src/responder/version_rsp.rs:79:23
   |
79 |           for (_, v) in self
   |  _______________________^
80 | |             .common
81 | |             .config_info
82 | |             .spdm_version
83 | |             .iter()
84 | |             .flatten()
85 | |             .enumerate()
   | |________________________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_enumerate_index
help: remove the `.enumerate()` call
   |
79 ~         for v in self
80 +             .common
81 +             .config_info
82 +             .spdm_version
83 +             .iter()
84 +             .flatten()
   |

error: could not compile `spdmlib` (lib) due to 54 previous errors
@OuyangHang33
Copy link
Collaborator

still need to fix this kind of error:
error: the item Box is imported redundantly
--> executor/src/executor.rs:9:13
|
9 | alloc::{boxed::Box, collections::vec_deque::VecDeque, sync::Arc},
| ^^^^^^^^^^
|
::: /home/xiaoyu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:125:13
|
125 | pub use super::v1::*;
| --------- the item Box is already defined here
|
= note: -D unused-imports implied by -D warnings
= help: to override -D warnings add #[allow(unused_imports)]

@OuyangHang33
Copy link
Collaborator

Hi, I did some investigation work about why the latest version clippy got different results for Box is imported redundantly:

Root cause:

This patch changed check_for_redundant_imports: rust-lang/rust#117772,
The check_for_redundant_imports logic (skip the import and check what is next in scope) only makes sense for imports that are used only during scope-based resolution.

Reference:

Recently, users found some fallout from new check_for_redundant_imports, and the impacted projects mostly have no_std feature:
rust-lang/rust#121708 (comment)
rust-lang/rust#121312

Suggestion Solution:

rust-lang/rust#121708 (comment)

Replace
#![cfg_attr(not(feature = "std"), no_std)]
with

#![no_std]

#[cfg(feature = "std")]
extern crate std;

@jyao1
Copy link
Member

jyao1 commented Mar 13, 2024

@OuyangHang33, please submit PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants