rust-lang / rust-clippy

A bunch of lints to catch common mistakes and improve your Rust code. Book: https://doc.rust-lang.org/clippy/
https://rust-lang.github.io/rust-clippy/
Other
11.51k stars 1.55k forks source link

False positive: redundant_clone #10577

Open glittershark opened 1 year ago

glittershark commented 1 year ago

Summary

I looked and this didn't look like any of the existing redundant_clone false positives. Sometime between nightly-2022-10-01 and nightly-2023-03-18 (sorry for the wide range) clippy::redundant_clone started false-positive firing here. If that clone() call is removed, compilation fails due to index_on being used here

Lint Name

clippy::redundant_clone

Reproducer

See links

Version

❯ rustc -Vv
rustc 1.70.0-nightly (4a04d086c 2023-03-18)
binary: rustc
commit-hash: 4a04d086cac54a41517d5657b59d5fe2caca2d71
commit-date: 2023-03-18
host: x86_64-unknown-linux-gnu
release: 1.70.0-nightly
LLVM version: 16.0.0

Additional Labels

No response

ilyagr commented 1 year ago

Narrowing down the range, I don't think this triggered as recently as rustc 1.69.0-nightly (13471d3b2 2023-03-02). At least, that seems to be the case for my similar issue at https://github.com/martinvonz/jj/pull/1465.

andrey-yantsen commented 1 year ago

To help narrow down the range — the issue started sometime between 2023-03-16 and 2023-03-18. The last successful build for me was on 16 March 2023, and the first failed one was on 18 March.

zeenix commented 1 year ago

FWIW I bumped into this too with this code in zbus.

error: redundant clone
   --> zbus_macros/src/error.rs:239:26
    |
239 |                 in_fields.clone()
    |                          ^^^^^^^^ help: remove this
    |
note: cloned value is neither consumed nor mutated
   --> zbus_macros/src/error.rs:239:17
    |
239 |                 in_fields.clone()
    |                 ^^^^^^^^^^^^^^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone
    = note: `-D clippy::redundant-clone` implied by `-D warnings`
brooksprumo commented 1 year ago

We are hitting this as well on the https://github.com/solana-labs/solana repo when trying to upgrade our nightly version to 2023-04-15. (Our nightly is currently on 2023-03-04.)

