From 979f7788d829bdb046eeab0c4a37140c8aef5e97 Mon Sep 17 00:00:00 2001 From: Jack Clayton Date: Wed, 12 Jan 2022 12:53:49 +0800 Subject: [PATCH] Fix skipping both errors for rust-analyzer not existing --- src/fix_rust_analyzer.rs | 7 +------ src/main.rs | 17 ++++++----------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/fix_rust_analyzer.rs b/src/fix_rust_analyzer.rs index 0f2dada9..a197bb5a 100644 --- a/src/fix_rust_analyzer.rs +++ b/src/fix_rust_analyzer.rs @@ -140,11 +140,6 @@ fn check_exists() { let rust_project = RustAnalyzerProject::new(); match rust_project.check_rust_analyzer_exists() { Ok(_) => (), - Err(err) => match err { - RustAnalyzerError::NoRustAnalyzerError => { - println!("Correctly identifying rust-analyzer doesn't exist") - } - RustAnalyzerError::IoError(err) => panic!("io error: {}", err), - }, + Err(_) => println!("Correctly identifying rust-analyzer doesn't exist"), } } diff --git a/src/main.rs b/src/main.rs index 5970ee3f..6926a222 100644 --- a/src/main.rs +++ b/src/main.rs @@ -416,16 +416,7 @@ fn rustc_exists() -> bool { fn fix_rust_analyzer() { let mut rust_project = RustAnalyzerProject::new(); - if let Err(err) = rust_project.check_rust_analyzer_exists() { - match err { - RustAnalyzerError::NoRustAnalyzerError => { - println!("rust-analyzer doesn't exist, skipping fix") - } - RustAnalyzerError::IoError(err) => { - println!("error trying to find rust-analyzer: {}", err) - } - } - } else { + if rust_project.check_rust_analyzer_exists().is_ok() { println!("rust-analyzer exists, fixing to work with rustlings"); if let Err(err) = rust_project.get_sysroot_src() { 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() { 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") } }