diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-02-22 00:27:09 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-02-22 00:27:09 +0000 |
commit | baf832d6d903afbc39e3a01c752a1aa5218c020e (patch) | |
tree | f8d3481c6274e032f166e8c342281216dd24ec0e /crates/ra_hir_ty/src/infer | |
parent | d8b09435357462dccf7f026f568b2cd1dc3ec67a (diff) | |
parent | f1f45f9191d60c52dbedec717aee0de4a0580bcc (diff) |
Merge #3262
3262: Fix handling of const patterns r=matklad a=flodiebold
E.g. in `match x { None => ... }`, `None` is a path pattern (resolving to the
option variant), not a binding. To determine this, we need to try to resolve the
name during lowering. This isn't too hard since we already need to resolve names
for macro expansion anyway (though maybe a bit hacky).
Fixes #1618.
Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_hir_ty/src/infer')
-rw-r--r-- | crates/ra_hir_ty/src/infer/pat.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/crates/ra_hir_ty/src/infer/pat.rs b/crates/ra_hir_ty/src/infer/pat.rs index a495ecbfe..bf8ea192b 100644 --- a/crates/ra_hir_ty/src/infer/pat.rs +++ b/crates/ra_hir_ty/src/infer/pat.rs | |||
@@ -189,7 +189,9 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
189 | }; | 189 | }; |
190 | // use a new type variable if we got Ty::Unknown here | 190 | // use a new type variable if we got Ty::Unknown here |
191 | let ty = self.insert_type_vars_shallow(ty); | 191 | let ty = self.insert_type_vars_shallow(ty); |
192 | self.unify(&ty, expected); | 192 | if !self.unify(&ty, expected) { |
193 | // FIXME record mismatch, we need to change the type of self.type_mismatches for that | ||
194 | } | ||
193 | let ty = self.resolve_ty_as_possible(ty); | 195 | let ty = self.resolve_ty_as_possible(ty); |
194 | self.write_pat_ty(pat, ty.clone()); | 196 | self.write_pat_ty(pat, ty.clone()); |
195 | ty | 197 | ty |