@@ -106,7 +106,9 @@ impl ExprScopes {
106106 let mut scopes = ExprScopes {
107107 scopes : Arena :: default ( ) ,
108108 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+ ) ,
110112 } ;
111113 let mut root = scopes. root_scope ( ) ;
112114 if let Some ( self_param) = body. self_param {
@@ -179,7 +181,7 @@ impl ExprScopes {
179181 binding : BindingId ,
180182 hygiene : HygieneId ,
181183 ) {
182- let Binding { name, .. } = & store. bindings [ binding] ;
184+ let Binding { name, .. } = & store[ binding] ;
183185 let entry = self . scope_entries . alloc ( ScopeEntry { name : name. clone ( ) , binding, hygiene } ) ;
184186 self . scopes [ scope] . entries =
185187 IdxRange :: new_inclusive ( self . scopes [ scope] . entries . start ( ) ..=entry) ;
@@ -251,7 +253,7 @@ fn compute_expr_scopes(
251253 scope : & mut ScopeId ,
252254) {
253255 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 ( ) ) ) ;
255257
256258 let compute_expr_scopes = |scopes : & mut ExprScopes , expr : ExprId , scope : & mut ScopeId | {
257259 compute_expr_scopes ( expr, store, scopes, scope)
@@ -534,9 +536,8 @@ fn foo() {
534536 } ;
535537
536538 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 ( ) ;
540541
541542 let local_name = pat_src. value . syntax_node_ptr ( ) . to_node ( file. syntax ( ) ) ;
542543 assert_eq ! ( local_name. text_range( ) , expected_name. syntax( ) . text_range( ) ) ;
0 commit comments