|
104 | 104 | //! implemented.
|
105 | 105 |
|
106 | 106 | use crate::errors;
|
| 107 | +use rustc_data_structures::base_n::Base36Encodable; |
107 | 108 | use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
|
108 | 109 | use rustc_data_structures::svh::Svh;
|
109 | 110 | use rustc_data_structures::unord::{UnordMap, UnordSet};
|
@@ -329,28 +330,21 @@ pub fn finalize_session_directory(sess: &Session, svh: Option<Svh>) {
|
329 | 330 |
|
330 | 331 | debug!("finalize_session_directory() - session directory: {}", incr_comp_session_dir.display());
|
331 | 332 |
|
332 |
| - let old_sub_dir_name = incr_comp_session_dir.file_name().unwrap().to_string_lossy(); |
333 |
| - assert_no_characters_lost(&old_sub_dir_name); |
| 333 | + let mut sub_dir_name = incr_comp_session_dir.file_name().unwrap().to_string_lossy().to_string(); |
| 334 | + assert_no_characters_lost(&sub_dir_name); |
334 | 335 |
|
335 | 336 | // Keep the 's-{timestamp}-{random-number}' prefix, but replace the
|
336 | 337 | // '-working' part with the SVH of the crate
|
337 |
| - let dash_indices: Vec<_> = old_sub_dir_name.match_indices('-').map(|(idx, _)| idx).collect(); |
338 |
| - if dash_indices.len() != 3 { |
339 |
| - bug!( |
340 |
| - "Encountered incremental compilation session directory with \ |
341 |
| - malformed name: {}", |
342 |
| - incr_comp_session_dir.display() |
343 |
| - ) |
344 |
| - } |
345 |
| - |
346 |
| - // State: "s-{timestamp}-{random-number}-" |
347 |
| - let mut new_sub_dir_name = String::from(&old_sub_dir_name[..=dash_indices[2]]); |
| 338 | + // We want to keep this: "s-{timestamp}-{random-number}-" |
| 339 | + sub_dir_name.truncate(2 + (u64::encoded_len() - 3) + 1 + u32::encoded_len() + 1); |
| 340 | + assert!(sub_dir_name.ends_with('-')); |
| 341 | + assert!(sub_dir_name.as_bytes().iter().filter(|b| **b == b'-').count() == 3); |
348 | 342 |
|
349 | 343 | // Append the svh
|
350 |
| - base_n::push_str(svh.as_u128(), INT_ENCODE_BASE, &mut new_sub_dir_name); |
| 344 | + base_n::push_case_insensitive(svh.as_u128(), &mut sub_dir_name); |
351 | 345 |
|
352 | 346 | // Create the full path
|
353 |
| - let new_path = incr_comp_session_dir.parent().unwrap().join(new_sub_dir_name); |
| 347 | + let new_path = incr_comp_session_dir.parent().unwrap().join(&*sub_dir_name); |
354 | 348 | debug!("finalize_session_directory() - new path: {}", new_path.display());
|
355 | 349 |
|
356 | 350 | match rename_path_with_retry(&*incr_comp_session_dir, &new_path, 3) {
|
@@ -446,11 +440,10 @@ fn generate_session_dir_path(crate_dir: &Path) -> PathBuf {
|
446 | 440 | let random_number = thread_rng().next_u32();
|
447 | 441 | debug!("generate_session_dir_path: random_number = {}", random_number);
|
448 | 442 |
|
449 |
| - let directory_name = format!( |
450 |
| - "s-{}-{}-working", |
451 |
| - timestamp, |
452 |
| - base_n::encode(random_number as u128, INT_ENCODE_BASE) |
453 |
| - ); |
| 443 | + // Chop the first 3 characters off the timestamp. Those 3 bytes will be zero for a while. |
| 444 | + assert_eq!(×tamp[..3], "000"); |
| 445 | + let directory_name = |
| 446 | + format!("s-{}-{}-working", ×tamp[3..], base_n::case_insensitive(random_number)); |
454 | 447 | debug!("generate_session_dir_path: directory_name = {}", directory_name);
|
455 | 448 | let directory_path = crate_dir.join(directory_name);
|
456 | 449 | debug!("generate_session_dir_path: directory_path = {}", directory_path.display());
|
@@ -582,7 +575,7 @@ fn extract_timestamp_from_session_dir(directory_name: &str) -> Result<SystemTime
|
582 | 575 | fn timestamp_to_string(timestamp: SystemTime) -> String {
|
583 | 576 | let duration = timestamp.duration_since(UNIX_EPOCH).unwrap();
|
584 | 577 | let micros = duration.as_secs() * 1_000_000 + (duration.subsec_nanos() as u64) / 1000;
|
585 |
| - base_n::encode(micros as u128, INT_ENCODE_BASE) |
| 578 | + base_n::case_insensitive(micros) |
586 | 579 | }
|
587 | 580 |
|
588 | 581 | fn string_to_timestamp(s: &str) -> Result<SystemTime, &'static str> {
|
@@ -613,7 +606,7 @@ fn crate_path(sess: &Session) -> PathBuf {
|
613 | 606 | sess.cfg_version,
|
614 | 607 | );
|
615 | 608 |
|
616 |
| - let stable_crate_id = base_n::encode(stable_crate_id.as_u64() as u128, INT_ENCODE_BASE); |
| 609 | + let stable_crate_id = base_n::case_insensitive(stable_crate_id.as_u64()); |
617 | 610 |
|
618 | 611 | let crate_name = format!("{crate_name}-{stable_crate_id}");
|
619 | 612 | incr_dir.join(crate_name)
|
|
0 commit comments