Closed
Description
When trying to compile the following code I get an unused variable warning despite the variable is being used:
The current output is:
warning: unused variable: `typ`
--> src/lib.rs:62:17
|
62 | let typ = T::infer_type(self);
| ^^^ help: if this is intentional, prefix it with an underscore: `_typ`
|
= note: `#[warn(unused_variables)]` on by default
Ideally the output should not produce such a warning.
cargo fix
produces the following output:
warning: failed to automatically apply fixes suggested by rustc to crate `rust_playground`
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[E0425]: cannot find value `typ` in this scope
--> src\lib.rs:64:30
|
64 | info.typ.replace(typ);
| ^^^ help: a local variable with a similar name exists: `_typ`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0425`.
Original diagnostics will follow.
warning: unused variable: `typ`
--> src\lib.rs:62:17
|
62 | let typ = T::infer_type(self);
| ^^^ help: if this is intentional, prefix it with an underscore: `_typ`
|
= note: `#[warn(unused_variables)]` on by default
warning: 1 warning emitted
warning: unused variable: `typ`
--> src\lib.rs:62:17
|
62 | let typ = T::infer_type(self);
| ^^^ help: if this is intentional, prefix it with an underscore: `_typ`
|
= note: `#[warn(unused_variables)]` on by default
warning: 1 warning emitted
Finished dev [unoptimized + debuginfo] target(s) in 1.04s