@@ -87,7 +87,7 @@ fn lower_evaluate_expr<'db>(
87
87
88
88
match lowered_expr. as_var_usage ( ctx. ctx , & mut builder) {
89
89
Ok ( lowered_var) => {
90
- ctx. register_var ( var, lowered_var) ;
90
+ ctx. register_var ( var, lowered_var. var_id ) ;
91
91
ctx. pass_builder_to_child ( id, node. next , builder) ;
92
92
Ok ( ( ) )
93
93
}
@@ -116,7 +116,7 @@ fn lower_boolean_if<'db>(
116
116
// Finalize the block.
117
117
let match_info = MatchInfo :: Enum ( MatchEnumInfo {
118
118
concrete_enum_id : corelib:: core_bool_enum ( db) ,
119
- input : ctx. vars [ & node. condition_var ] ,
119
+ input : ctx. var_usage ( node. condition_var ) ,
120
120
arms : vec ! [
121
121
MatchArm {
122
122
arm_selector: MatchArmSelector :: VariantId ( corelib:: false_variant( db) ) ,
@@ -179,8 +179,7 @@ fn lower_enum_match<'db>(
179
179
let var_location = flow_control_var. location ( ctx. graph ) ;
180
180
// Create a variable for the variant inner value.
181
181
let variant_var = ctx. ctx . new_var ( VarRequest { ty : var_ty, location : var_location } ) ;
182
- let var_usage = VarUsage { var_id : variant_var, location : var_location } ;
183
- ctx. register_var ( * flow_control_var, var_usage) ;
182
+ ctx. register_var ( * flow_control_var, variant_var) ;
184
183
MatchArm {
185
184
arm_selector : MatchArmSelector :: VariantId ( * concrete_variant) ,
186
185
block_id : ctx. assign_child_block_id ( * variant_node, & builder) ,
@@ -191,7 +190,7 @@ fn lower_enum_match<'db>(
191
190
192
191
let match_info = MatchInfo :: Enum ( MatchEnumInfo {
193
192
concrete_enum_id : node. concrete_enum_id ,
194
- input : ctx. vars [ & node. matched_var ] ,
193
+ input : ctx. var_usage ( node. matched_var ) ,
195
194
arms,
196
195
location : match_location,
197
196
} ) ;
@@ -243,7 +242,7 @@ fn handle_extern_match<'db>(
243
242
// (b) `LoweredExpr::Tuple` of `LoweredExpr::AtVariable`,
244
243
// we can safely unwrap the `as_var_usage` result.
245
244
let var_usage = variant_expr. as_var_usage ( ctx. ctx , & mut child_builder) . unwrap ( ) ;
246
- ctx. register_var ( * flow_control_var, var_usage) ;
245
+ ctx. register_var ( * flow_control_var, var_usage. var_id ) ;
247
246
248
247
let block_id = ctx. register_child_builder ( * variant_node, child_builder) ;
249
248
@@ -290,7 +289,7 @@ fn lower_value_match<'db>(
290
289
let match_info = MatchInfo :: Value ( MatchEnumValue {
291
290
num_of_arms : node. nodes . len ( ) ,
292
291
arms,
293
- input : ctx. vars [ & node. matched_var ] ,
292
+ input : ctx. var_usage ( node. matched_var ) ,
294
293
location : ctx. location ,
295
294
} ) ;
296
295
@@ -310,7 +309,7 @@ fn lower_equals_literal<'db>(
310
309
311
310
let literal_stable_ptr = node. stable_ptr . untyped ( ) ;
312
311
let literal_location = ctx. ctx . get_location ( literal_stable_ptr) ;
313
- let input_var = ctx. vars [ & node. input ] ;
312
+ let input_var = ctx. var_usage ( node. input ) ;
314
313
315
314
// Lower the expression `input_var - literal`.
316
315
let is_equal: VarUsage < ' db > = if node. literal == BigInt :: from ( 0 ) {
@@ -383,7 +382,7 @@ fn lower_bind_var<'db>(
383
382
mut builder : BlockBuilder < ' db > ,
384
383
) -> Maybe < ( ) > {
385
384
let pattern_variable = node. output . get ( ctx. graph ) ;
386
- let var_id = ctx. vars [ & node. input ] . var_id ;
385
+ let var_id = ctx. var_usage ( node. input ) . var_id ;
387
386
388
387
// Override variable location to with the location of the variable in the pattern.
389
388
// TODO(lior): Consider using the location of the first instance of the pattern binding instead
@@ -418,11 +417,11 @@ fn lower_deconstruct<'db>(
418
417
. collect ( ) ;
419
418
420
419
let variable_ids =
421
- generators:: StructDestructure { input : ctx. vars [ & node. input ] , var_reqs : var_requests }
420
+ generators:: StructDestructure { input : ctx. var_usage ( node. input ) , var_reqs : var_requests }
422
421
. add ( ctx. ctx , & mut builder. statements ) ;
423
422
424
423
for ( var_id, output) in zip_eq ( variable_ids, & node. outputs ) {
425
- ctx. register_var ( * output, VarUsage { var_id, location : output . location ( ctx . graph ) } ) ;
424
+ ctx. register_var ( * output, var_id) ;
426
425
}
427
426
428
427
ctx. pass_builder_to_child ( id, node. next , builder) ;
@@ -445,15 +444,15 @@ fn lower_upcast<'db>(
445
444
446
445
let call_result = generators:: Call {
447
446
function,
448
- inputs : vec ! [ ctx. vars [ & node. input] ] ,
447
+ inputs : vec ! [ ctx. var_usage ( node. input) ] ,
449
448
coupon_input : None ,
450
449
extra_ret_tys : vec ! [ ] ,
451
450
ret_tys : vec ! [ output_ty] ,
452
451
location : node. input . location ( ctx. graph ) ,
453
452
}
454
453
. add ( ctx. ctx , & mut builder. statements ) ;
455
454
456
- ctx. register_var ( node. output , call_result. returns . into_iter ( ) . next ( ) . unwrap ( ) ) ;
455
+ ctx. register_var ( node. output , call_result. returns . into_iter ( ) . next ( ) . unwrap ( ) . var_id ) ;
457
456
ctx. pass_builder_to_child ( id, node. next , builder) ;
458
457
Ok ( ( ) )
459
458
}
@@ -480,12 +479,11 @@ fn lower_downcast<'db>(
480
479
// Create the output variable.
481
480
let output_location = node. output . location ( ctx. graph ) ;
482
481
let output_var = ctx. ctx . new_var ( VarRequest { ty : output_ty, location : output_location } ) ;
483
- let var_usage = VarUsage { var_id : output_var, location : output_location } ;
484
- ctx. register_var ( node. output , var_usage) ;
482
+ ctx. register_var ( node. output , output_var) ;
485
483
486
484
let match_info = MatchInfo :: Extern ( MatchExternInfo {
487
485
function : function_id,
488
- inputs : vec ! [ ctx. vars [ & node. input] ] ,
486
+ inputs : vec ! [ ctx. var_usage ( node. input) ] ,
489
487
arms : vec ! [
490
488
MatchArm {
491
489
arm_selector: MatchArmSelector :: VariantId ( corelib:: option_some_variant(
0 commit comments