mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 22:31:43 +00:00
Merge #701
701: Minor type inference tweaks r=flodiebold a=marcusklaas Pass down expectation for reference expressions and type the guard in match expressions. I wasn't able to add a test for the former addition because the type variable previously introduced would always resolve to the right type in the things I tried! Co-authored-by: Marcus Klaas de Vries <mail@marcusklaas.nl>
This commit is contained in:
commit
28fdb8d03c
11 changed files with 163 additions and 63 deletions
|
@ -219,7 +219,7 @@ pub use ra_syntax::ast::BinOp as BinaryOp;
|
|||
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||
pub struct MatchArm {
|
||||
pub pats: Vec<PatId>,
|
||||
// guard: Option<ExprId>, // TODO
|
||||
pub guard: Option<ExprId>,
|
||||
pub expr: ExprId,
|
||||
}
|
||||
|
||||
|
@ -515,10 +515,12 @@ impl ExprCollector {
|
|||
MatchArm {
|
||||
pats: vec![pat],
|
||||
expr: then_branch,
|
||||
guard: None,
|
||||
},
|
||||
MatchArm {
|
||||
pats: vec![placeholder_pat],
|
||||
expr: else_branch,
|
||||
guard: None,
|
||||
},
|
||||
];
|
||||
self.alloc_expr(
|
||||
|
@ -617,6 +619,10 @@ impl ExprCollector {
|
|||
.map(|arm| MatchArm {
|
||||
pats: arm.pats().map(|p| self.collect_pat(p)).collect(),
|
||||
expr: self.collect_expr_opt(arm.expr()),
|
||||
guard: arm
|
||||
.guard()
|
||||
.and_then(|guard| guard.expr())
|
||||
.map(|e| self.collect_expr(e)),
|
||||
})
|
||||
.collect()
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue