@@ -15,7 +15,9 @@ use semantic::{ConcreteTypeId, ExprVarMemberPath, TypeLongId};
1515use super :: context:: { LoweredExpr , LoweringContext , LoweringFlowError , LoweringResult , VarRequest } ;
1616use super :: generators;
1717use super :: generators:: StatementsBuilder ;
18- use super :: refs:: { SemanticLoweringMapping , StructRecomposer , merge_semantics} ;
18+ use super :: refs:: {
19+ SemanticLoweringMapping , StructRecomposer , find_changed_members, merge_semantics,
20+ } ;
1921use crate :: db:: LoweringGroup ;
2022use crate :: diagnostic:: { LoweringDiagnosticKind , LoweringDiagnosticsBuilder } ;
2123use crate :: ids:: LocationId ;
@@ -397,6 +399,15 @@ impl<'db> BlockBuilder<'db> {
397399 closure_info,
398400 )
399401 }
402+
403+ /// Marks the following as changed members:
404+ /// (1) the changed members of `parent_builder`,
405+ /// (2) the members whose value was changed between `parent_builder` and `self`.
406+ pub fn set_changed_member_paths ( & mut self , parent_builder : & Self ) {
407+ self . changed_member_paths . extend ( parent_builder. changed_member_paths . iter ( ) . cloned ( ) ) ;
408+ self . changed_member_paths
409+ . extend ( find_changed_members ( & parent_builder. semantics , & self . semantics ) ) ;
410+ }
400411}
401412
402413impl < ' db > DebugWithDb < ' db > for BlockBuilder < ' db > {
@@ -559,8 +570,9 @@ impl<'db> StructRecomposer<'db> for BlockStructRecomposer<'_, '_, 'db> {
559570/// * Variables mapped to the same lowered variable across all input blocks are kept as-is.
560571/// * Local variables that appear in only a subset of the blocks are removed.
561572/// * Variables with different mappings across blocks are remapped to a new lowered variable.
562- // TODO(lior): Remove `allow(dead_code)` once the function is used.
563- #[ allow( dead_code) ]
573+ ///
574+ /// Note that the returned [BlockBuilder] has an empty [BlockBuilder::changed_member_paths].
575+ /// Use [BlockBuilder::set_changed_member_paths] to set it if necessary.
564576pub fn merge_sealed_block_builders < ' db > (
565577 ctx : & mut LoweringContext < ' db , ' _ > ,
566578 sealed_blocks : Vec < SealedGotoCallsite < ' db > > ,
0 commit comments