@@ -4,7 +4,7 @@ use la_arena::{Arena, ArenaMap, Idx, IdxRange, RawIdx};
4
4
use triomphe:: Arc ;
5
5
6
6
use crate :: {
7
- BlockId , ConstBlockId , DefWithBodyId ,
7
+ BlockId , DefWithBodyId ,
8
8
db:: DefDatabase ,
9
9
expr_store:: { Body , ExpressionStore , HygieneId } ,
10
10
hir:: { Binding , BindingId , Expr , ExprId , Item , LabelId , Pat , PatId , Statement } ,
@@ -53,9 +53,7 @@ pub struct ScopeData {
53
53
impl ExprScopes {
54
54
pub ( crate ) fn expr_scopes_query ( db : & dyn DefDatabase , def : DefWithBodyId ) -> Arc < ExprScopes > {
55
55
let body = db. body ( def) ;
56
- let mut scopes = ExprScopes :: new_body ( & body, |const_block| {
57
- db. lookup_intern_anonymous_const ( const_block) . root
58
- } ) ;
56
+ let mut scopes = ExprScopes :: new_body ( & body) ;
59
57
scopes. shrink_to_fit ( ) ;
60
58
Arc :: new ( scopes)
61
59
}
@@ -104,10 +102,7 @@ fn empty_entries(idx: usize) -> IdxRange<ScopeEntry> {
104
102
}
105
103
106
104
impl ExprScopes {
107
- fn new_body (
108
- body : & Body ,
109
- resolve_const_block : impl ( Fn ( ConstBlockId ) -> ExprId ) + Copy ,
110
- ) -> ExprScopes {
105
+ fn new_body ( body : & Body ) -> ExprScopes {
111
106
let mut scopes = ExprScopes {
112
107
scopes : Arena :: default ( ) ,
113
108
scope_entries : Arena :: default ( ) ,
@@ -118,7 +113,7 @@ impl ExprScopes {
118
113
scopes. add_bindings ( body, root, self_param, body. binding_hygiene ( self_param) ) ;
119
114
}
120
115
scopes. add_params_bindings ( body, root, & body. params ) ;
121
- compute_expr_scopes ( body. body_expr , body, & mut scopes, & mut root, resolve_const_block ) ;
116
+ compute_expr_scopes ( body. body_expr , body, & mut scopes, & mut root) ;
122
117
scopes
123
118
}
124
119
@@ -221,23 +216,22 @@ fn compute_block_scopes(
221
216
store : & ExpressionStore ,
222
217
scopes : & mut ExprScopes ,
223
218
scope : & mut ScopeId ,
224
- resolve_const_block : impl ( Fn ( ConstBlockId ) -> ExprId ) + Copy ,
225
219
) {
226
220
for stmt in statements {
227
221
match stmt {
228
222
Statement :: Let { pat, initializer, else_branch, .. } => {
229
223
if let Some ( expr) = initializer {
230
- compute_expr_scopes ( * expr, store, scopes, scope, resolve_const_block ) ;
224
+ compute_expr_scopes ( * expr, store, scopes, scope) ;
231
225
}
232
226
if let Some ( expr) = else_branch {
233
- compute_expr_scopes ( * expr, store, scopes, scope, resolve_const_block ) ;
227
+ compute_expr_scopes ( * expr, store, scopes, scope) ;
234
228
}
235
229
236
230
* scope = scopes. new_scope ( * scope) ;
237
231
scopes. add_pat_bindings ( store, * scope, * pat) ;
238
232
}
239
233
Statement :: Expr { expr, .. } => {
240
- compute_expr_scopes ( * expr, store, scopes, scope, resolve_const_block ) ;
234
+ compute_expr_scopes ( * expr, store, scopes, scope) ;
241
235
}
242
236
Statement :: Item ( Item :: MacroDef ( macro_id) ) => {
243
237
* scope = scopes. new_macro_def_scope ( * scope, macro_id. clone ( ) ) ;
@@ -246,7 +240,7 @@ fn compute_block_scopes(
246
240
}
247
241
}
248
242
if let Some ( expr) = tail {
249
- compute_expr_scopes ( expr, store, scopes, scope, resolve_const_block ) ;
243
+ compute_expr_scopes ( expr, store, scopes, scope) ;
250
244
}
251
245
}
252
246
@@ -255,13 +249,12 @@ fn compute_expr_scopes(
255
249
store : & ExpressionStore ,
256
250
scopes : & mut ExprScopes ,
257
251
scope : & mut ScopeId ,
258
- resolve_const_block : impl ( Fn ( ConstBlockId ) -> ExprId ) + Copy ,
259
252
) {
260
253
let make_label =
261
254
|label : & Option < LabelId > | label. map ( |label| ( label, store. labels [ label] . name . clone ( ) ) ) ;
262
255
263
256
let compute_expr_scopes = |scopes : & mut ExprScopes , expr : ExprId , scope : & mut ScopeId | {
264
- compute_expr_scopes ( expr, store, scopes, scope, resolve_const_block )
257
+ compute_expr_scopes ( expr, store, scopes, scope)
265
258
} ;
266
259
267
260
scopes. set_scope ( expr, * scope) ;
@@ -271,7 +264,7 @@ fn compute_expr_scopes(
271
264
// Overwrite the old scope for the block expr, so that every block scope can be found
272
265
// via the block itself (important for blocks that only contain items, no expressions).
273
266
scopes. set_scope ( expr, scope) ;
274
- compute_block_scopes ( statements, * tail, store, scopes, & mut scope, resolve_const_block ) ;
267
+ compute_block_scopes ( statements, * tail, store, scopes, & mut scope) ;
275
268
}
276
269
Expr :: Const ( id) => {
277
270
let mut scope = scopes. root_scope ( ) ;
@@ -282,7 +275,7 @@ fn compute_expr_scopes(
282
275
// Overwrite the old scope for the block expr, so that every block scope can be found
283
276
// via the block itself (important for blocks that only contain items, no expressions).
284
277
scopes. set_scope ( expr, scope) ;
285
- compute_block_scopes ( statements, * tail, store, scopes, & mut scope, resolve_const_block ) ;
278
+ compute_block_scopes ( statements, * tail, store, scopes, & mut scope) ;
286
279
}
287
280
Expr :: Loop { body : body_expr, label } => {
288
281
let mut scope = scopes. new_labeled_scope ( * scope, make_label ( label) ) ;
0 commit comments