Here's the full (long!) output ``` $ git clone https://github.com/solana-labs/solana.git $ git checkout 775639c0582d540d4dd068275ac5f75414b8f961 $ cargo +nightly-2023-04-15 clippy --tests --benches --fix Updating crates.io index Downloaded proc-macro2 v1.0.56 Downloaded semver v1.0.17 Downloaded console v0.15.5 Downloaded prost v0.11.9 Downloaded prost-types v0.11.9 Downloaded futures-io v0.3.28 Downloaded enum-iterator-derive v1.2.0 Downloaded matches v0.1.10 Downloaded enum-iterator v1.4.0 Downloaded fd-lock v3.0.12 Downloaded futures-core v0.3.28 Downloaded sysctl v0.4.6 Downloaded thiserror v1.0.40 Downloaded shell-words v1.1.0 Downloaded errno v0.3.1 Downloaded byte-unit v4.0.19 Downloaded futures-task v0.3.28 Downloaded futures-sink v0.3.28 Downloaded futures-macro v0.3.28 Downloaded ctrlc v3.2.5 Downloaded memoffset v0.7.1 Downloaded tempfile v3.5.0 Downloaded prost-derive v0.11.9 Downloaded io-lifetimes v1.0.10 Downloaded futures-channel v0.3.28 Downloaded thiserror-impl v1.0.40 Downloaded native-tls v0.2.11 Downloaded dialoguer v0.10.4 Downloaded assert_cmd v2.0.8 Downloaded serde_derive v1.0.162 Downloaded anyhow v1.0.71 Downloaded async-trait v0.1.68 Downloaded serde v1.0.162 Downloaded miniz_oxide v0.7.1 Downloaded openssl-sys v0.9.87 Downloaded base64 v0.21.0 Downloaded flate2 v1.0.26 Downloaded http v0.2.9 Downloaded crossbeam-channel v0.5.8 Downloaded reqwest v0.11.17 Downloaded futures-util v0.3.28 Downloaded hyper v0.14.26 Downloaded rustix v0.37.18 Downloaded openssl v0.10.52 Downloaded syn v2.0.15 Downloaded nix v0.26.2 Downloaded bstr v1.4.0 Downloaded 47 crates (3.2 MB) in 1.58s Compiling libc v0.2.142 Compiling proc-macro2 v1.0.56 Compiling quote v1.0.26 Compiling unicode-ident v1.0.2 Compiling syn v1.0.109 Checking cfg-if v1.0.0 Compiling autocfg v1.1.0 Compiling version_check v0.9.4 Compiling serde_derive v1.0.162 Compiling serde v1.0.162 Compiling memchr v2.4.1 Checking lazy_static v1.4.0 Compiling log v0.4.17 Checking once_cell v1.17.1 Compiling typenum v1.15.0 Checking scopeguard v1.1.0 Compiling generic-array v0.14.7 Compiling semver v1.0.17 Checking itoa v1.0.1 Compiling crossbeam-utils v0.8.14 Checking ppv-lite86 v0.2.15 Checking either v1.8.1 Compiling memoffset v0.6.4 Compiling libm v0.2.1 Checking bitflags v1.3.2 Compiling crossbeam-epoch v0.9.5 (https://github.com/solana-labs/crossbeam?rev=fd279d707025f0e60951e429bf778b4813d1b6bf#fd279d70) Compiling num-traits v0.2.15 Compiling ahash v0.7.6 Compiling rayon-core v1.11.0 Compiling rustc_version v0.4.0 Checking subtle v2.4.1 Checking crossbeam-channel v0.5.8 Checking getrandom v0.2.8 Compiling syn v2.0.15 Compiling jobserver v0.1.24 Checking num_cpus v1.15.0 Compiling thiserror v1.0.40 Compiling num-integer v0.1.44 Checking rand_core v0.6.4 Compiling anyhow v1.0.71 Compiling ryu v1.0.5 Compiling cc v1.0.79 Checking crossbeam-deque v0.8.1 Compiling unicode-xid v0.2.2 Checking rand_chacha v0.3.1 Checking fnv v1.0.7 Checking base64 v0.13.1 Compiling serde_json v1.0.96 Compiling num-bigint v0.4.3 Compiling getrandom v0.1.16 Checking rand v0.8.5 Checking cpufeatures v0.2.1 Checking tinyvec_macros v0.1.0 Checking regex-syntax v0.6.27 Checking rayon v1.7.0 Checking tinyvec v1.5.0 Checking aho-corasick v0.7.18 Compiling rustversion v1.0.12 Checking byteorder v1.4.3 Checking block-padding v0.2.1 Checking rand_core v0.5.1 Checking opaque-debug v0.3.0 Checking rand_chacha v0.2.2 Compiling core-foundation-sys v0.8.3 Checking unicode-normalization v0.1.19 Compiling crunchy v0.2.2 Checking rand v0.7.3 Checking bytes v1.4.0 Checking regex v1.6.0 Checking itertools v0.10.5 Compiling paste v1.0.9 Checking pin-project-lite v0.2.7 Checking percent-encoding v2.1.0 Compiling wasm-bindgen-shared v0.2.84 Compiling synstructure v0.12.6 Compiling feature-probe v0.1.1 Compiling blake3 v1.3.3 Checking bitmaps v2.1.0 Compiling im v15.1.0 Checking arrayref v0.3.7 Compiling bv v0.11.1 Checking smallvec v1.7.0 Checking rand_xoshiro v0.6.0 Checking rustc-hash v1.1.0 Compiling digest v0.9.0 Checking arrayvec v0.7.2 Checking sized-chunks v0.6.5 Checking constant_time_eq v0.2.5 Compiling bumpalo v3.12.0 Checking bs58 v0.4.0 Compiling libsecp256k1-core v0.2.2 Checking memmap2 v0.5.10 Checking atty v0.2.14 Checking lock_api v0.4.6 Checking keccak v0.1.0 Compiling wasm-bindgen-backend v0.2.84 Compiling borsh-derive-internal v0.9.3 Compiling borsh-schema-derive-internal v0.9.3 Compiling thiserror-impl v1.0.40 Compiling memoffset v0.8.0 Compiling toml v0.5.8 Checking termcolor v1.1.2 Compiling libsecp256k1-gen-genmult v0.2.1 Compiling libsecp256k1-gen-ecmult v0.2.1 Compiling wasm-bindgen v0.2.84 Checking hashbrown v0.11.2 Checking humantime v2.1.0 Checking base64 v0.12.3 Compiling zeroize_derive v1.2.0 Compiling derivative v2.2.0 Compiling libsecp256k1 v0.6.0 Compiling wasm-bindgen-macro-support v0.2.84 Compiling bytemuck_derive v1.4.0 Compiling num-derive v0.3.3 Compiling ahash v0.8.3 Compiling proc-macro-crate v0.1.5 Checking zeroize v1.3.0 Checking array-bytes v1.4.1 Compiling futures-core v0.3.28 Compiling borsh-derive v0.9.3 Checking env_logger v0.9.3 Checking bytemuck v1.13.0 Compiling parking_lot_core v0.8.5 Compiling wasm-bindgen-macro v0.2.84 Checking borsh v0.9.3 Checking instant v0.1.12 Compiling proc-macro-crate v1.1.0 Compiling ark-serialize-derive v0.4.2 Checking ark-std v0.4.0 Checking hashbrown v0.12.3 Compiling solana-frozen-abi-macro v1.16.0 (/Users/brooks/work/solana/frozen-abi/macro) Compiling ident_case v1.0.1 Checking pin-utils v0.1.0 Compiling strsim v0.10.0 Compiling ark-ff-macros v0.4.2 Compiling ark-ff-asm v0.4.2 Checking hashbrown v0.13.2 Checking iana-time-zone v0.1.46 Compiling solana-frozen-abi v1.16.0 (/Users/brooks/work/solana/frozen-abi) Checking signal-hook-registry v1.4.0 Compiling darling_core v0.14.2 Checking parking_lot v0.11.2 Checking time v0.1.43 Compiling tokio v1.14.1 Checking signature v1.4.0 Compiling tokio-macros v1.7.0 Checking mio v0.7.14 Compiling solana-program v1.16.0 (/Users/brooks/work/solana/sdk/program) Checking ed25519 v1.2.0 Checking assert_matches v1.5.0 Checking derivation-path v0.2.0 Checking solana-logger v1.16.0 (/Users/brooks/work/solana/logger) Compiling solana-sdk-macro v1.16.0 (/Users/brooks/work/solana/sdk/macro) Checking qstring v0.7.2 Checking uriparse v0.6.4 Checking slab v0.4.5 Checking futures-sink v0.3.28 Compiling io-lifetimes v1.0.10 Compiling futures-task v0.3.28 Compiling futures-channel v0.3.28 Compiling num_enum_derive v0.6.1 Compiling solana-sdk v1.16.0 (/Users/brooks/work/solana/sdk) Compiling futures-util v0.3.28 Checking futures-io v0.3.28 Compiling futures-macro v0.3.28 Compiling rustix v0.37.18 Checking futures v0.1.31 Compiling indexmap v1.9.2 Compiling darling_macro v0.14.2 Checking tracing-core v0.1.21 Checking num_enum v0.6.1 Compiling tracing-attributes v0.1.18 Compiling ring v0.16.20 Compiling darling v0.14.2 Checking errno v0.3.1 Checking serde_bytes v0.11.9 Checking bincode v1.3.3 Checking chrono v0.4.24 Compiling serde_with_macros v2.3.2 Checking crypto-common v0.1.3 Checking block-buffer v0.10.2 Checking block-buffer v0.9.0 Checking crypto-mac v0.8.0 Checking tracing v0.1.29 Checking digest v0.10.6 Checking curve25519-dalek v3.2.1 Checking sha2 v0.9.9 Checking hmac v0.8.1 Checking pbkdf2 v0.4.0 Checking untrusted v0.7.1 Checking sha2 v0.10.6 Checking sha3 v0.10.4 Checking ark-serialize v0.4.2 Checking hmac-drbg v0.3.0 Checking tiny-bip39 v0.8.2 Checking hmac v0.12.1 Checking serde_with v2.3.2 Checking ed25519-dalek v1.0.1 Checking pbkdf2 v0.11.0 Checking spin v0.5.2 Checking fastrand v1.6.0 Checking http v0.2.9 Checking socket2 v0.4.9 Compiling httparse v1.8.0 Checking matches v0.1.10 Checking tower-service v0.3.1 Checking ed25519-dalek-bip32 v0.2.0 Checking tempfile v3.5.0 Checking tokio-util v0.7.1 Checking unicode-bidi v0.3.7 Checking httpdate v1.0.1 Checking try-lock v0.2.3 Compiling rustls v0.20.8 Checking http-body v0.4.5 Checking ark-ff v0.4.2 Checking core-foundation v0.9.2 Checking want v0.3.0 Checking security-framework-sys v2.4.2 Checking form_urlencoded v1.0.1 Checking h2 v0.3.18 Checking webpki v0.22.0 Checking sct v0.7.0 Checking idna v0.2.3 Checking mime v0.3.16 Compiling native-tls v0.2.11 Checking security-framework v2.4.2 Compiling crc32fast v1.2.1 Checking alloc-no-stdlib v2.0.3 Checking adler v1.0.2 Checking webpki-roots v0.22.1 Checking url v2.2.2 Compiling encoding_rs v0.8.29 Checking alloc-stdlib v0.2.1 Checking miniz_oxide v0.7.1 Checking rustls-pemfile v1.0.0 Checking serde_urlencoded v0.7.1 Checking brotli-decompressor v2.3.2 Checking ipnet v2.3.1 Checking base64 v0.21.0 Checking gethostname v0.2.3 Compiling num-bigint v0.2.6 Checking tokio-native-tls v0.3.0 Checking flate2 v1.0.26 Compiling num-rational v0.2.4 Compiling num-complex v0.2.4 Compiling num-iter v0.1.43 Compiling scroll_derive v0.11.0 Checking tokio-rustls v0.23.3 Checking void v1.0.2 Checking brotli v3.3.4 Compiling winapi v0.3.9 Checking unreachable v1.0.0 Checking hyper v0.14.26 Checking plain v0.2.3 Checking ascii v0.9.3 Checking managed v0.8.0 Compiling enum-iterator-derive v1.2.0 Checking scroll v0.11.0 Checking combine v3.8.1 Checking hash32 v0.2.1 Checking gdbstub v0.6.3 Compiling solana-program-runtime v1.16.0 (/Users/brooks/work/solana/program-runtime) Checking rustc-demangle v0.1.21 Checking eager v0.1.0 Compiling solana-vote-program v1.16.0 (/Users/brooks/work/solana/programs/vote) Compiling proc-macro2 v0.4.30 Checking cipher v0.3.0 Checking enum-iterator v1.4.0 Checking goblin v0.5.1 Checking num v0.2.1 Compiling unicode-xid v0.1.0 Checking percentage v0.1.0 Checking universal-hash v0.4.1 Compiling syn v0.15.44 Checking aes v0.7.5 Checking polyval v0.5.3 Checking ctr v0.8.0 Checking async-compression v0.3.14 Checking aead v0.4.3 Checking sha3 v0.9.1 Checking hyper-tls v0.5.0 Checking hyper-rustls v0.23.0 Checking merlin v3.0.0 Compiling proc-macro-error-attr v1.0.4 Checking aes-gcm-siv v0.10.3 Compiling solana-perf v1.16.0 (/Users/brooks/work/solana/perf) Compiling quote v0.6.13 Checking solana-rayon-threadlimit v1.16.0 (/Users/brooks/work/solana/rayon-threadlimit) Compiling proc-macro-error v1.0.4 Checking reqwest v0.11.17 Compiling ucd-trie v0.1.3 Checking static_assertions v1.1.0 Compiling pest v2.1.3 Compiling pkg-config v0.3.22 Compiling zstd-sys v2.0.1+zstd.1.5.2 Checking solana_rbpf v0.3.0 Compiling solana-address-lookup-table-program v1.16.0 (/Users/brooks/work/solana/programs/address-lookup-table) Compiling zstd-safe v5.0.1+zstd.1.5.2 Checking ark-std v0.3.0 Compiling ark-ff-macros v0.3.0 Compiling ark-ff-asm v0.3.0 Checking ark-serialize v0.3.0 Compiling solana-frozen-abi-macro v1.15.1 Checking ark-poly v0.4.2 Compiling semver-parser v0.10.2 Compiling heck v0.4.0 Checking futures-executor v0.3.24 Compiling solana-frozen-abi v1.15.1 Compiling solana-program v1.15.1 Compiling solana-sdk-macro v1.15.1 Compiling num_enum_derive v0.5.11 Compiling solana-version v1.16.0 (/Users/brooks/work/solana/version) Compiling semver v0.11.0 Checking futures v0.3.24 Compiling solana-sdk v1.15.1 Checking ark-ec v0.4.2 Checking inout v0.1.2 Compiling rustc_version v0.3.3 Checking solana-logger v1.15.1 Checking unicode-width v0.1.9 Compiling async-trait v0.1.68 Checking Inflector v0.11.4 Checking num_threads v0.1.3 Compiling dlopen_derive v0.1.4 Checking cipher v0.4.3 Checking console v0.15.5 Compiling time-macros v0.2.4 Compiling bzip2-sys v0.1.11+1.0.8 Compiling parking_lot_core v0.9.1 Compiling ark-ff v0.3.0 Compiling modular-bitfield-impl v0.11.2 Checking filetime v0.2.15 Checking xattr v0.2.2 Checking num_enum v0.5.11 Checking textwrap v0.11.0 Compiling lz4-sys v1.9.4 Checking dlopen v0.1.8 Checking tar v0.4.38 Compiling solana-stake-program v1.16.0 (/Users/brooks/work/solana/programs/stake) Checking strsim v0.8.0 Checking ark-bn254 v0.4.0 Checking ansi_term v0.11.0 Checking vec_map v0.8.2 Checking parking_lot v0.12.1 Checking same-file v1.0.6 Checking jsonrpc-core v18.0.0 Checking clap v2.33.3 Compiling strum_macros v0.24.3 Checking lru v0.7.8 Compiling solana-runtime v1.16.0 (/Users/brooks/work/solana/runtime) Checking modular-bitfield v0.11.2 Checking walkdir v2.3.2 Checking time v0.3.9 Checking aliasable v0.1.3 Compiling ouroboros_macro v0.15.6 Checking dashmap v4.0.2 Checking dir-diff v0.3.2 Checking index_list v0.2.7 Checking symlink v0.1.0 Compiling hidapi v2.2.0 Compiling memoffset v0.7.1 Checking tokio-stream v0.1.12 Checking shell-words v1.1.0 Compiling pin-project-internal v1.0.12 Checking dialoguer v0.10.4 Checking rtoolbox v0.0.1 Compiling portable-atomic v0.3.19 Checking sha-1 v0.10.0 Checking os_str_bytes v6.0.0 Checking rpassword v7.2.0 Checking strum v0.24.0 Checking ouroboros v0.15.6 Checking number_prefix v0.4.0 Compiling clap_derive v3.2.18 Checking clap_lex v0.2.4 Checking textwrap v0.16.0 Checking pin-project v1.0.12 Checking yasna v0.5.0 Checking pem v1.1.1 Compiling nom v7.0.0 Checking minimal-lexical v0.1.4 Checking nix v0.26.2 Checking rcgen v0.10.0 Compiling displaydoc v0.2.3 Compiling asn1-rs-impl v0.1.0 Compiling asn1-rs-derive v0.4.0 Checking rustls-pemfile v0.2.1 Checking rustls-native-certs v0.6.1 Checking const-oid v0.7.1 Checking indicatif v0.17.3 Compiling oid-registry v0.6.0 Checking quinn-proto v0.9.3 Checking der v0.5.1 Checking clap v3.2.23 Checking base64ct v1.3.3 Checking event-listener v2.5.2 Checking concurrent-queue v2.1.0 Checking data-encoding v2.3.2 Checking histogram v0.6.9 Checking spki v0.5.4 Checking async-channel v1.8.0 Checking chrono-humanize v0.2.2 Checking pkcs8 v0.8.0 Checking utf-8 v0.7.6 Checking async-mutex v1.4.0 Compiling prost-derive v0.11.9 Compiling which v4.2.2 Checking tungstenite v0.17.3 Checking rusticata-macros v4.1.0 Checking asn1-rs v0.5.1 Checking quinn-udp v0.3.2 Compiling fixedbitset v0.4.0 Checking tokio-tungstenite v0.17.2 Compiling multimap v0.8.3 Checking quinn v0.9.3 Checking tokio-util v0.6.9 Compiling autotools v0.2.5 Compiling openssl-src v111.25.0+1.1.1t Compiling glob v0.3.0 Checking tower-layer v0.3.2 Compiling protobuf-src v1.1.0+21.5 Compiling openssl-sys v0.9.87 Checking prost v0.11.9 Compiling petgraph v0.6.0 Checking ark-ec v0.3.0 Compiling clang-sys v1.2.2 Compiling prettyplease v0.1.9 Checking tower v0.4.13 Compiling prost-types v0.11.9 Checking ieee754 v0.2.6 Checking ark-bn254 v0.3.0 Checking fast-math v0.1.1 Checking tokio-io-timeout v1.1.1 Compiling async-stream-impl v0.3.2 Compiling axum-core v0.3.2 Compiling libloading v0.7.4 Compiling openssl v0.10.52 Compiling bindgen v0.60.1 Checking foreign-types-shared v0.1.1 Checking hyper-timeout v0.4.1 Checking der-parser v8.1.0 Checking foreign-types v0.3.2 Compiling prost-build v0.11.4 Checking async-stream v0.3.2 Checking tracing-futures v0.2.5 Compiling openssl-macros v0.1.0 Compiling axum v0.6.4 Compiling lazycell v1.3.0 Checking x509-parser v0.14.0 Compiling tonic-build v0.8.4 Checking http-range-header v0.3.0 Compiling peeking_take_while v0.1.2 Compiling shlex v1.1.0 Checking tower-http v0.3.5 Checking headers-core v0.2.0 Compiling cexpr v0.6.0 Checking sync_wrapper v0.1.1 Checking matchit v0.7.0 Checking simpl v0.1.0 Checking fs_extra v1.3.0 Checking headers v0.3.7 Checking arc-swap v1.5.0 Checking backoff v0.4.0 Compiling reed-solomon-erasure v6.0.0 Compiling solana-ledger v1.16.0 (/Users/brooks/work/solana/ledger) Checking spin v0.9.2 Checking trees v0.4.2 Checking dirs-sys-next v0.1.2 Checking unsafe-libyaml v0.2.8 Checking hyper-proxy v0.9.1 Compiling solana-bloom v1.16.0 (/Users/brooks/work/solana/bloom) Checking dirs-next v2.0.0 Compiling solana-gossip v1.16.0 (/Users/brooks/work/solana/gossip) Compiling unicase v2.6.0 Checking sysctl v0.4.6 Checking serde_yaml v0.9.21 Checking users v0.10.0 Checking unix_socket2 v0.5.4 Checking bstr v0.2.17 Compiling prost-derive v0.9.0 Checking core_affinity v0.5.10 Checking parity-tokio-ipc v0.9.0 Checking globset v0.4.8 Checking idna v0.1.5 Checking percent-encoding v1.0.1 Checking cfg-if v0.1.10 Compiling convert_case v0.4.0 Checking jsonrpc-server-utils v18.0.0 Checking net2 v0.2.37 Compiling prost-build v0.9.0 Checking url v1.7.2 Compiling derive_more v0.99.16 Checking jsonrpc-pubsub v18.0.0 Compiling unicode-segmentation v1.9.0 Compiling maplit v1.0.2 Compiling pest_meta v2.1.3 Checking jsonrpc-http-server v18.0.0 Checking sha-1 v0.9.8 Compiling prost v0.9.0 Compiling heck v0.3.3 Checking soketto v0.7.1 Checking stream-cancel v0.8.1 Compiling pest_generator v2.1.3 Checking webpki v0.21.4 Checking sct v0.6.1 Compiling jsonrpc-derive v18.0.0 Compiling prost-types v0.9.0 Checking rustls v0.19.1 Compiling librocksdb-sys v0.8.0+7.4.4 Compiling pest_derive v2.1.0 Compiling sys-info v0.9.1 Checking tonic v0.8.3 Checking json5 v0.4.1 Checking spl-memo v3.0.1 Checking spl-token v3.5.0 Checking jsonrpc-client-transports v18.0.0 Checking tokio-rustls v0.22.0 Compiling tonic-build v0.6.2 Checking jsonrpc-core-client v18.0.0 Compiling solana-core v1.16.0 (/Users/brooks/work/solana/core) Checking tonic v0.6.2 Checking rolling-file v0.2.0 Checking min-max-heap v1.3.0 Compiling enum-ordinalize v3.1.10 Checking thread_local v1.1.4 Checking sharded-slab v0.1.4 Compiling etcd-client v0.8.2 Checking solana-zk-token-sdk v1.15.1 Checking opentelemetry v0.17.0 Compiling educe v0.4.18 Compiling tarpc-plugins v0.12.0 Checking tracing-subscriber v0.3.7 Compiling test-case-macros v2.2.2 Checking dashmap v5.2.0 Checking spl-token-2022 v0.6.1 Checking tracing-opentelemetry v0.17.2 Compiling serial_test_derive v0.9.0 Checking pretty-hex v0.3.0 Checking ctrlc v3.2.5 Checking hex v0.4.3 Checking test-case v2.2.2 Checking bytesize v1.1.0 Checking tokio-serde v0.8.0 Checking raptorq v1.7.0 Checking serial_test v0.9.0 Compiling cast v0.2.7 Checking systemstat v0.2.3 Checking spl-associated-token-account v1.1.3 Compiling const_format_proc_macros v0.2.29 Checking rand v0.4.6 Checking thread-scoped v1.0.2 Checking tarpc v0.29.0 Checking linked-hash-map v0.5.4 Checking wait-timeout v0.2.0 Checking yaml-rust v0.4.5 Compiling camino v1.0.9 Compiling signal-hook v0.3.15 Checking const_format v0.2.30 Compiling tikv-jemalloc-sys v0.4.2+5.2.1-patched.2 Checking criterion-stats v0.3.0 Checking serde_yaml v0.8.26 Checking spl-instruction-padding v0.1.0 Checking filedescriptor v0.8.1 Checking csv-core v0.1.10 Compiling doc-comment v0.3.3 Checking predicates-core v1.0.2 Checking gag v1.0.0 Checking cargo-platform v0.1.2 Checking csv v1.2.1 Checking float-cmp v0.9.0 Checking regex-automata v0.1.10 Checking termtree v0.2.3 Checking normalize-line-endings v0.3.0 Checking difflib v0.4.0 Checking cargo_metadata v0.15.4 Checking bstr v1.4.0 Checking predicates-tree v1.0.4 Compiling solana-install v1.16.0 (/Users/brooks/work/solana/install) Checking predicates v2.1.5 Checking pickledb v0.5.1 Checking jsonrpc-ipc-server v18.0.0 Checking fd-lock v3.0.12 Checking assert_cmd v2.0.8 Checking bit-vec v0.6.3 Checking quick-error v1.2.3 Compiling gen-syscall-list v1.16.0 (/Users/brooks/work/solana/programs/bpf_loader/gen-syscall-list) Checking rusty-fork v0.3.0 Checking bit-set v0.5.2 Checking solana-merkle-tree v1.16.0 (/Users/brooks/work/solana/merkle-tree) Checking rand_xorshift v0.3.0 Checking unarray v0.1.4 Checking quick-error v2.0.1 Checking bytecount v0.6.3 Checking utf8-width v0.1.5 Checking proptest v1.1.0 warning: (not a warning) Generating ../../../sdk/sbf/syscalls.txt from ../src/syscalls/mod.rs Checking byte-unit v4.0.19 Checking solana-cargo-test-sbf v1.16.0 (/Users/brooks/work/solana/sdk/cargo-test-sbf) Checking solana-cargo-test-bpf v1.16.0 (/Users/brooks/work/solana/sdk/cargo-test-bpf) Checking solana-measure v1.16.0 (/Users/brooks/work/solana/measure) Checking solana-metrics v1.16.0 (/Users/brooks/work/solana/metrics) Checking solana-zk-token-sdk v1.16.0 (/Users/brooks/work/solana/zk-token-sdk) Checking solana-remote-wallet v1.16.0 (/Users/brooks/work/solana/remote-wallet) Checking solana-banks-interface v1.16.0 (/Users/brooks/work/solana/banks-interface) Checking solana-notifier v1.16.0 (/Users/brooks/work/solana/notifier) Checking solana-bucket-map v1.16.0 (/Users/brooks/work/solana/bucket_map) Checking solana-connection-cache v1.16.0 (/Users/brooks/work/solana/connection-cache) Checking solana-net-utils v1.16.0 (/Users/brooks/work/solana/net-utils) Checking solana-sys-tuner v1.16.0 (/Users/brooks/work/solana/sys-tuner) warning: this is an outer doc comment and does not apply to the parent module or crate --> zk-token-sdk/src/zk_token_proof_instruction.rs:1:1 | 1 | ///! Instructions provided by the ZkToken Proof program | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_doc_comments = note: `#[warn(clippy::suspicious_doc_comments)]` on by default help: use an inner doc comment to document the parent module or crate | 1 | //! Instructions provided by the ZkToken Proof program | Checking tikv-jemallocator v0.4.1 warning: `solana-zk-token-sdk` (lib) generated 1 warning Checking solana-banks-client v1.16.0 (/Users/brooks/work/solana/banks-client) Checking solana-log-analyzer v1.16.0 (/Users/brooks/work/solana/log-analyzer) Checking solana-config-program v1.16.0 (/Users/brooks/work/solana/programs/config) Checking solana-bpf-loader-program v1.16.0 (/Users/brooks/work/solana/programs/bpf_loader) Checking solana-system-program v1.16.0 (/Users/brooks/work/solana/programs/system) Checking solana-zk-token-proof-program v1.16.0 (/Users/brooks/work/solana/programs/zk-token-proof) Checking solana-loader-v3-program v1.16.0 (/Users/brooks/work/solana/programs/loader-v3) Checking solana-compute-budget-program v1.16.0 (/Users/brooks/work/solana/programs/compute-budget) Checking solana-clap-utils v1.16.0 (/Users/brooks/work/solana/clap-utils) Checking solana-streamer v1.16.0 (/Users/brooks/work/solana/streamer) Checking solana-entry v1.16.0 (/Users/brooks/work/solana/entry) warning: failed to automatically apply fixes suggested by rustc to crate `solana_perf` after fixes were automatically applied the compiler reported errors within these files: * perf/src/recycler.rs This likely indicates a bug in either rustc or cargo itself, and we would appreciate a bug report! You're likely to see a number of compiler warnings after this message which cargo attempted to fix but failed. If you could open an issue at https://github.com/rust-lang/rust/issues quoting the full output of this command we'd be very appreciative! Note that you may be able to make some more progress in the near-term fixing code with the `--broken-code` flag The following errors were reported: error[E0382]: borrow of moved value: `recycler` --> perf/src/recycler.rs:212:20 | 206 | let recycler = Recycler::default(); | -------- move occurs because `recycler` has type `recycler::Recycler`, which does not implement the `Copy` trait ... 210 | let recycler2 = recycler; | -------- value moved here 211 | recycler2.recycler.recycle(y); 212 | assert_eq!(recycler.recycler.gc.lock().unwrap().len(), 1); | ^^^^^^^^^^^^^^^^^^^^ value borrowed here after move | = note: borrow occurs due to deref coercion to `recycler::RecyclerX` help: consider cloning the value if the performance cost is acceptable | 210 | let recycler2 = recycler.clone(); | ++++++++ error: aborting due to previous error For more information about this error, try `rustc --explain E0382`. Original diagnostics will follow. Checking solana-clap-v3-utils v1.16.0 (/Users/brooks/work/solana/clap-v3-utils) warning: redundant clone --> perf/src/recycler.rs:210:33 | 210 | let recycler2 = recycler.clone(); | ^^^^^^^^ help: remove this | note: cloned value is neither consumed nor mutated --> perf/src/recycler.rs:210:25 | 210 | let recycler2 = recycler.clone(); | ^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone = note: `#[warn(clippy::redundant_clone)]` on by default warning: `solana-perf` (lib test) generated 1 warning (run `cargo clippy --fix --lib -p solana-perf --tests` to apply 1 suggestion) Checking solana-cli-config v1.16.0 (/Users/brooks/work/solana/cli-config) Checking solana-udp-client v1.16.0 (/Users/brooks/work/solana/udp-client) Checking solana-poh-bench v1.16.0 (/Users/brooks/work/solana/poh-bench) Checking solana-bench-streamer v1.16.0 (/Users/brooks/work/solana/bench-streamer) Checking solana-faucet v1.16.0 (/Users/brooks/work/solana/faucet) Checking solana-keygen v1.16.0 (/Users/brooks/work/solana/keygen) Checking solana-upload-perf v1.16.0 (/Users/brooks/work/solana/upload-perf) Checking solana-cargo-build-bpf v1.16.0 (/Users/brooks/work/solana/sdk/cargo-build-bpf) warning: `solana-zk-token-sdk` (lib test) generated 1 warning (1 duplicate) Checking solana-net-shaper v1.16.0 (/Users/brooks/work/solana/net-shaper) Checking gen-headers v1.16.0 (/Users/brooks/work/solana/sdk/gen-headers) Checking solana-memory-management v1.16.0 (/Users/brooks/work/solana/memory-management) Checking rbpf-cli v1.16.0 (/Users/brooks/work/solana/rbpf-cli) Checking smpl_jwt v0.7.1 Checking goauth v0.13.1 Checking lz4 v1.24.0 Checking bzip2 v0.4.4 warning: failed to automatically apply fixes suggested by rustc to crate `solana_program` after fixes were automatically applied the compiler reported errors within these files: * /rustc/84dd17b56a931a631a23dfd5ef2018fd3ef49108/library/core/src/macros/mod.rs * sdk/program/src/clock.rs * sdk/program/src/sysvar/fees.rs This likely indicates a bug in either rustc or cargo itself, and we would appreciate a bug report! You're likely to see a number of compiler warnings after this message which cargo attempted to fix but failed. If you could open an issue at https://github.com/rust-lang/rust/issues quoting the full output of this command we'd be very appreciative! Note that you may be able to make some more progress in the near-term fixing code with the `--broken-code` flag The following errors were reported: error[E0382]: borrow of moved value: `clock` --> sdk/program/src/clock.rs:183:9 | 175 | let clock = Clock { | ----- move occurs because `clock` has type `clock::Clock`, which does not implement the `Copy` trait ... 182 | let cloned_clock = clock; | ----- value moved here 183 | assert_eq!(cloned_clock, clock); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ value borrowed here after move | = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider cloning the value if the performance cost is acceptable | 182 | let cloned_clock = clock.clone(); | ++++++++ error[E0382]: borrow of moved value: `fees` --> sdk/program/src/sysvar/fees.rs:68:9 | 62 | let fees = Fees { | ---- move occurs because `fees` has type `sysvar::fees::Fees`, which does not implement the `Copy` trait ... 67 | let cloned_fees = fees; | ---- value moved here 68 | assert_eq!(cloned_fees, fees); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ value borrowed here after move | = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider cloning the value if the performance cost is acceptable | 67 | let cloned_fees = fees.clone(); | ++++++++ error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0382`. Original diagnostics will follow. warning: redundant clone --> sdk/program/src/clock.rs:182:33 | 182 | let cloned_clock = clock.clone(); | ^^^^^^^^ help: remove this | note: cloned value is neither consumed nor mutated --> sdk/program/src/clock.rs:182:28 | 182 | let cloned_clock = clock.clone(); | ^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone = note: `#[warn(clippy::redundant_clone)]` on by default warning: redundant clone --> sdk/program/src/sysvar/fees.rs:67:31 | 67 | let cloned_fees = fees.clone(); | ^^^^^^^^ help: remove this | note: cloned value is neither consumed nor mutated --> sdk/program/src/sysvar/fees.rs:67:27 | 67 | let cloned_fees = fees.clone(); | ^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone Checking zstd v0.11.2+zstd.1.5.2 Checking solana-account-decoder v1.16.0 (/Users/brooks/work/solana/account-decoder) warning: `solana-program` (lib test) generated 2 warnings (run `cargo clippy --fix --lib -p solana-program --tests` to apply 2 suggestions) Checking solana-transaction-status v1.16.0 (/Users/brooks/work/solana/transaction-status) Checking solana-download-utils v1.16.0 (/Users/brooks/work/solana/download-utils) warning: failed to automatically apply fixes suggested by rustc to crate `solana_runtime` after fixes were automatically applied the compiler reported errors within these files: * runtime/src/accounts_hash.rs * runtime/src/bank/tests.rs * runtime/src/stake_history.rs This likely indicates a bug in either rustc or cargo itself, and we would appreciate a bug report! You're likely to see a number of compiler warnings after this message which cargo attempted to fix but failed. If you could open an issue at https://github.com/rust-lang/rust/issues quoting the full output of this command we'd be very appreciative! Note that you may be able to make some more progress in the near-term fixing code with the `--broken-code` flag The following errors were reported: error[E0382]: borrow of moved value: `hashes` --> runtime/src/accounts_hash.rs:1764:13 | 1759 | fn test_hashing(hashes: Vec, fanout: usize) -> Hash { | ------ move occurs because `hashes` has type `std::vec::Vec`, which does not implement the `Copy` trait ... 1762 | let reduced: Vec<_> = hashes; | ------ value moved here 1763 | let result2 = AccountsHasher::compute_merkle_root_from_slices( 1764 | hashes.len(), | ^^^^^^^^^^^^ value borrowed here after move | help: consider cloning the value if the performance cost is acceptable | 1762 | let reduced: Vec<_> = hashes.clone(); | ++++++++ error[E0382]: borrow of moved value: `bank0` --> runtime/src/bank/tests.rs:9111:21 | 9101 | |bank0, | ----- move occurs because `bank0` has type `std::sync::Arc`, which does not implement the `Copy` trait ... 9107 | let mut prev_bank = bank0; | ----- value moved here ... 9111 | bank0.clone(), | ^^^^^^^^^^^^^ value borrowed here after move error[E0382]: borrow of moved value: `stake_history` --> runtime/src/stake_history.rs:55:29 | 43 | let mut stake_history = StakeHistory::default(); | ----------------- move occurs because `stake_history` has type `stake_history::StakeHistory`, which does not implement the `Copy` trait ... 52 | let stake_history2 = stake_history; | ------------- value moved here ... 55 | Arc::ptr_eq(&stake_history.0, &stake_history2.0), | ^^^^^^^^^^^^^^^^ value borrowed here after move | help: consider cloning the value if the performance cost is acceptable | 52 | let stake_history2 = stake_history.clone(); | ++++++++ error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0382`. Original diagnostics will follow. Checking solana-rpc-client-api v1.16.0 (/Users/brooks/work/solana/rpc-client-api) Checking solana-geyser-plugin-interface v1.16.0 (/Users/brooks/work/solana/geyser-plugin-interface) Checking solana-cargo-build-sbf v1.16.0 (/Users/brooks/work/solana/sdk/cargo-build-sbf) Compiling solana-storage-proto v1.16.0 (/Users/brooks/work/solana/storage-proto) Checking proto v1.16.0 (/Users/brooks/work/solana/storage-bigtable/build-proto) Checking solana-merkle-root-bench v1.16.0 (/Users/brooks/work/solana/merkle-root-bench) warning: redundant clone --> runtime/src/accounts.rs:2989:46 | 2989 | let counter_clone = counter_clone.clone(); | ^^^^^^^^ help: remove this | note: cloned value is neither consumed nor mutated --> runtime/src/accounts.rs:2989:33 | 2989 | let counter_clone = counter_clone.clone(); | ^^^^^^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone = note: `#[warn(clippy::redundant_clone)]` on by default warning: redundant clone --> runtime/src/accounts.rs:2990:40 | 2990 | let exit_clone = exit_clone.clone(); | ^^^^^^^^ help: remove this | note: cloned value is neither consumed nor mutated --> runtime/src/accounts.rs:2990:30 | 2990 | let exit_clone = exit_clone.clone(); | ^^^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone warning: redundant clone --> runtime/src/accounts_hash.rs:1762:37 | 1762 | let reduced: Vec<_> = hashes.clone(); | ^^^^^^^^ help: remove this | note: cloned value is neither consumed nor mutated --> runtime/src/accounts_hash.rs:1762:31 | 1762 | let reduced: Vec<_> = hashes.clone(); | ^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone warning: redundant clone --> runtime/src/bank/tests.rs:9107:38 | 9107 | let mut prev_bank = bank0.clone(); | ^^^^^^^^ help: remove this | note: cloned value is neither consumed nor mutated --> runtime/src/bank/tests.rs:9107:33 | 9107 | let mut prev_bank = bank0.clone(); | ^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone Checking solana-accounts-bench v1.16.0 (/Users/brooks/work/solana/accounts-bench) Checking solana-store-tool v1.16.0 (/Users/brooks/work/solana/runtime/store-tool) Checking solana-rpc-client v1.16.0 (/Users/brooks/work/solana/rpc-client) warning: redundant clone --> runtime/src/stake_history.rs:52:47 | 52 | let stake_history2 = stake_history.clone(); | ^^^^^^^^ help: remove this | note: cloned value is neither consumed nor mutated --> runtime/src/stake_history.rs:52:34 | 52 | let stake_history2 = stake_history.clone(); | ^^^^^^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone Checking solana-pubsub-client v1.16.0 (/Users/brooks/work/solana/pubsub-client) Checking solana-quic-client v1.16.0 (/Users/brooks/work/solana/quic-client) warning: `solana-runtime` (lib test) generated 5 warnings (run `cargo clippy --fix --lib -p solana-runtime --tests` to apply 5 suggestions) Checking solana-cli-output v1.16.0 (/Users/brooks/work/solana/cli-output) Checking solana-thin-client v1.16.0 (/Users/brooks/work/solana/thin-client) Checking solana-tpu-client v1.16.0 (/Users/brooks/work/solana/tpu-client) Checking solana-rpc-client-nonce-utils v1.16.0 (/Users/brooks/work/solana/rpc-client-nonce-utils) Checking solana-genesis-utils v1.16.0 (/Users/brooks/work/solana/genesis-utils) Checking solana-tokens v1.16.0 (/Users/brooks/work/solana/tokens) Checking solana-watchtower v1.16.0 (/Users/brooks/work/solana/watchtower) Checking solana-storage-bigtable v1.16.0 (/Users/brooks/work/solana/storage-bigtable) Building [===================> ] 1036/1167: solana-install(test), solana-rpc-client-nonce-utils, solana-tokens, solana-storage-bigtable, librocksdb-sys(build), solana-watchtower(bin test), solana_genesis_utils(test), quic_client(test), solana-tpu-client, solana-genesis-utils, solana-tpu-client(test), solana-install, solana_storage_bigtable(test) Checking solana-client v1.16.0 (/Users/brooks/work/solana/client) Checking solana-stake-accounts v1.16.0 (/Users/brooks/work/solana/stake-accounts) Checking solana-send-transaction-service v1.16.0 (/Users/brooks/work/solana/send-transaction-service) Checking solana-cli v1.16.0 (/Users/brooks/work/solana/cli) Checking solana-banks-server v1.16.0 (/Users/brooks/work/solana/banks-server) warning: failed to automatically apply fixes suggested by rustc to crate `solana_cli` after fixes were automatically applied the compiler reported errors within these files: * cli/src/cluster_query.rs * cli/src/wallet.rs This likely indicates a bug in either rustc or cargo itself, and we would appreciate a bug report! You're likely to see a number of compiler warnings after this message which cargo attempted to fix but failed. If you could open an issue at https://github.com/rust-lang/rust/issues quoting the full output of this command we'd be very appreciative! Note that you may be able to make some more progress in the near-term fixing code with the `--broken-code` flag The following errors were reported: error[E0382]: borrow of partially moved value: `cli_epoch_info` --> cli/src/cluster_query.rs:1145:46 | 1112 | let epoch_info = cli_epoch_info.epoch_info; | ------------------------- value partially moved here ... 1145 | Ok(config.output_format.formatted_string(&cli_epoch_info)) | ^^^^^^^^^^^^^^^ value borrowed here after partial move | = note: partial move occurs because `cli_epoch_info.epoch_info` has type `solana_sdk::epoch_info::EpochInfo`, which does not implement the `Copy` trait error[E0382]: borrow of partially moved value: `account` --> cli/src/wallet.rs:655:55 | 654 | let data = account.data; | ------------ value partially moved here 655 | let cli_account = CliAccount::new(account_pubkey, &account, use_lamports_unit); | ^^^^^^^^ value borrowed here after partial move | = note: partial move occurs because `account.data` has type `std::vec::Vec`, which does not implement the `Copy` trait error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0382`. Original diagnostics will follow. Checking solana-program-test v1.16.0 (/Users/brooks/work/solana/program-test) warning: redundant clone --> cli/src/cluster_query.rs:1112:55 | 1112 | let epoch_info = cli_epoch_info.epoch_info.clone(); | ^^^^^^^^ help: remove this | note: cloned value is neither consumed nor mutated --> cli/src/cluster_query.rs:1112:30 | 1112 | let epoch_info = cli_epoch_info.epoch_info.clone(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone = note: `#[warn(clippy::redundant_clone)]` on by default warning: redundant clone --> cli/src/wallet.rs:654:28 | 654 | let data = account.data.clone(); | ^^^^^^^^ help: remove this | note: cloned value is neither consumed nor mutated --> cli/src/wallet.rs:654:16 | 654 | let data = account.data.clone(); | ^^^^^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone warning: `solana-cli` (lib) generated 2 warnings (run `cargo clippy --fix --lib -p solana-cli` to apply 2 suggestions) Checking solana-address-lookup-table-program-tests v1.16.0 (/Users/brooks/work/solana/programs/address-lookup-table-tests) Checking solana-zk-token-proof-program-tests v1.16.0 (/Users/brooks/work/solana/programs/zk-token-proof-tests) Checking solana-ed25519-program-tests v1.16.0 (/Users/brooks/work/solana/programs/ed25519-tests) Checking solana-bpf-loader-program-tests v1.16.0 (/Users/brooks/work/solana/programs/bpf-loader-tests) Checking rocksdb v0.19.0 Checking solana-poh v1.16.0 (/Users/brooks/work/solana/poh) Checking solana-genesis v1.16.0 (/Users/brooks/work/solana/genesis) warning: failed to automatically apply fixes suggested by rustc to crate `solana_ledger` after fixes were automatically applied the compiler reported errors within these files: * ledger/src/shred/legacy.rs This likely indicates a bug in either rustc or cargo itself, and we would appreciate a bug report! You're likely to see a number of compiler warnings after this message which cargo attempted to fix but failed. If you could open an issue at https://github.com/rust-lang/rust/issues quoting the full output of this command we'd be very appreciative! Note that you may be able to make some more progress in the near-term fixing code with the `--broken-code` flag The following errors were reported: error[E0382]: use of moved value: `shred` --> ledger/src/shred/legacy.rs:370:29 | 341 | let mut shred = ShredData::new_from_data( | --------- move occurs because `shred` has type `shred::legacy::ShredData`, which does not implement the `Copy` trait ... 359 | let mut shred = shred; | ----- value moved here ... 370 | let mut shred = shred; | ^^^^^ value used here after move | help: consider cloning the value if the performance cost is acceptable | 359 | let mut shred = shred.clone(); | ++++++++ error[E0382]: use of moved value: `shred` --> ledger/src/shred/legacy.rs:381:29 | 341 | let mut shred = ShredData::new_from_data( | --------- move occurs because `shred` has type `shred::legacy::ShredData`, which does not implement the `Copy` trait ... 370 | let mut shred = shred; | ----- value moved here ... 381 | let mut shred = shred; | ^^^^^ value used here after move | help: consider cloning the value if the performance cost is acceptable | 370 | let mut shred = shred.clone(); | ++++++++ error[E0382]: assign to part of moved value: `shred` --> ledger/src/shred/legacy.rs:398:13 | 341 | let mut shred = ShredData::new_from_data( | --------- move occurs because `shred` has type `shred::legacy::ShredData`, which does not implement the `Copy` trait ... 381 | let mut shred = shred; | ----- value moved here ... 398 | shred.data_header.size = shred.payload().len() as u16 + 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ value partially assigned here after move | help: consider cloning the value if the performance cost is acceptable | 381 | let mut shred = shred.clone(); | ++++++++ error[E0382]: use of moved value: `shred` --> ledger/src/shred/legacy.rs:441:29 | 411 | let mut shred = ShredCode::new_from_parity_shard( | --------- move occurs because `shred` has type `shred::legacy::ShredCode`, which does not implement the `Copy` trait ... 433 | let mut shred = shred; | ----- value moved here ... 441 | let mut shred = shred; | ^^^^^ value used here after move | help: consider cloning the value if the performance cost is acceptable | 433 | let mut shred = shred.clone(); | ++++++++ error[E0382]: use of moved value: `shred` --> ledger/src/shred/legacy.rs:450:29 | 411 | let mut shred = ShredCode::new_from_parity_shard( | --------- move occurs because `shred` has type `shred::legacy::ShredCode`, which does not implement the `Copy` trait ... 441 | let mut shred = shred; | ----- value moved here ... 450 | let mut shred = shred; | ^^^^^ value used here after move | help: consider cloning the value if the performance cost is acceptable | 441 | let mut shred = shred.clone(); | ++++++++ error[E0382]: use of moved value: `shred` --> ledger/src/shred/legacy.rs:461:29 | 411 | let mut shred = ShredCode::new_from_parity_shard( | --------- move occurs because `shred` has type `shred::legacy::ShredCode`, which does not implement the `Copy` trait ... 450 | let mut shred = shred; | ----- value moved here ... 461 | let mut shred = shred; | ^^^^^ value used here after move | help: consider cloning the value if the performance cost is acceptable | 450 | let mut shred = shred.clone(); | ++++++++ error[E0382]: assign to part of moved value: `shred` --> ledger/src/shred/legacy.rs:482:13 | 411 | let mut shred = ShredCode::new_from_parity_shard( | --------- move occurs because `shred` has type `shred::legacy::ShredCode`, which does not implement the `Copy` trait ... 461 | let mut shred = shred; | ----- value moved here ... 482 | shred.coding_header.num_coding_shreds = u16::MAX; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ value partially assigned here after move | help: consider cloning the value if the performance cost is acceptable | 461 | let mut shred = shred.clone(); | ++++++++ error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0382`. Original diagnostics will follow. warning: redundant clone --> ledger/src/shred/legacy.rs:359:34 | 359 | let mut shred = shred.clone(); | ^^^^^^^^ help: remove this | note: cloned value is neither consumed nor mutated --> ledger/src/shred/legacy.rs:359:29 | 359 | let mut shred = shred.clone(); | ^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone = note: `#[warn(clippy::redundant_clone)]` on by default warning: redundant clone --> ledger/src/shred/legacy.rs:370:34 | 370 | let mut shred = shred.clone(); | ^^^^^^^^ help: remove this | note: cloned value is neither consumed nor mutated --> ledger/src/shred/legacy.rs:370:29 | 370 | let mut shred = shred.clone(); | ^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone warning: redundant clone --> ledger/src/shred/legacy.rs:381:34 | 381 | let mut shred = shred.clone(); | ^^^^^^^^ help: remove this | note: cloned value is neither consumed nor mutated --> ledger/src/shred/legacy.rs:381:29 | 381 | let mut shred = shred.clone(); | ^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone warning: redundant clone --> ledger/src/shred/legacy.rs:433:34 | 433 | let mut shred = shred.clone(); | ^^^^^^^^ help: remove this | note: cloned value is neither consumed nor mutated --> ledger/src/shred/legacy.rs:433:29 | 433 | let mut shred = shred.clone(); | ^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone warning: redundant clone --> ledger/src/shred/legacy.rs:441:34 | 441 | let mut shred = shred.clone(); | ^^^^^^^^ help: remove this | note: cloned value is neither consumed nor mutated --> ledger/src/shred/legacy.rs:441:29 | 441 | let mut shred = shred.clone(); | ^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone warning: redundant clone --> ledger/src/shred/legacy.rs:450:34 | 450 | let mut shred = shred.clone(); | ^^^^^^^^ help: remove this | note: cloned value is neither consumed nor mutated --> ledger/src/shred/legacy.rs:450:29 | 450 | let mut shred = shred.clone(); | ^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone warning: redundant clone --> ledger/src/shred/legacy.rs:461:34 | 461 | let mut shred = shred.clone(); | ^^^^^^^^ help: remove this | note: cloned value is neither consumed nor mutated --> ledger/src/shred/legacy.rs:461:29 | 461 | let mut shred = shred.clone(); | ^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone warning: `solana-ledger` (lib test) generated 7 warnings (run `cargo clippy --fix --lib -p solana-ledger --tests` to apply 7 suggestions) Checking solana-rpc v1.16.0 (/Users/brooks/work/solana/rpc) Checking solana-geyser-plugin-manager v1.16.0 (/Users/brooks/work/solana/geyser-plugin-manager) Fixed core/src/broadcast_stage/broadcast_fake_shreds_run.rs (1 fix) Checking solana-test-validator v1.16.0 (/Users/brooks/work/solana/test-validator) Checking solana-local-cluster v1.16.0 (/Users/brooks/work/solana/local-cluster) Checking solana-bench-tps v1.16.0 (/Users/brooks/work/solana/bench-tps) Checking solana-ledger-tool v1.16.0 (/Users/brooks/work/solana/ledger-tool) Checking solana-banking-bench v1.16.0 (/Users/brooks/work/solana/banking-bench) Checking solana-validator v1.16.0 (/Users/brooks/work/solana/validator) Checking solana-dos v1.16.0 (/Users/brooks/work/solana/dos) Fixed core/src/broadcast_stage.rs (1 fix) Fixed ledger-tool/src/args.rs (1 fix) Checking solana-rpc-test v1.16.0 (/Users/brooks/work/solana/rpc-test) Checking solana-accounts-cluster-bench v1.16.0 (/Users/brooks/work/solana/accounts-cluster-bench) Checking solana-client-test v1.16.0 (/Users/brooks/work/solana/client-test) Fixed validator/src/main.rs (8 fixes) Checking solana-transaction-dos v1.16.0 (/Users/brooks/work/solana/transaction-dos) warning: failed to automatically apply fixes suggested by rustc to crate `solana_cli` after fixes were automatically applied the compiler reported errors within these files: * cli/src/cluster_query.rs * cli/src/wallet.rs This likely indicates a bug in either rustc or cargo itself, and we would appreciate a bug report! You're likely to see a number of compiler warnings after this message which cargo attempted to fix but failed. If you could open an issue at https://github.com/rust-lang/rust/issues quoting the full output of this command we'd be very appreciative! Note that you may be able to make some more progress in the near-term fixing code with the `--broken-code` flag The following errors were reported: error[E0382]: borrow of partially moved value: `cli_epoch_info` --> cli/src/cluster_query.rs:1145:46 | 1112 | let epoch_info = cli_epoch_info.epoch_info; | ------------------------- value partially moved here ... 1145 | Ok(config.output_format.formatted_string(&cli_epoch_info)) | ^^^^^^^^^^^^^^^ value borrowed here after partial move | = note: partial move occurs because `cli_epoch_info.epoch_info` has type `solana_sdk::epoch_info::EpochInfo`, which does not implement the `Copy` trait error[E0382]: borrow of partially moved value: `account` --> cli/src/wallet.rs:655:55 | 654 | let data = account.data; | ------------ value partially moved here 655 | let cli_account = CliAccount::new(account_pubkey, &account, use_lamports_unit); | ^^^^^^^^ value borrowed here after partial move | = note: partial move occurs because `account.data` has type `std::vec::Vec`, which does not implement the `Copy` trait error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0382`. Original diagnostics will follow. warning: `solana-cli` (lib test) generated 2 warnings (2 duplicates) Finished dev [unoptimized + debuginfo] target(s) in 11m 59s ❯ ```
ryoqun commented 1 year ago

