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