mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 05:45:12 +00:00
Support if let
match guards
This commit is contained in:
parent
4466e07fd7
commit
d568e7686a
10 changed files with 90 additions and 27 deletions
|
@ -8,7 +8,7 @@ use std::{
|
|||
|
||||
use chalk_ir::{cast::Cast, fold::Shift, Mutability, TyVariableKind};
|
||||
use hir_def::{
|
||||
expr::{Array, BinaryOp, Expr, ExprId, Literal, Statement, UnaryOp},
|
||||
expr::{Array, BinaryOp, Expr, ExprId, Literal, MatchGuard, Statement, UnaryOp},
|
||||
path::{GenericArg, GenericArgs},
|
||||
resolver::resolver_for_expr,
|
||||
AssocContainerId, FieldId, Lookup,
|
||||
|
@ -366,12 +366,13 @@ impl<'a> InferenceContext<'a> {
|
|||
for arm in arms {
|
||||
self.diverges = Diverges::Maybe;
|
||||
let _pat_ty = self.infer_pat(arm.pat, &input_ty, BindingMode::default());
|
||||
if let Some(guard_expr) = arm.guard {
|
||||
if let Some(MatchGuard::If { expr: guard_expr }) = arm.guard {
|
||||
self.infer_expr(
|
||||
guard_expr,
|
||||
&Expectation::has_type(TyKind::Scalar(Scalar::Bool).intern(&Interner)),
|
||||
);
|
||||
}
|
||||
// FIXME: infer `if let` guard
|
||||
|
||||
let arm_ty = self.infer_expr_inner(arm.expr, &expected);
|
||||
all_arms_diverge &= self.diverges;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue