rem_repairer/
repair_lifetime_simple.rs

1use std::fs;
2
3use crate::common::{
4    repair_bounds_help, repair_iteration, repair_standard_help, RepairResult, RepairSystem,
5};
6use rem_utils::compile_file;
7
8#[derive(Debug, Clone)]
9pub struct Repairer {}
10
11impl RepairSystem for Repairer {
12    fn name(&self) -> &str {
13        "_simple_repairer"
14    }
15
16    fn repair_project(
17        &self,
18        _src_path: &str,
19        _manifest_path: &str,
20        _fn_name: &str,
21    ) -> RepairResult {
22        RepairResult {
23            success: false,
24            repair_count: 0,
25            has_non_elidible_lifetime: false,
26            has_struct_lt: false,
27        }
28    }
29
30    fn repair_file(&self, file_name: &str, new_file_name: &str) -> RepairResult {
31        self.repair_function(file_name, new_file_name, "")
32    }
33
34    fn repair_function(&self, file_name: &str, new_file_name: &str, fn_name: &str) -> RepairResult {
35        let args: Vec<&str> = vec!["--error-format=json"];
36        fs::copy(file_name, &new_file_name).unwrap();
37
38        let mut compile_cmd = compile_file(&new_file_name, &args);
39
40        let process_errors = |stderr: &str| {
41            repair_bounds_help(stderr, new_file_name, fn_name)
42                || repair_standard_help(stderr, new_file_name)
43        };
44
45        repair_iteration(&mut compile_cmd, &process_errors, true, None)
46    }
47
48    fn clone_box(&self) -> Box<dyn RepairSystem> {
49        Box::new((*self).clone())
50    }
51}