fn import_def_id_as_static()

in checker/src/body_visitor.rs [604:708]


    fn import_def_id_as_static(
        &mut self,
        path: &Rc<Path>,
        def_id: Option<DefId>,
        summary_cache_key: &Rc<str>,
    ) {
        let environment_before_call = self.current_environment.clone();
        let saved_analyzing_static_var = self.analyzing_static_var;
        self.analyzing_static_var = true;
        let mut block_visitor;
        let summary;
        let summary = if let Some(def_id) = def_id {
            if self.active_calls_map.contains_key(&def_id) {
                return;
            }
            let generic_args = self.cv.substs_cache.get(&def_id).cloned();
            let callee_generic_argument_map = if let Some(generic_args) = generic_args {
                self.type_visitor()
                    .get_generic_arguments_map(def_id, generic_args, &[])
            } else {
                None
            };
            let ty = self.tcx.type_of(def_id);
            let func_const = self
                .cv
                .constant_value_cache
                .get_function_constant_for(
                    def_id,
                    ty,
                    generic_args,
                    self.tcx,
                    &mut self.cv.known_names_cache,
                    &mut self.cv.summary_cache,
                )
                .clone();
            block_visitor = BlockVisitor::new(self);
            let mut call_visitor = CallVisitor::new(
                &mut block_visitor,
                def_id,
                generic_args,
                callee_generic_argument_map,
                environment_before_call,
                func_const,
            );
            let func_ref = call_visitor
                .callee_func_ref
                .clone()
                .expect("CallVisitor::new should guarantee this");
            let cached_summary = call_visitor
                .block_visitor
                .bv
                .cv
                .summary_cache
                .get_summary_for_call_site(&func_ref, &None, &None);
            if cached_summary.is_computed {
                cached_summary
            } else {
                summary = call_visitor.create_and_cache_function_summary(&None, &None);
                &summary
            }
        } else {
            summary = self
                .cv
                .summary_cache
                .get_persistent_summary_for(summary_cache_key);
            &summary
        };
        if summary.is_computed && !summary.side_effects.is_empty() {
            let side_effects = summary.side_effects.clone();
            checked_assume!(self.fresh_variable_offset <= usize::MAX - 1_000_000); // expect to diverge before a call chain gets this deep
            self.fresh_variable_offset += 1_000_000;
            // Effects on the path
            let environment = self.current_environment.clone();
            self.transfer_and_refine(
                &side_effects,
                path.clone(),
                &Path::new_result(),
                &Some(path.clone()),
                &[],
                &environment,
            );
            // Effects on the heap
            for (path, value) in side_effects.iter() {
                if path.is_rooted_by_non_local_structure() {
                    self.update_value_at(
                        path.refine_parameters_and_paths(
                            &[],
                            &None,
                            &self.current_environment,
                            &self.current_environment,
                            self.fresh_variable_offset,
                        ),
                        value.refine_parameters_and_paths(
                            &[],
                            &None,
                            &self.current_environment,
                            &self.current_environment,
                            self.fresh_variable_offset,
                        ),
                    );
                }
            }
        }
        self.analyzing_static_var = saved_analyzing_static_var;
    }