fn add_conditions_to_context(
        &mut self,
        context: &SpecBlockContext,
        loc: &Loc,
        conditions: Vec<Condition>,
        context_properties: PropertyBag,
        error_msg: &str,
    ) {
        for cond in conditions {
            // If this is an invariant on a function decl, transform it into a pair of
            // requires and ensures.
            let derived_conds = match cond {
                Condition {
                    loc,
                    kind: kind @ ConditionKind::Invariant,
                    properties,
                    exp,
                }
                | Condition {
                    loc,
                    kind: kind @ ConditionKind::InvariantModule,
                    properties,
                    exp,
                } if matches!(context, SpecBlockContext::Function(..)) => {
                    let requires_kind = if kind == ConditionKind::InvariantModule {
                        ConditionKind::RequiresModule
                    } else {
                        ConditionKind::Requires
                    };
                    let mut merged_properties = context_properties.clone();
                    merged_properties.extend(properties);
                    vec![
                        Condition {
                            loc: loc.clone(),
                            kind: requires_kind,
                            properties: merged_properties.clone(),
                            exp: exp.clone(),
                        },
                        Condition {
                            loc,
                            kind: ConditionKind::Ensures,
                            properties: merged_properties,
                            exp,
                        },
                    ]
                }
                Condition {
                    loc,
                    kind,
                    properties,
                    exp,
                } => {
                    let mut merged_properties = context_properties.clone();
                    merged_properties.extend(properties);
                    vec![Condition {
                        loc,
                        kind,
                        properties: merged_properties,
                        exp,
                    }]
                }
            };
            for derived_cond in derived_conds {
                if self.check_condition_is_valid(context, loc, &derived_cond.kind, error_msg)
                    && !self
                        .parent
                        .env
                        .is_property_true(&derived_cond.properties, CONDITION_DEACTIVATED_PROP)
                        .unwrap_or(false)
                {
                    self.update_spec(context, |spec| spec.conditions.push(derived_cond));
                }
            }
        }
    }
/// Add the given conditions to the context, after checking whether they are valid in the
/// context. Reports errors for invalid conditions.
Add the given conditions to the context, after checking whether they are valid in the
context. Reports errors for invalid conditions.
Add the given conditions to the context after checking whether they are valid in the context . Reports errors for invalid conditions .
fn add_conditions_to_context(
        &mut self,
        context: &SpecBlockContext,
        loc: &Loc,
        conditions: Vec<Condition>,
        context_properties: PropertyBag,
        error_msg: &str,
    ) {
        for cond in conditions {
            // If this is an invariant on a function decl, transform it into a pair of
            // requires and ensures.
            let derived_conds = match cond {
                Condition {
                    loc,
                    kind: kind @ ConditionKind::Invariant,
                    properties,
                    exp,
                }
                | Condition {
                    loc,
                    kind: kind @ ConditionKind::InvariantModule,
                    properties,
                    exp,
                } if matches!(context, SpecBlockContext::Function(..)) => {
                    let requires_kind = if kind == ConditionKind::InvariantModule {
                        ConditionKind::RequiresModule
                    } else {
                        ConditionKind::Requires
                    };
                    let mut merged_properties = context_properties.clone();
                    merged_properties.extend(properties);
                    vec![
                        Condition {
                            loc: loc.clone(),
                            kind: requires_kind,
                            properties: merged_properties.clone(),
                            exp: exp.clone(),
                        },
                        Condition {
                            loc,
                            kind: ConditionKind::Ensures,
                            properties: merged_properties,
                            exp,
                        },
                    ]
                }
                Condition {
                    loc,
                    kind,
                    properties,
                    exp,
                } => {
                    let mut merged_properties = context_properties.clone();
                    merged_properties.extend(properties);
                    vec![Condition {
                        loc,
                        kind,
                        properties: merged_properties,
                        exp,
                    }]
                }
            };
            for derived_cond in derived_conds {
                if self.check_condition_is_valid(context, loc, &derived_cond.kind, error_msg)
                    && !self
                        .parent
                        .env
                        .is_property_true(&derived_cond.properties, CONDITION_DEACTIVATED_PROP)
                        .unwrap_or(false)
                {
                    self.update_spec(context, |spec| spec.conditions.push(derived_cond));
                }
            }
        }
    }
fn add_conditions_to_context ( & mut self , context : & SpecBlockContext , loc : & Loc , conditions : Vec < Condition > , context_properties : PropertyBag , error_msg : & str , ) { for cond in conditions { // If this is an invariant on a function decl, transform it into a pair of // requires and ensures. let derived_conds = match cond { Condition { loc , kind : kind @ ConditionKind :: Invariant , properties , exp , } | Condition { loc , kind : kind @ ConditionKind :: InvariantModule , properties , exp , } if matches ! ( context SpecBlockContext Function ( ) ) => { let requires_kind = if kind == ConditionKind :: InvariantModule { ConditionKind :: RequiresModule } else { ConditionKind :: Requires } ; let mut merged_properties = context_properties . clone ( ) ; merged_properties . extend ( properties ) ; vec ! [ Condition { loc loc clone ( ) kind requires_kind properties merged_properties clone ( ) exp exp clone ( ) } Condition { loc kind ConditionKind Ensures properties merged_properties exp } ] } Condition { loc , kind , properties , exp , } => { let mut merged_properties = context_properties . clone ( ) ; merged_properties . extend ( properties ) ; vec ! [ Condition { loc kind properties merged_properties exp } ] } } ; for derived_cond in derived_conds { if self . check_condition_is_valid ( context , loc , & derived_cond . kind , error_msg ) && ! self . parent . env . is_property_true ( & derived_cond . properties , CONDITION_DEACTIVATED_PROP ) . unwrap_or ( false ) { self . update_spec ( context , | spec | spec . conditions . push ( derived_cond ) ) ; } } } }
Add the given conditions to the context, after checking whether they are valid in the
context.
Add the given conditions to the context after checking whether they are valid in the context .
&mut self
context
&SpecBlockContext
loc
&Loc
conditions
Vec<Condition>
context_properties
PropertyBag
error_msg
&str
&mut self
context
&SpecBlockContext
loc
&Loc
conditions
Vec<Condition>
context_properties
PropertyBag
error_msg
&str