pub fn try_expand_target_pattern<F, G, H>(
        &mut self,
        target_path: &Rc<Path>,
        source_path: &Rc<Path>,
        root_rustc_type: Ty<'tcx>,
        strong_update: F,
        weak_update: G,
        weak_update_slice: H,
    ) -> bool
    where
        F: Fn(&mut Self, Rc<Path>, Rc<Path>, Ty<'tcx>),
        G: Fn(&mut Self, Rc<Path>, Rc<Path>, Rc<AbstractValue>),
        H: Fn(&mut Self, Rc<Path>, Rc<Path>, Rc<AbstractValue>),
    {
        trace!(
            "try_expand_target_pattern(target_path {:?}, source_path {:?}, root_rustc_type {:?},)",
            target_path,
            source_path,
            root_rustc_type
        );
        if let PathEnum::QualifiedPath {
            ref qualifier,
            ref selector,
            ..
        } = &target_path.value
        {
            match &**selector {
                PathSelector::Index(value) => {
                    if let Expression::CompileTimeConstant(..) = &value.expression {
                        // fall through, the target path is unique
                    } else {
                        weak_update(self, qualifier.clone(), source_path.clone(), value.clone());
                        // fall through
                    }
                }
                PathSelector::Slice(count) => {
                    // if the count is known at this point, expand it like a pattern.
                    if let Expression::CompileTimeConstant(ConstantDomain::U128(val)) =
                        &count.expression
                    {
                        self.expand_slice(
                            qualifier,
                            source_path,
                            root_rustc_type,
                            0,
                            *val as u64,
                            strong_update,
                        );
                        return true;
                    } else {
                        // Any element that that might get assigned to via this slice need to get weakened.
                        // That is, the value has to become a condition based on index < count.
                        weak_update_slice(
                            self,
                            qualifier.clone(),
                            source_path.clone(),
                            count.clone(),
                        )
                        // fall through
                    }
                }
                _ => {
                    // fall through
                }
            }
        }

        // Assigning to a fixed length array is like a pattern
        if let TyKind::Array(_, len) = root_rustc_type.kind() {
            let param_env = self.type_visitor.get_param_env();
            let len = len
                .try_eval_usize(self.tcx, param_env)
                .expect("Array to have constant len");

            self.expand_slice(
                target_path,
                source_path,
                root_rustc_type,
                0,
                len as u64,
                strong_update,
            );
            return true;
        }
        false
    }
/// If target_path is a slice of known size, this amounts to a series of assignments
/// to each, known, slice element. In this case the function returns true.
/// If target_path is a "pattern" that may match one or more other paths in the environment,
/// depending on some unknown value, then these other paths are "weakly" updated to reflect
/// the possibility that this assignment might modify the values that are currently associated
/// with them. In this case the function returns false so that the caller can proceed to
/// also, strongly, update the target_path without treating it as a pattern.
If target_path is a slice of known size, this amounts to a series of assignments
to each, known, slice element. In this case the function returns true.
If target_path is a "pattern" that may match one or more other paths in the environment,
depending on some unknown value, then these other paths are "weakly" updated to reflect
the possibility that this assignment might modify the values that are currently associated
with them. In this case the function returns false so that the caller can proceed to
also, strongly, update the target_path without treating it as a pattern.
If target_path is a slice of known size this amounts to a series of assignments to each known slice element . In this case the function returns true . If target_path is a " pattern " that may match one or more other paths in the environment depending on some unknown value then these other paths are " weakly " updated to reflect the possibility that this assignment might modify the values that are currently associated with them . In this case the function returns false so that the caller can proceed to also strongly update the target_path without treating it as a pattern .
pub fn try_expand_target_pattern<F, G, H>(
        &mut self,
        target_path: &Rc<Path>,
        source_path: &Rc<Path>,
        root_rustc_type: Ty<'tcx>,
        strong_update: F,
        weak_update: G,
        weak_update_slice: H,
    ) -> bool
    where
        F: Fn(&mut Self, Rc<Path>, Rc<Path>, Ty<'tcx>),
        G: Fn(&mut Self, Rc<Path>, Rc<Path>, Rc<AbstractValue>),
        H: Fn(&mut Self, Rc<Path>, Rc<Path>, Rc<AbstractValue>),
    {
        trace!(
            "try_expand_target_pattern(target_path {:?}, source_path {:?}, root_rustc_type {:?},)",
            target_path,
            source_path,
            root_rustc_type
        );
        if let PathEnum::QualifiedPath {
            ref qualifier,
            ref selector,
            ..
        } = &target_path.value
        {
            match &**selector {
                PathSelector::Index(value) => {
                    if let Expression::CompileTimeConstant(..) = &value.expression {
                        // fall through, the target path is unique
                    } else {
                        weak_update(self, qualifier.clone(), source_path.clone(), value.clone());
                        // fall through
                    }
                }
                PathSelector::Slice(count) => {
                    // if the count is known at this point, expand it like a pattern.
                    if let Expression::CompileTimeConstant(ConstantDomain::U128(val)) =
                        &count.expression
                    {
                        self.expand_slice(
                            qualifier,
                            source_path,
                            root_rustc_type,
                            0,
                            *val as u64,
                            strong_update,
                        );
                        return true;
                    } else {
                        // Any element that that might get assigned to via this slice need to get weakened.
                        // That is, the value has to become a condition based on index < count.
                        weak_update_slice(
                            self,
                            qualifier.clone(),
                            source_path.clone(),
                            count.clone(),
                        )
                        // fall through
                    }
                }
                _ => {
                    // fall through
                }
            }
        }
        // Assigning to a fixed length array is like a pattern
        if let TyKind::Array(_, len) = root_rustc_type.kind() {
            let param_env = self.type_visitor.get_param_env();
            let len = len
                .try_eval_usize(self.tcx, param_env)
                .expect("Array to have constant len");
            self.expand_slice(
                target_path,
                source_path,
                root_rustc_type,
                0,
                len as u64,
                strong_update,
            );
            return true;
        }
        false
    }
pub fn try_expand_target_pattern < F , G , H > ( & mut self , target_path : & Rc < Path > , source_path : & Rc < Path > , root_rustc_type : Ty < ' tcx > , strong_update : F , weak_update : G , weak_update_slice : H , ) -> bool where F : Fn ( & mut Self , Rc < Path > , Rc < Path > , Ty < ' tcx > ) , G : Fn ( & mut Self , Rc < Path > , Rc < Path > , Rc < AbstractValue > ) , H : Fn ( & mut Self , Rc < Path > , Rc < Path > , Rc < AbstractValue > ) , { trace ! ( " " target_path source_path root_rustc_type ) ; if let PathEnum :: QualifiedPath { ref qualifier , ref selector , .. } = & target_path . value { match & * * selector { PathSelector :: Index ( value ) => { if let Expression :: CompileTimeConstant ( .. ) = & value . expression { // fall through, the target path is unique } else { weak_update ( self , qualifier . clone ( ) , source_path . clone ( ) , value . clone ( ) ) ; // fall through } } PathSelector :: Slice ( count ) => { // if the count is known at this point, expand it like a pattern. if let Expression :: CompileTimeConstant ( ConstantDomain :: U128 ( val ) ) = & count . expression { self . expand_slice ( qualifier , source_path , root_rustc_type , 0 , * val as u64 , strong_update , ) ; return true ; } else { // Any element that that might get assigned to via this slice need to get weakened. // That is, the value has to become a condition based on index < count. weak_update_slice ( self , qualifier . clone ( ) , source_path . clone ( ) , count . clone ( ) , ) // fall through } } _ => { // fall through } } } // Assigning to a fixed length array is like a pattern if let TyKind :: Array ( _ , len ) = root_rustc_type . kind ( ) { let param_env = self . type_visitor . get_param_env ( ) ; let len = len . try_eval_usize ( self . tcx , param_env ) . expect ( " " ) ; self . expand_slice ( target_path , source_path , root_rustc_type , 0 , len as u64 , strong_update , ) ; return true ; } false }
If target_path is a slice of known size, this amounts to a series of assignments
to each, known, slice element.
If target_path is a slice of known size this amounts to a series of assignments to each known slice element .
&mut self
target_path
&Rc<Path>
source_path
&Rc<Path>
root_rustc_type
Ty<'tcx>
strong_update
F
weak_update
G
weak_update_slice
H
&mut self
target_path
&Rc<Path>
source_path
&Rc<Path>
root_rustc_type
Ty<'tcx>
strong_update
F
weak_update
G
weak_update_slice
H