From 44e9a9605b2b3916669182ba091599d59653c497 Mon Sep 17 00:00:00 2001 From: Marcus Klaas de Vries Date: Thu, 17 Jan 2019 13:40:45 +0100 Subject: Fixup annotated bindings --- crates/ra_hir/src/code_model_impl/function/scope.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'crates/ra_hir/src/code_model_impl') diff --git a/crates/ra_hir/src/code_model_impl/function/scope.rs b/crates/ra_hir/src/code_model_impl/function/scope.rs index 7e8eb7704..220c71f74 100644 --- a/crates/ra_hir/src/code_model_impl/function/scope.rs +++ b/crates/ra_hir/src/code_model_impl/function/scope.rs @@ -88,10 +88,17 @@ impl FnScopes { fn add_bindings(&mut self, body: &Body, scope: ScopeId, pat: PatId) { match &body[pat] { - Pat::Bind { name, .. } => self.scopes[scope].entries.push(ScopeEntry { - name: name.clone(), - pat, - }), + Pat::Bind { name, .. } => { + // bind can have a subpattern, but it's actually not allowed + // to bind to things in there + let entry = ScopeEntry { + name: name.clone(), + pat, + }; + self.scopes[scope].entries.push(entry) + } + // FIXME: isn't every call to add_binding starting an entirely new + // tree walk!? p => p.walk_child_pats(|pat| self.add_bindings(body, scope, pat)), } } -- cgit v1.2.3