Checking rosc v0.6.0 (/home/alinz/code/rosc)
warning: failed to automatically apply fixes suggested by rustc to crate `rosc`
after fixes were automatically applied the compiler reported errors within these files:
* src/decoder.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[E0597]: `elem_size` does not live long enough
--> src/decoder.rs:121:18
|
119 | / map_parser(
120 | | |input| {
| | ------- value captured here
121 | | take(elem_size)(input).map_err(|_: nom::Err<OscError>| {
| | ^^^^^^^^^ borrowed value does not live long enough
122 | | nom::Err::Error(OscError::BadBundle(
... |
127 | | |input| decode_packet(input, original_input),
128 | | )(input)
| |_____- a temporary with access to the borrow is created here ...
129 | }
| -
| |
| `elem_size` dropped here while still borrowed
| ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `impl FnMut(&[u8])-> std::result::Result<(&[u8], types::OscPacket), nom::Err<errors::OscError>>`
|
= note: the temporary is part of an expression at the end of a block;
consider forcing this temporary to be dropped sooner, before the block's local variables are dropped
help: for example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block
|
119 ~ let x = map_parser(
120 | |input| {
121 | take(elem_size)(input).map_err(|_: nom::Err<OscError>| {
122 | nom::Err::Error(OscError::BadBundle(
123 | "Bundle shorter than expected!".to_string(),
124 | ))
...
error: aborting due to previous error
For more information about this error, try `rustc --explain E0597`.
Original diagnostics will follow.
warning: returning the result of a `let` binding from a block
--> src/decoder.rs:128:5
|
118 | / let result = map_parser(
119 | | |input| {
120 | | take(elem_size)(input).map_err(|_: nom::Err<OscError>| {
121 | | nom::Err::Error(OscError::BadBundle(
... |
126 | | |input| decode_packet(input, original_input),
127 | | )(input);
| |_____________- unnecessary `let` binding
128 | result
| ^^^^^^
|
= note: `#[warn(clippy::let_and_return)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_and_return
help: return the expression directly
|
118 ~
119 ~ map_parser(
120 + |input| {
121 + take(elem_size)(input).map_err(|_: nom::Err<OscError>| {
122 + nom::Err::Error(OscError::BadBundle(
123 + "Bundle shorter than expected!".to_string(),
...
warning: `rosc` (lib) generated 1 warning
warning: `rosc` (lib test) generated 1 warning (1 duplicate)
Finished dev [unoptimized + debuginfo] target(s) in 0.69s
Could you please check if this is still an issue? If so, could you please close this issue and report one over at https://github.com/rust-lang/rust-clippy instead? Thanks!
I tried this code:
I expected to see this happen: That clippy can apply the fixes without generating broken code.
Instead, this happened: Clippy created a lifetime issue and aborted.
Meta
rustc --version --verbose
:Backtrace
``` No backtrace available. ```
Here's the full output of
cargo clippy fix
:This can be reproduced by applying the command to github.com/klingtnet/rosc@apply-clippy-suggestions https://github.com/klingtnet/rosc/compare/apply-clippy-suggestions