`E0716` suggests `binding` on 1st assign, rather than merge
Open
Nobody has claimed this yet.
A-diagnostics
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
#[allow(unused)]
fn main() {
let x = 0;
let y;
y = &&x;
println!("{y}");
}
Current output
Compiling playground v0.0.1 (/playground)
error[E0716]: temporary value dropped while borrowed
--> src/main.rs:5:10
|
5 | y = &&x;
| ^^- temporary value is freed at the end of this statement
| |
| creates a temporary value which is freed while still in use
6 | println!("{y}");
| --- borrow later used here
|
help: consider using a `let` binding to create a longer lived value
|
5 ~ let binding = &x;
6 ~ y = &binding;
|
For more information about this error, try `rustc --explain E0716`.
error: could not compile `playground` (bin "playground") due to 1 previous error
Desired output
Compiling playground v0.0.1 (/playground)
error[E0716]: temporary value dropped while borrowed
--> src/main.rs:5:10
|
5 | y = &&x;
| ^^- temporary value is freed at the end of this statement
| |
| creates a temporary value which is freed while still in use
6 | println!("{y}");
| --- borrow later used here
|
help: consider using a `let` binding to create a longer lived value
|
4 ~ let y = &&x;
|
For more information about this error, try `rustc --explain E0716`.
error: could not compile `playground` (bin "playground") due to 1 previous error
Rationale and extra context
In "Desired output" IDK what's the proper notation to express "delete line 5"
Other cases
No response
Rust Version
Playground
1.79.0-nightly
2024-04-21
fb898629a26e4acec59c
Anything else?
https://github.com/rust-lang/rust/issues/99430#issuecomment-2071134933
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the E0716 diagnostic with the Rust Playground example and compare the current and desired suggestions. Trace the compiler's E0716 help output and adjust it so the suggested change merges the assignment into let y = &&x;; done means the diagnostic matches the desired output without suggesting a binding variable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100