Skip to content

Commit df8aed4

Browse files
committed
More error details upon unexpected incr-comp session dir
1 parent c94cb83 commit df8aed4

File tree

1 file changed

+7
-7
lines changed
  • compiler/rustc_incremental/src/persist

1 file changed

+7
-7
lines changed

compiler/rustc_incremental/src/persist/fs.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -538,8 +538,8 @@ where
538538
continue;
539539
}
540540

541-
let timestamp = extract_timestamp_from_session_dir(&directory_name).unwrap_or_else(|_| {
542-
bug!("unexpected incr-comp session dir: {}", session_dir.display())
541+
let timestamp = extract_timestamp_from_session_dir(&directory_name).unwrap_or_else(|e| {
542+
bug!("unexpected incr-comp session dir: {}: {}", session_dir.display(), e)
543543
});
544544

545545
if timestamp > best_candidate.0 {
@@ -562,14 +562,14 @@ fn is_session_directory_lock_file(file_name: &str) -> bool {
562562
file_name.starts_with("s-") && file_name.ends_with(LOCK_FILE_EXT)
563563
}
564564

565-
fn extract_timestamp_from_session_dir(directory_name: &str) -> Result<SystemTime, ()> {
565+
fn extract_timestamp_from_session_dir(directory_name: &str) -> Result<SystemTime, &'static str> {
566566
if !is_session_directory(directory_name) {
567-
return Err(());
567+
return Err("not a directory");
568568
}
569569

570570
let dash_indices: Vec<_> = directory_name.match_indices('-').map(|(idx, _)| idx).collect();
571571
if dash_indices.len() != 3 {
572-
return Err(());
572+
return Err("not three dashes in name");
573573
}
574574

575575
string_to_timestamp(&directory_name[dash_indices[0] + 1..dash_indices[1]])
@@ -581,11 +581,11 @@ fn timestamp_to_string(timestamp: SystemTime) -> String {
581581
base_n::encode(micros as u128, INT_ENCODE_BASE)
582582
}
583583

584-
fn string_to_timestamp(s: &str) -> Result<SystemTime, ()> {
584+
fn string_to_timestamp(s: &str) -> Result<SystemTime, &'static str> {
585585
let micros_since_unix_epoch = u64::from_str_radix(s, INT_ENCODE_BASE as u32);
586586

587587
if micros_since_unix_epoch.is_err() {
588-
return Err(());
588+
return Err("timestamp not an int");
589589
}
590590

591591
let micros_since_unix_epoch = micros_since_unix_epoch.unwrap();

0 commit comments

Comments
 (0)