pub fn validate_graph(project: &Project) -> Result<(), CoreError>Expand description
Checks that every needs entry in project names a beam that actually
exists, that project’s default (if it declares one) does too, and
that no beam (transitively) needs itself.
The checks run as separate passes over Project::beams, in
declaration order: first every needs entry against the full set of
declared ids, then the default, then cycle detection (which assumes
every needs entry already resolves, since the first pass would have
already returned an error otherwise). Each reports at the exact
reference that does not resolve, and against whichever beam declared
it — its own source, via CoreError::with_source_id — never the
caller’s; this function runs after every file has finished loading,
when no SourceIdScope is active, so leaving source_id at its
default would always point a multi-file project’s error at the root
file regardless of which imported file actually declared the problem.
The default needs no such correction: only the root file’s default
is ever kept (see crate::loader::load_project), so it always
belongs to the file SourceId’s own default already names.