rust-lang / rust-lang/rust-clippy

clippy bug report

Open
#8,925 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

This is the output of the 'cargo clippy --fix' command:

cargo clippy --fix
Checking equation-solver v0.1.0
warning: failed to automatically apply fixes suggested by rustc to crate equation_solver

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

  • src\lib.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[E0596]: cannot borrow term as mutable, as it is not declared as mutable
--> src\lib.rs:439:42
|
428 | term: Term,
| ---- help: consider changing this to be mutable: mut term
...
439 | let exceptions_in_domain = match term.solve()? {
| ^^^^^^^^^^^^ cannot borrow as mutable

error: aborting due to previous error

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

warning: length comparison to zero
--> src\lib.rs:135:28
|
135 | if nested_terms.len() > 0 {
| ^^^^^^^^^^^^^^^^^^^^^^ help: using !is_empty is clearer and more explicit: !nested_terms.is_empty()
|
= note: #[warn(clippy::len_zero)] on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#len_zero

warning: use of ok_or followed by a function call
--> src\lib.rs:164:26
|
164 | .ok_or(String::from("Equation is missing opening parenthesis"))?;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: ok_or_else(|| String::from("Equation is missing opening parenthesis"))
|
= note: #[warn(clippy::or_fun_call)] on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#or_fun_call

warning: length comparison to zero
--> src\lib.rs:177:12
|
177 | if nested_terms.len() > 0 {
| ^^^^^^^^^^^^^^^^^^^^^^ help: using !is_empty is clearer and more explicit: !nested_terms.is_empty()
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#len_zero

warning: redundant clone
--> src\lib.rs:439:46
|
439 | let exceptions_in_domain = match term.clone().solve()? {
| ^^^^^^^^ help: remove this
|
= note: #[warn(clippy::redundant_clone)] on by default
note: this value is dropped without further use
--> src\lib.rs:439:42
|
439 | let exceptions_in_domain = match term.clone().solve()? {
| ^^^^
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone

warning: redundant closure
--> src\lib.rs:442:22
|
442 | .map(|value| OrderedFloat(value))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: OrderedFloat
|
= note: #[warn(clippy::redundant_closure)] on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure

warning: equation-solver (lib test) generated 5 warnings
warning: failed to automatically apply fixes suggested by rustc to crate equation_solver

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

  • src\lib.rs

This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
428 | term: Term,
| ---- help: consider changing this to be mutable: mut term
...
439 | let exceptions_in_domain = match term.solve()? {
| ^^^^^^^^^^^^ cannot borrow as mutable

error: aborting due to previous error

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

warning: equation-solver (lib) generated 5 warnings (5 duplicates)
Finished dev [unoptimized + debuginfo] target(s) in 8.06s

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the report with cargo clippy --fix using the equation-solver example and inspect src/lib.rs around lines 428-442. Compare the failed rustc fix with the Clippy warnings for lines 135, 164, 177, 439, and 442; done means the command no longer reports the failed automatic fix for this case.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.