@@ -106,7 +106,9 @@ impl ExprScopes {
106
106
let mut scopes = ExprScopes {
107
107
scopes : Arena :: default ( ) ,
108
108
scope_entries : Arena :: default ( ) ,
109
- scope_by_expr : ArenaMap :: with_capacity ( body. exprs . len ( ) ) ,
109
+ scope_by_expr : ArenaMap :: with_capacity (
110
+ body. expr_only . as_ref ( ) . map_or ( 0 , |it| it. exprs . len ( ) ) ,
111
+ ) ,
110
112
} ;
111
113
let mut root = scopes. root_scope ( ) ;
112
114
if let Some ( self_param) = body. self_param {
@@ -179,7 +181,7 @@ impl ExprScopes {
179
181
binding : BindingId ,
180
182
hygiene : HygieneId ,
181
183
) {
182
- let Binding { name, .. } = & store. bindings [ binding] ;
184
+ let Binding { name, .. } = & store[ binding] ;
183
185
let entry = self . scope_entries . alloc ( ScopeEntry { name : name. clone ( ) , binding, hygiene } ) ;
184
186
self . scopes [ scope] . entries =
185
187
IdxRange :: new_inclusive ( self . scopes [ scope] . entries . start ( ) ..=entry) ;
@@ -251,7 +253,7 @@ fn compute_expr_scopes(
251
253
scope : & mut ScopeId ,
252
254
) {
253
255
let make_label =
254
- |label : & Option < LabelId > | label. map ( |label| ( label, store. labels [ label] . name . clone ( ) ) ) ;
256
+ |label : & Option < LabelId > | label. map ( |label| ( label, store[ label] . name . clone ( ) ) ) ;
255
257
256
258
let compute_expr_scopes = |scopes : & mut ExprScopes , expr : ExprId , scope : & mut ScopeId | {
257
259
compute_expr_scopes ( expr, store, scopes, scope)
@@ -534,9 +536,8 @@ fn foo() {
534
536
} ;
535
537
536
538
let resolved = scopes. resolve_name_in_scope ( expr_scope, & name_ref. as_name ( ) ) . unwrap ( ) ;
537
- let pat_src = source_map
538
- . pat_syntax ( * source_map. binding_definitions [ resolved. binding ( ) ] . first ( ) . unwrap ( ) )
539
- . unwrap ( ) ;
539
+ let pat_src =
540
+ source_map. pat_syntax ( source_map. patterns_for_binding ( resolved. binding ( ) ) [ 0 ] ) . unwrap ( ) ;
540
541
541
542
let local_name = pat_src. value . syntax_node_ptr ( ) . to_node ( file. syntax ( ) ) ;
542
543
assert_eq ! ( local_name. text_range( ) , expected_name. syntax( ) . text_range( ) ) ;
0 commit comments