From cc5fd6af29a2c2a969ff02a2a8fff6a976c22c1d Mon Sep 17 00:00:00 2001 From: Zalathar Date: Fri, 18 Oct 2024 17:49:51 +1100 Subject: [PATCH] Store path stems in a BTreeSet There is no noticeable performance difference in practice, and the consistent sorted order of BTreeSet should be more convenient than a HashSet or Vec when printing these paths for debug purposes. --- src/tools/compiletest/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs index d045c6fe05312..c248d5e087328 100644 --- a/src/tools/compiletest/src/lib.rs +++ b/src/tools/compiletest/src/lib.rs @@ -20,7 +20,7 @@ pub mod runtest; pub mod util; use core::panic; -use std::collections::HashSet; +use std::collections::BTreeSet; use std::ffi::{OsStr, OsString}; use std::io::{self, ErrorKind}; use std::path::{Path, PathBuf}; @@ -554,7 +554,7 @@ struct TestCollectorCx { /// Mutable state used during test collection. struct TestCollector { tests: Vec, - found_path_stems: HashSet, + found_path_stems: BTreeSet, poisoned: bool, } @@ -573,7 +573,7 @@ pub fn collect_and_make_tests(config: Arc) -> Vec { let cx = TestCollectorCx { config, cache, common_inputs_stamp, modified_tests }; let mut collector = - TestCollector { tests: vec![], found_path_stems: HashSet::new(), poisoned: false }; + TestCollector { tests: vec![], found_path_stems: BTreeSet::new(), poisoned: false }; collect_tests_from_dir(&cx, &mut collector, &cx.config.src_base, &PathBuf::new()) .unwrap_or_else(|reason| { @@ -1023,7 +1023,7 @@ fn make_test_closure( /// To avoid problems, we forbid test names from overlapping in this way. /// /// See for more context. -fn check_for_overlapping_test_paths(found_path_stems: &HashSet) { +fn check_for_overlapping_test_paths(found_path_stems: &BTreeSet) { let mut collisions = Vec::new(); for path in found_path_stems { for ancestor in path.ancestors().skip(1) {