regexident/cargo-modules

Add `--use-parents` option?

Opened this issue · 1 comments

I was going to suggest that we close #18 in light of #184, but it turns out that PR is only a partial solution.

It catches cases like this:

mod a {
  use super::b;
}
mod b {
  use super::a;
}

But it doesn't catch cases like this:

mod a {
  use super::b;
  struct T;
}
mod b {
  use super::a::T;
}

because an edge b --> a::T is not the same as an edge b --> a.

I think the easiest solution would be to add something like --use-parents, which adds an edge b --> a whenever an edge b --> a::T is seen.

@regexident I realize this is "option creep" for a tool not originally intended for this purpose, but would you be open to adding such an option?

This would also allow to generate a graph of actual module dependencies without rendering every single item per module, right? For large (binary) crates, it would be very nice if this tool could help identify easy modules to move out into separate crates, but currently due to the size of the output when only showing modules, it's not really feasible.