Closed
Description
I wrote code like
let qself_res = if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = qself.kind
&& let [segment] = path.segments
&& kw::SelfUpper = segment.ident.name
{
when I meant
let qself_res = if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = qself.kind
&& let [segment] = path.segments
&& kw::SelfUpper == segment.ident.name
{
and was confused by the rust-analyzer and rustc output:
error: `let` expressions are not supported here
--> compiler/rustc_typeck/src/astconv/mod.rs:1812:48
|
1812 | ... let qself_res = if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = qself.kind
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: only supported directly in conditions of `if` and `while` expressions
= note: as well as when nested within `&&` and parentheses in those conditions
error: `let` expressions are not supported here
--> compiler/rustc_typeck/src/astconv/mod.rs:1813:36
|
1813 | ... && let [segment] = path.segments
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: only supported directly in conditions of `if` and `while` expressions
= note: as well as when nested within `&&` and parentheses in those conditions
error[E0433]: failed to resolve: use of undeclared crate or module `kw`
--> compiler/rustc_typeck/src/astconv/mod.rs:1814:36
|
1814 | ... && kw::SelfUpper = segment.ident.name
| ^^ use of undeclared crate or module `kw`
error[E0308]: mismatched types
--> compiler/rustc_typeck/src/astconv/mod.rs:1812:48
|
1812 | ... let qself_res = if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = qself.kind
| __________________________________________^
1813 | | ... && let [segment] = path.segments
1814 | | ... && kw::SelfUpper = segment.ident.name
| |_______________________________________________________________^ expected `bool`, found `()`
|
help: you might have meant to use pattern matching
|
1812 | let qself_res = if let let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = qself.kind
| +++
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: Too much output caused by a single piece of incorrect code.`#![feature(let_chains)]`Relevant to the compiler team, which will review and decide on the PR/issue.