-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied
Description
Summary
When running:
cargo clippy --fix
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
}
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
tabokiesgkoishi
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied