/// If source_path is a qualified path with a path selector that is a pattern of some sort
/// then expand the pattern into one more simpler paths and call F(target_path, simpler_path)
/// on each simpler path.
If source_path is a qualified path with a path selector that is a pattern of some sort
then expand the pattern into one more simpler paths and call F(target_path, simpler_path)
on each simpler path.
If source_path is a qualified path with a path selector that is a pattern of some sort then expand the pattern into one more simpler paths and call F ( target_path simpler_path ) on each simpler path .
pub fn try_expand_source_pattern<F>(
        &mut self,
        target_path: &Rc<Path>,
        source_path: &Rc<Path>,
        root_rustc_ty: Ty<'tcx>,
        update: F,
    ) -> bool
    where
        F: Fn(&mut Self, Rc<Path>, Rc<Path>, Ty<'tcx>),
    {
        trace!(
            "try_expand_source_pattern(target_path {:?}, source_path {:?}, root_rustc_ty {:?},)",
            target_path,
            source_path,
            root_rustc_ty
        );
        if let PathEnum::QualifiedPath {
            ref qualifier,
            ref selector,
            ..
        } = &source_path.value
        {
            match **selector {
                PathSelector::ConstantIndex {
                    offset, from_end, ..
                } => {
                    let index = if from_end {
                        let len_value = self.get_len(qualifier.clone());
                        if let AbstractValue {
                            expression: Expression::CompileTimeConstant(ConstantDomain::U128(len)),
                            ..
                        } = len_value.as_ref()
                        {
                            (*len) - u128::from(offset)
                        } else {
                            // can't expand the pattern because the length is not known at this point
                            return false;
                        }
                    } else {
                        u128::from(offset)
                    };
                    let index_val = self.get_u128_const_val(index);
                    let index_path = Path::new_index(qualifier.clone(), index_val)
                        .refine_paths(&self.current_environment, 0);
                    update(self, target_path.clone(), index_path, root_rustc_ty);
                    return true;
                }
                PathSelector::ConstantSlice { from, to, from_end } => {
                    let len_value = self.get_len(qualifier.clone());
                    if let AbstractValue {
                        expression: Expression::CompileTimeConstant(ConstantDomain::U128(len)),
                        ..
                    } = len_value.as_ref()
                    {
                        let to = if from_end {
                            u64::try_from(*len).unwrap() - to
                        } else {
                            to
                        };
                        self.expand_slice(target_path, qualifier, root_rustc_ty, from, to, update);
                        return true;
                    }
                }
                _ => (),
            }
        };
        false
    }
pub fn try_expand_source_pattern < F > ( & mut self , target_path : & Rc < Path > , source_path : & Rc < Path > , root_rustc_ty : Ty < ' tcx > , update : F , ) -> bool where F : Fn ( & mut Self , Rc < Path > , Rc < Path > , Ty < ' tcx > ) , { trace ! ( " " target_path source_path root_rustc_ty ) ; if let PathEnum :: QualifiedPath { ref qualifier , ref selector , .. } = & source_path . value { match * * selector { PathSelector :: ConstantIndex { offset , from_end , .. } => { let index = if from_end { let len_value = self . get_len ( qualifier . clone ( ) ) ; if let AbstractValue { expression : Expression :: CompileTimeConstant ( ConstantDomain :: U128 ( len ) ) , .. } = len_value . as_ref ( ) { ( * len ) - u128 :: from ( offset ) } else { // can't expand the pattern because the length is not known at this point return false ; } } else { u128 :: from ( offset ) } ; let index_val = self . get_u128_const_val ( index ) ; let index_path = Path :: new_index ( qualifier . clone ( ) , index_val ) . refine_paths ( & self . current_environment , 0 ) ; update ( self , target_path . clone ( ) , index_path , root_rustc_ty ) ; return true ; } PathSelector :: ConstantSlice { from , to , from_end } => { let len_value = self . get_len ( qualifier . clone ( ) ) ; if let AbstractValue { expression : Expression :: CompileTimeConstant ( ConstantDomain :: U128 ( len ) ) , .. } = len_value . as_ref ( ) { let to = if from_end { u64 :: try_from ( * len ) . unwrap ( ) - to } else { to } ; self . expand_slice ( target_path , qualifier , root_rustc_ty , from , to , update ) ; return true ; } } _ => ( ) , } } ; false }
If source_path is a qualified path with a path selector that is a pattern of some sort
then expand the pattern into one more simpler paths and call F(target_path, simpler_path)
on each simpler path.
If source_path is a qualified path with a path selector that is a pattern of some sort then expand the pattern into one more simpler paths and call F ( target_path simpler_path ) on each simpler path .
&mut self
target_path
&Rc<Path>
source_path
&Rc<Path>
root_rustc_ty
Ty<'tcx>
update
F