@@ -87,15 +87,13 @@ impl ExprScopes {
87
87
}
88
88
89
89
fn add_bindings ( & mut self , body : & Body , scope : ScopeId , pat : PatId ) {
90
- match & body[ pat] {
91
- Pat :: Bind { name, .. } => {
92
- // bind can have a sub pattern, but it's actually not allowed
93
- // to bind to things in there
94
- let entry = ScopeEntry { name : name. clone ( ) , pat } ;
95
- self . scopes [ scope] . entries . push ( entry)
96
- }
97
- p => p. walk_child_pats ( |pat| self . add_bindings ( body, scope, pat) ) ,
90
+ let pattern = & body[ pat] ;
91
+ if let Pat :: Bind { name, .. } = pattern {
92
+ let entry = ScopeEntry { name : name. clone ( ) , pat } ;
93
+ self . scopes [ scope] . entries . push ( entry) ;
98
94
}
95
+
96
+ pattern. walk_child_pats ( |pat| self . add_bindings ( body, scope, pat) ) ;
99
97
}
100
98
101
99
fn add_params_bindings ( & mut self , body : & Body , scope : ScopeId , params : & [ PatId ] ) {
@@ -190,8 +188,8 @@ mod tests {
190
188
}
191
189
}
192
190
193
- fn do_check ( code : & str , expected : & [ & str ] ) {
194
- let ( off, code) = extract_offset ( code ) ;
191
+ fn do_check ( ra_fixture : & str , expected : & [ & str ] ) {
192
+ let ( off, code) = extract_offset ( ra_fixture ) ;
195
193
let code = {
196
194
let mut buf = String :: new ( ) ;
197
195
let off: usize = off. into ( ) ;
@@ -300,6 +298,22 @@ mod tests {
300
298
) ;
301
299
}
302
300
301
+ #[ test]
302
+ fn test_bindings_after_at ( ) {
303
+ do_check (
304
+ r"
305
+ fn foo() {
306
+ match Some(()) {
307
+ opt @ Some(unit) => {
308
+ <|>
309
+ }
310
+ _ => {}
311
+ }
312
+ }" ,
313
+ & [ "opt" , "unit" ] ,
314
+ ) ;
315
+ }
316
+
303
317
fn do_check_local_name ( code : & str , expected_offset : u32 ) {
304
318
let ( off, code) = extract_offset ( code) ;
305
319
0 commit comments