Repository navigation
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: Syntactic analysis / parsing of Rust source code (to an AST) as done by `rustc_parse`D-papercutDiagnostics: An error or lint that needs small tweaks.D-verboseDiagnostics: Too much output caused by a single piece of incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
Description
Given the following code:
fn do_something(opt1: Option<()>, opt2: Option<()>) {
- let a = opt1.map(|_| {
if let Some(_) = opt {
}
});
}https://play.rust-lang.org/?gist=710a6e61334a9cff89667599564d0a42
The current output is:
Compiling playground v0.0.1 (/playground)
error[E0425]: cannot find value `opt` in this scope
--> src/lib.rs:6:26
|
6 | if let Some(_) = opt {
| ^^^ help: a local variable with a similar name exists: `opt1`
error[E0658]: `let` expressions in this position are experimental
--> src/lib.rs:5:5
|
5 | - let a = opt1.map(|_| {
| _____^
6 | | if let Some(_) = opt {
7 | |
8 | | }
9 | | });
| |______^
|
= note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
= help: you can write `matches!(<expr>, <pattern>)` instead of `let <pattern> = <expr>`
error: expected expression, found statement (`let`)
--> src/lib.rs:5:5
|
5 | - let a = opt1.map(|_| {
| _____^
6 | | if let Some(_) = opt {
7 | |
8 | | }
9 | | });
| |______^
|
= note: variable declaration using `let` is a statement
error[E0600]: cannot apply unary operator `-` to type `bool`
--> src/lib.rs:5:1
|
5 | / - let a = opt1.map(|_| {
6 | | if let Some(_) = opt {
7 | |
8 | | }
9 | | });
| |______^ cannot apply unary operator `-`
error: aborting due to 4 previous errorsThe last error is the closest one to the actual error.
I know this looks quite contrived but it actually happened to my twice today (new keyboard haha)
Thanks!
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: Syntactic analysis / parsing of Rust source code (to an AST) as done by `rustc_parse`D-papercutDiagnostics: An error or lint that needs small tweaks.D-verboseDiagnostics: Too much output caused by a single piece of incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
Activity
estebank commentedon Dec 28, 2022
Triage: no change.
estebank commentedon Dec 5, 2024
Current output:
Rollup merge of rust-lang#164920 - estebank:issue-87291, r=wesleywiser
Rollup merge of rust-lang#164920 - estebank:issue-87291, r=wesleywiser
Rollup merge of rust-lang#164920 - estebank:issue-87291, r=wesleywiser
Rollup merge of rust-lang#164920 - estebank:issue-87291, r=wesleywiser
Rollup merge of rust-lang#164920 - estebank:issue-87291, r=wesleywiser
Rollup merge of rust-lang#164920 - estebank:issue-87291, r=wesleywiser
Unrolled build for #164920 in rollup 165234
Rollup merge of #164920 - estebank:issue-87291, r=wesleywiser