crates/mimir-driver/tests/no_trimmed_paths.rs
//! GUARD: the driver never asks the compiler for trimmed paths. Its
//! `trimmed_def_paths` query makes rustc ICE at the end of a session that
//! emitted no diagnostic (dwarf 2026-10-17: every member of a 21-repo read
//! failed on dependencies like toml_edit). Types are printed with full paths
//! and cut by `mimir_driver::shorten_paths`.
#[test]
fn the_driver_never_prints_trimmed_paths() {
let src = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("src");
let mut files = Vec::new();
let mut dirs = vec![src];
while let Some(d) = dirs.pop() {
for e in std::fs::read_dir(&d).unwrap().flatten() {
let p = e.path();
if p.is_dir() {
dirs.push(p);
} else if p.extension().is_some_and(|x| x == "rs") {
files.push(p);
}
}
}
let forbidden = ["ForceTrimmedGuard", "with_forced_trimmed_paths", "trimmed_def_paths(", "with_crate_prefix", "short_ty("];
let mut bad = Vec::new();
for f in &files {
for (i, line) in std::fs::read_to_string(f).unwrap().lines().enumerate() {
let code = line.split("//").next().unwrap_or_default();
for w in forbidden {
if code.contains(w) {
bad.push(format!("{}:{}: {}", f.display(), i + 1, line.trim()));
}
}
}
}
assert!(bad.is_empty(), "trimmed-path printing in the driver:\n{}", bad.join("\n"));
}