Summary
When running:
On https://github.com/ZcashFoundation/zebra/tree/410133435e875336875aab32c338a284470ceab4/zebra-chain
I get an error:
after fixes were automatically applied the compiler reported errors
Lint Name
unnecessary_to_owned
Reproducer
I tried this code:
for mut input in transaction.inputs().to_vec().into_iter() {
// use input and &mut transaction
}
https://github.com/ZcashFoundation/zebra/blob/410133435e875336875aab32c338a284470ceab4/zebra-chain/src/block/arbitrary.rs#L554-L578
I saw this happen:
after fixes were automatically applied the compiler reported errors within these files:
* zebra-chain/src/block/arbitrary.rs
...
The following errors were reported:
error[E0502]: cannot borrow `transaction` as mutable because it is also borrowed as immutable
--> zebra-chain/src/block/arbitrary.rs:559:17
|
554 | for mut input in transaction.inputs().iter().cloned() {
| ------------------------------------
| |
| immutable borrow occurs here
| immutable borrow later used here
...
559 | &mut transaction,
| ^^^^^^^^^^^^^^^^ mutable borrow occurs here
I expected to see this happen:
Either no lint, or a fix that compiles correctly.
Version
rustc 1.59.0-nightly (7abab1efb 2021-12-17)
binary: rustc
commit-hash: 7abab1efb21617ba6845fa86328dffa16cfcf1dc
commit-date: 2021-12-17
host: x86_64-unknown-linux-gnu
release: 1.59.0-nightly
LLVM version: 13.0.0
Additional Labels
@rustbot label +I-suggestion-causes-error
Summary
When running:
On https://github.com/ZcashFoundation/zebra/tree/410133435e875336875aab32c338a284470ceab4/zebra-chain
I get an error:
Lint Name
unnecessary_to_owned
Reproducer
I tried this code:
https://github.com/ZcashFoundation/zebra/blob/410133435e875336875aab32c338a284470ceab4/zebra-chain/src/block/arbitrary.rs#L554-L578
I saw this happen:
I expected to see this happen:
Either no lint, or a fix that compiles correctly.
Version
Additional Labels
@rustbot label +I-suggestion-causes-error