Fix skipping both errors for rust-analyzer not existing

This commit is contained in:
Jack Clayton 2022-01-12 12:53:49 +08:00
parent a831aa7982
commit 979f7788d8
2 changed files with 7 additions and 17 deletions

View File

@ -140,11 +140,6 @@ fn check_exists() {
let rust_project = RustAnalyzerProject::new(); let rust_project = RustAnalyzerProject::new();
match rust_project.check_rust_analyzer_exists() { match rust_project.check_rust_analyzer_exists() {
Ok(_) => (), Ok(_) => (),
Err(err) => match err { Err(_) => println!("Correctly identifying rust-analyzer doesn't exist"),
RustAnalyzerError::NoRustAnalyzerError => {
println!("Correctly identifying rust-analyzer doesn't exist")
}
RustAnalyzerError::IoError(err) => panic!("io error: {}", err),
},
} }
} }

View File

@ -416,16 +416,7 @@ fn rustc_exists() -> bool {
fn fix_rust_analyzer() { fn fix_rust_analyzer() {
let mut rust_project = RustAnalyzerProject::new(); let mut rust_project = RustAnalyzerProject::new();
if let Err(err) = rust_project.check_rust_analyzer_exists() { if rust_project.check_rust_analyzer_exists().is_ok() {
match err {
RustAnalyzerError::NoRustAnalyzerError => {
println!("rust-analyzer doesn't exist, skipping fix")
}
RustAnalyzerError::IoError(err) => {
println!("error trying to find rust-analyzer: {}", err)
}
}
} else {
println!("rust-analyzer exists, fixing to work with rustlings"); println!("rust-analyzer exists, fixing to work with rustlings");
if let Err(err) = rust_project.get_sysroot_src() { if let Err(err) = rust_project.get_sysroot_src() {
println!("Error getting toolchain path: {}\nContinuing... rust-analyzer won't work with rustlings", &err) println!("Error getting toolchain path: {}\nContinuing... rust-analyzer won't work with rustlings", &err)
@ -433,6 +424,10 @@ fn fix_rust_analyzer() {
if let Err(err) = rust_project.exercies_to_json() { if let Err(err) = rust_project.exercies_to_json() {
println!("Error parsing exercises and converting to json: {}\nContinuing... rust-analyzer won't work with rustlings", &err) println!("Error parsing exercises and converting to json: {}\nContinuing... rust-analyzer won't work with rustlings", &err)
} }
rust_project.write_to_disk(); if let Err(_) = rust_project.write_to_disk() {
println!("Failed to write rust-project.json to disk, rust-analyzer won't work with rustlings");
};
} else {
println!("Can't find rust-analyzer, skipping fix\n")
} }
} }