Skip to content

Commit cc5fd6a

Browse files
committed
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.
1 parent 5540976 commit cc5fd6a

File tree

1 file changed

+4
-4
lines changed
  • src/tools/compiletest/src

1 file changed

+4
-4
lines changed

src/tools/compiletest/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub mod runtest;
2020
pub mod util;
2121

2222
use core::panic;
23-
use std::collections::HashSet;
23+
use std::collections::BTreeSet;
2424
use std::ffi::{OsStr, OsString};
2525
use std::io::{self, ErrorKind};
2626
use std::path::{Path, PathBuf};
@@ -554,7 +554,7 @@ struct TestCollectorCx {
554554
/// Mutable state used during test collection.
555555
struct TestCollector {
556556
tests: Vec<test::TestDescAndFn>,
557-
found_path_stems: HashSet<PathBuf>,
557+
found_path_stems: BTreeSet<PathBuf>,
558558
poisoned: bool,
559559
}
560560

@@ -573,7 +573,7 @@ pub fn collect_and_make_tests(config: Arc<Config>) -> Vec<test::TestDescAndFn> {
573573

574574
let cx = TestCollectorCx { config, cache, common_inputs_stamp, modified_tests };
575575
let mut collector =
576-
TestCollector { tests: vec![], found_path_stems: HashSet::new(), poisoned: false };
576+
TestCollector { tests: vec![], found_path_stems: BTreeSet::new(), poisoned: false };
577577

578578
collect_tests_from_dir(&cx, &mut collector, &cx.config.src_base, &PathBuf::new())
579579
.unwrap_or_else(|reason| {
@@ -1023,7 +1023,7 @@ fn make_test_closure(
10231023
/// To avoid problems, we forbid test names from overlapping in this way.
10241024
///
10251025
/// See <https://github.com/rust-lang/rust/pull/109509> for more context.
1026-
fn check_for_overlapping_test_paths(found_path_stems: &HashSet<PathBuf>) {
1026+
fn check_for_overlapping_test_paths(found_path_stems: &BTreeSet<PathBuf>) {
10271027
let mut collisions = Vec::new();
10281028
for path in found_path_stems {
10291029
for ancestor in path.ancestors().skip(1) {

0 commit comments

Comments
 (0)