hey, i created minimal test case:

use std::sync::Arc;

#[derive(Clone)]
struct Account {
    data: Arc<usize>,
}

fn take<T>(_a: &T) {
}

fn main() {
    let account = Account {data: Arc::new(30)};
    let data = account.data.clone();
    take(&account);
    take(&data);
}
$ cargo +nightly-2023-03-16-x86_64-unknown-linux-gnu clippy --fix --allow-dirty -- --deny clippy::redundant_clone
    Checking clippy-redundant-clone v0.1.0 (/home/sol/work/clippy-redundant-clone)
    Finished dev [unoptimized + debuginfo] target(s) in 0.26s

$ cargo +nightly-2023-03-17-x86_64-unknown-linux-gnu clippy --fix --allow-dirty -- --deny clippy::redundant_clone
    Checking clippy-redundant-clone v0.1.0 (/home/sol/work/clippy-redundant-clone)
warning: failed to automatically apply fixes suggested by rustc to crate `clippy_redundant_clone`

after fixes were automatically applied the compiler reported errors within these files:

  * src/main.rs

This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag

The following errors were reported:
error[E0382]: borrow of partially moved value: `account`
  --> src/main.rs:14:10
   |
13 |     let data = account.data;
   |                ------------ value partially moved here
14 |     take(&account);
   |          ^^^^^^^^ value borrowed here after partial move
   |
   = note: partial move occurs because `account.data` has type `std::sync::Arc<usize>`, which does not implement the `Copy` trait

