diff --git a/crates/install-wheel-rs/src/uninstall.rs b/crates/install-wheel-rs/src/uninstall.rs index f1075cb31..de917c09e 100644 --- a/crates/install-wheel-rs/src/uninstall.rs +++ b/crates/install-wheel-rs/src/uninstall.rs @@ -16,15 +16,17 @@ pub fn uninstall_wheel(dist_info: &Path) -> Result { }; // Read the RECORD file. - let record_path = dist_info.join("RECORD"); - let mut record_file = match fs::File::open(&record_path) { - Ok(record_file) => record_file, - Err(err) if err.kind() == std::io::ErrorKind::NotFound => { - return Err(Error::MissingRecord(record_path)); - } - Err(err) => return Err(err.into()), + let record = { + let record_path = dist_info.join("RECORD"); + let mut record_file = match fs::File::open(&record_path) { + Ok(record_file) => record_file, + Err(err) if err.kind() == std::io::ErrorKind::NotFound => { + return Err(Error::MissingRecord(record_path)); + } + Err(err) => return Err(err.into()), + }; + read_record_file(&mut record_file)? }; - let record = read_record_file(&mut record_file)?; let mut file_count = 0usize; let mut dir_count = 0usize;