Closed
Description
Summary
Hi, I'm learning rust. I was not able to identify the issue: Clippy attempted to fix a function but it failed.
It looks similar to #91523.
Lint Name
let_and_return
Reproducer
git clone git@github.com:Mcdostone/kconfig.git
cd kconfig
cargo clippy --fix
Backtrace
cargo clippy --fix --allow-dirty
Checking kconfig v0.1.0
warning: failed to automatically apply fixes suggested by rustc to crate `kconfig`
after fixes were automatically applied the compiler reported errors within these files:
* src/kconfig.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]: `file` does not live long enough
--> src/kconfig.rs:23:19
|
21 | map(delimited(ws_comment, many0(parse_entry), ws_comment), |d| {
| - --- value captured here
| _____|
| |
22 | | Kconfig {
23 | | file: file.display().to_string(), //input.extra.file.display().to_string(),
| | ^^^^ borrowed value does not live long enough
24 | | entries: d,
25 | | //architecture: Noneis_architecture_related(&input.extra.0.clone(), &input.extra.1),
26 | | }
27 | | })(input)
| |______- a temporary with access to the borrow is created here ...
28 | }
| -
| |
| `file` 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(nom_locate::LocatedSpan<&str, KconfigFile>) -> std::result::Result<(nom_locate::LocatedSpan<&str, KconfigFile>, kconfig::Kconfig), nom::Err<nom::error::Error<nom_locate::LocatedSpan<&str, KconfigFile>>>>`
|
= 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
|
21 ~ let x = map(delimited(ws_comment, many0(parse_entry), ws_comment), |d| {
22 | Kconfig {
...
26 | }
27 ~ })(input); x
|
error: aborting due to previous error
For more information about this error, try `rustc --explain E0597`.
Original diagnostics will follow.
Version
rustc 1.70.0 (90c541806 2023-05-31)
binary: rustc
commit-hash: 90c541806f23a127002de5b4038be731ba1458ca
commit-date: 2023-05-31
host: x86_64-unknown-linux-gnu
release: 1.70.0
LLVM version: 16.0.2
Additional Labels
No response