mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Support let...else
This commit is contained in:
parent
4675410f07
commit
f8acae7895
13 changed files with 162 additions and 8 deletions
|
@ -914,7 +914,7 @@ impl<'a> InferenceContext<'a> {
|
|||
) -> Ty {
|
||||
for stmt in statements {
|
||||
match stmt {
|
||||
Statement::Let { pat, type_ref, initializer } => {
|
||||
Statement::Let { pat, type_ref, initializer, else_branch } => {
|
||||
let decl_ty = type_ref
|
||||
.as_ref()
|
||||
.map(|tr| self.make_ty(tr))
|
||||
|
@ -931,6 +931,13 @@ impl<'a> InferenceContext<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
if let Some(expr) = else_branch {
|
||||
self.infer_expr_coerce(
|
||||
*expr,
|
||||
&Expectation::has_type(Ty::new(&Interner, TyKind::Never)),
|
||||
);
|
||||
}
|
||||
|
||||
self.infer_pat(*pat, &ty, BindingMode::default());
|
||||
}
|
||||
Statement::Expr { expr, .. } => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue