pub struct ModuleGraph {
pub modules: Vec<ModuleInfo>,
pub global_dynamic: bool,
/* private fields */
}Expand description
The whole project graph.
Fields§
§modules: Vec<ModuleInfo>§global_dynamic: boolTrue if any module in the project has a dynamic dispatch/import sink.
Implementations§
Source§impl ModuleGraph
impl ModuleGraph
Sourcepub fn build(root: &Utf8Path, files: &[Utf8PathBuf]) -> Self
pub fn build(root: &Utf8Path, files: &[Utf8PathBuf]) -> Self
Parse all files (in parallel) and build the graph.
Sourcepub fn unresolved_imports(&self) -> Vec<UnresolvedImport>
pub fn unresolved_imports(&self) -> Vec<UnresolvedImport>
Imports that look internal but resolve to no module in the project:
every relative import that fails to resolve, plus absolute imports under a
first-party top-level package that fail to resolve. These are typically a
typo or a broken refactor — distinct from third-party missing-dependency.
Sourcepub fn unused_files(&self) -> Vec<&ModuleInfo>
pub fn unused_files(&self) -> Vec<&ModuleInfo>
Files that are neither entries nor reachable from any entry.
Sourcepub fn symbol_used(&self, module: FileId, name: &str, defs_named: u32) -> bool
pub fn symbol_used(&self, module: FileId, name: &str, defs_named: u32) -> bool
Whether a symbol defined in module is referenced internally or by any
importer of that module. defs_named is how many top-level defs share
the name (to discount the definition site in the internal count).
pub fn edge_count(&self) -> usize
Sourcepub fn import_edges(&self) -> Vec<(&str, &str)>
pub fn import_edges(&self) -> Vec<(&str, &str)>
Internal import edges as (importer dotted, imported dotted) pairs. Used by the architecture-boundary engine.
Sourcepub fn path_of_dotted(&self, dotted: &str) -> Option<&Utf8Path>
pub fn path_of_dotted(&self, dotted: &str) -> Option<&Utf8Path>
The path of a module by its dotted name (first match), for findings.
Sourcepub fn find_cycles(&self) -> Vec<Vec<FileId>>
pub fn find_cycles(&self) -> Vec<Vec<FileId>>
Find import cycles: strongly-connected components of size > 1, plus self-loops. Tarjan’s algorithm; results are deterministic (each cycle’s members sorted, and the list sorted). Cross-module circular imports.
Auto Trait Implementations§
impl Freeze for ModuleGraph
impl RefUnwindSafe for ModuleGraph
impl Send for ModuleGraph
impl Sync for ModuleGraph
impl Unpin for ModuleGraph
impl UnsafeUnpin for ModuleGraph
impl UnwindSafe for ModuleGraph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more