[ty] Require that we can find a root when listing sub-modules

This is similar to a change made in the "list top-level modules"
implementation that had been masked by poor Salsa failure modes.
Basically, if we can't find a root here, it *must* be a bug. And if we
just silently skip over it, we risk voiding Salsa's purity contract,
leading to more difficult to debug panics.

This did cause one test to fail, but only because the test wasn't
properly setting up roots.
This commit is contained in:
Andrew Gallant 2025-08-26 14:55:19 -04:00 committed by Andrew Gallant
parent 3b913ce652
commit 9cea752934
4 changed files with 23 additions and 5 deletions

View file

@ -161,9 +161,11 @@ fn all_submodule_names_for_package(db: &dyn Db, file: File) -> Option<Vec<Name>>
// tree. When the revision gets bumped, the cache
// that Salsa creates does for this routine will be
// invalidated.
if let Some(root) = db.files().root(db, parent_directory) {
let _ = root.revision(db);
}
let root = db
.files()
.root(db, parent_directory)
.expect("System search path should have a registered root");
let _ = root.revision(db);
db.system()
.read_directory(parent_directory)