error: aborting due to previous error

For more information about this error, try `rustc --explain E0382`.
Original diagnostics will follow.

warning: redundant clone
  --> src/main.rs:13:28
   |
13 |     let data = account.data.clone();
   |                            ^^^^^^^^ help: remove this
   |
note: cloned value is neither consumed nor mutated
  --> src/main.rs:13:16
   |
13 |     let data = account.data.clone();
   |                ^^^^^^^^^^^^^^^^^^^^
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone
   = note: requested on the command line with `-D clippy::redundant-clone`

warning: `clippy-redundant-clone` (bin "clippy-redundant-clone") generated 1 warning (run `cargo clippy --fix --bin "clippy-redundant-clone"` to apply 1 suggestion)
warning: `clippy-redundant-clone` (bin "clippy-redundant-clone" test) generated 1 warning (1 duplicate)
    Finished dev [unoptimized + debuginfo] target(s) in 0.25s
ryoqun commented 1 year ago

also, i further narrowed down the regression window (thank to the prior work: https://github.com/rust-lang/rust-clippy/issues/10577#issuecomment-1494685235):

so, it looks like the regression window is quite narrow: https://github.com/rust-lang/rust/compare/ab65486...511364e

this is a hunch but i suspect https://github.com/rust-lang/rust/pull/108944 is the culprit, flipping this line: https://github.com/rust-lang/rust-clippy/blob/c4909746add9b34e3f10508ca37b87f5aa96c0b8/clippy_lints/src/redundant_clone.rs#L381

printfn commented 1 year ago

It looks like this bug is now in stable 1.70, I'm getting errors in https://github.com/printfn/fend.

``` error: redundant clone --> core/src/num/biguint.rs:199:34 | 199 | let mut high_guess = self.clone(); | ^^^^^^^^ help: remove this | note: cloned value is neither consumed nor mutated --> core/src/num/biguint.rs:199:30 | 199 | let mut high_guess = self.clone(); | ^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone note: the lint level is defined here --> core/src/lib.rs:2:9 | 2 | #![deny(clippy::all)] | ^^^^^^^^^^^ = note: `#[deny(clippy::redundant_clone)]` implied by `#[deny(clippy::all)]` ```
JarredAllen commented 1 year ago

I'm also seeing this error, with an even simpler minimal test case than was produced above (no need for Arcs): playground

ryoqun commented 1 year ago

yeah, fyi, I confirmed that the root cause is rustc's internal changes (ref: https://github.com/rust-lang/rust/pull/108944#issuecomment-1564451009). hehe, as i guessed in the post, this is getting more attention because now 1.70 is shipped. ;)

according to https://github.com/rust-lang/rust/pull/108944#issuecomment-1564493704, it seems clippy needs to be fixed for its misuse somehow...

fyi, i only bisected as a normal rust community member, currently not actively trying fix the clippy.

foresterre commented 1 year ago

Another instance in indicatif: https://github.com/rust-lang/rust/issues/112227

Excerpt of original output of cargo clippy --fix in https://github.com/console-rs/indicatif/pull/547, which suggested to create an issue here:

Checking indicatif v0.17.4 (C:\foresterre\indicatif)
warning: failed to automatically apply fixes suggested by rustc to crate `multi_autodrop`                                                                                

after fixes were automatically applied the compiler reported errors within these files:

  * tests\multi-autodrop.rs

This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag

indicatif pipeline

I tried this code (can probably be made more minimal):

use std::sync::{atomic::AtomicU32, atomic::Ordering, Arc, Mutex, RwLock};

// Reproduction derived from indicatif::MultiProgress and ProgressBar where this Clippy suggestion was found.
// With Clippy 0.1.71 (2023-06-01 d59363a)
// With Rust 1.70.0

#[derive(Clone)]
struct MultiProgress {
    state: Arc<RwLock<State>>,
}

impl Default for MultiProgress {
    fn default() -> Self {
        Self {
            state: Arc::new(RwLock::new(State)),
        }
    }
}

impl MultiProgress {
    fn add(&self, pb: ProgressBar) -> ProgressBar {
        let state = self.state.write().unwrap();
        drop(state);

        pb.set_remote(self.state.clone());
        pb
    }
}

#[derive(Clone)]
struct ProgressBar {
    value: Arc<AtomicU32>,
    remote: Arc<Mutex<Arc<RwLock<State>>>>,
}

impl Default for ProgressBar {
    fn default() -> Self {
        Self {
            value: Arc::new(AtomicU32::new(0)),
            remote: Arc::new(Mutex::new(Arc::new(RwLock::new(State)))),
        }
    }
}

impl ProgressBar {
    fn set_remote(&self, state: Arc<RwLock<State>>) {
        *self.remote.lock().unwrap() = state;
    }

    fn inc(&self, delta: u32) {
        self.value.fetch_add(delta, Ordering::SeqCst);
    }

    fn reset(&self) {
        self.value.fetch_add(0, Ordering::SeqCst);
    }
}

struct State;

fn main() {
    let pb = {
        let m = MultiProgress::default();
        m.add(ProgressBar::default())
        // m is dropped here
    };

    {
        // Clippy faults here: it suggests to remove the clone.
        let pb2 = pb.clone();
        for _ in 0..10 {
            pb2.inc(1);
        }
    }

    pb.reset();
}

Running cargo clippy:

hecking playground v0.0.1 (/playground)
warning: redundant clone
  --> src/main.rs:70:21
   |
70 |         let pb2 = pb.clone();
   |                     ^^^^^^^^ help: remove this
   |
note: cloned value is neither consumed nor mutated
  --> src/main.rs:70:19
   |
70 |         let pb2 = pb.clone();
   |                   ^^^^^^^^^^
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone
   = note: `#[warn(clippy::redundant_clone)]` on by default

warning: `playground` (bin "playground") generated 1 warning (run `cargo clippy --fix --bin "playground"` to apply 1 suggestion)
    Finished dev [unoptimized + debuginfo] target(s) in 0.42s

When applying the suggestion:

 Checking playground v0.0.1 (/playground)
error[E0382]: borrow of moved value: `pb`
  --> src/main.rs:76:5
   |
62 |     let pb = {
   |         -- move occurs because `pb` has type `ProgressBar`, which does not implement the `Copy` trait
...
70 |         let pb2 = pb;
   |                   -- value moved here
...
76 |     pb.reset();
   |     ^^^^^^^^^^ value borrowed here after move
   |
help: consider cloning the value if the performance cost is acceptable
   |
70 |         let pb2 = pb.clone();
   |                     ++++++++

For more information about this error, try `rustc --explain E0382`.
error: could not compile `playground` (bin "playground") due to previous error

Meta

rustc --version --verbose:

rustc 1.70.0 (90c541806 2023-05-31)
binary: rustc
commit-hash: 90c541806f23a127002de5b4038be731ba1458ca
commit-date: 2023-05-31
host: x86_64-pc-windows-msvc
release: 1.70.0
LLVM version: 16.0.2

cargo clippy --version --verbose:

clippy 0.1.70 (90c54180 2023-05-31)

Extra

Playground Gist Clippy lint

AaronKutch commented 1 year ago

Another set of instances is in my crate awint as of commit https://github.com/AaronKutch/awint/commit/71b35e8f034126d416d435fd718a2a6b95e94c4a (run cargo clippy --no-default-features), the clone isn't redundant because the original var needs to be used for a special trait method call