Giter Club home page Giter Club logo

cargo-modules's Introduction

cargo-modules

Build Status Downloads Version License

Synopsis

A cargo plugin for visualizing/analyzing a crate's internal structure.

Motivation

With time, as your Rust projects grow bigger and bigger, it gets more and more important to properly structure your code. Fortunately Rust provides us with a quite sophisticated module system, allowing us to neatly split up our crates into arbitrarily small sub-modules of types and functions. While this helps to avoid monolithic and unstructured chunks of code, it can also make it hard at times to still mentally stay on top of the over-all high-level structure of the project at hand.

This is where cargo-modules comes into play:

Installation

Install cargo-modules via:

cargo install cargo-modules

Usage

The cargo-modules tool comes with a couple of commands:

# Print a crate's hierarchical structure as a tree:
cargo modules structure <OPTIONS>

# Print a crate's internal dependencies as a graph:
cargo modules dependencies <OPTIONS>

# Detect unlinked source files within a crate's directory:
cargo modules orphans <OPTIONS>
Command help
$ cargo modules --help

Visualize/analyze a crate's internal structure.

Usage: cargo-modules <COMMAND>

Commands:
  structure     Prints a crate's hierarchical structure as a tree.
  dependencies  Prints a crate's internal dependencies as a graph.
  orphans       Detects unlinked source files within a crate's directory.
  help          Print this message or the help of the given subcommand(s)

Options:
  -h, --help  Print help

cargo modules structure

Print a crate's hierarchical structure as a tree:

cargo modules structure <OPTIONS>
Command help
$ cargo modules structure --help

Prints a crate's hierarchical structure as a tree.

Usage: cargo-modules structure [OPTIONS]

Options:
      --verbose                        Use verbose output
      --lib                            Process only this package's library
      --bin <BIN>                      Process only the specified binary
  -p, --package <PACKAGE>              Package to process (see `cargo help pkgid`)
      --no-default-features            Do not activate the `default` feature
      --all-features                   Activate all available features
      --features <FEATURES>            List of features to activate. This will be ignored if `--cargo-all-features` is provided
      --target <TARGET>                Analyze for target triple
      --manifest-path <MANIFEST_PATH>  Path to Cargo.toml [default: .]
      --no-fns                         Filter out functions (e.g. fns, async fns, const fns) from tree
      --no-traits                      Filter out traits (e.g. trait, unsafe trait) from tree
      --no-types                       Filter out types (e.g. structs, unions, enums) from tree
      --sort-by <SORT_BY>              The sorting order to use (e.g. name, visibility, kind) [default: name]
      --sort-reversed                  Reverses the sorting order
      --focus-on <FOCUS_ON>            Focus the graph on a particular path or use-tree's environment, e.g. "foo::bar::{self, baz, blee::*}"
      --max-depth <MAX_DEPTH>          The maximum depth of the generated graph relative to the crate's root node, or nodes selected by '--focus-on'
      --cfg-test                       Analyze with `#[cfg(test)]` enabled (i.e as if built via `cargo test`)
  -h, --help                           Print help

Example: Modules Structure as Text Tree

cd ./tests/projects/readme_tree_example
cargo-modules structure --cfg-test

Output:

Output of cargo modules structure …

crate readme_tree_example
├── trait Lorem: pub
├── mod amet: pub(crate)
│   └── mod consectetur: pub(self)
│       └── mod adipiscing: pub(self)
│           └── union Elit: pub(in crate::amet)
├── mod dolor: pub(crate)
│   └── enum Sit: pub(crate)
└── mod tests: pub(crate) #[cfg(test)]
    └── fn it_works: pub(self) #[test]

(Project source code: readme_tree_example/src/lib.rs)

Terminal Colors

If you are running the command on a terminal with color support and don't have NO_COLOR defined in your environment, then the output will be colored for easier visual parsing:

└── <visibility> <keyword> <name> [<test-attributes>]

The <visibility> (more info) is further more highlighted by the following colors:

Color Meaning
🟢 green Items visible to all and everything (i.e. pub)
🟡 yellow Items visible to the current crate (i.e. pub(crate))
🟠 orange Items visible to a certain parent module (i.e. pub(in path))
🔴 red Items visible to the current module (i.e. pub(self), implied by lack of pub …)

The <keyword> is highlighted in 🔵 blue to visually separate it from the name.

Test-guarded items (i.e. #[cfg(test)] …) and test functions (i.e. #[test] fn …) have their corresponding <test-attributes> printed next to them in gray and cyan.

cargo modules dependencies

Print a crate's internal dependencies as a graph:

cargo modules dependencies <OPTIONS>
Command help
$ cargo modules dependencies --help

Prints a crate's internal dependencies as a graph.

Usage: cargo-modules dependencies [OPTIONS]

Options:
      --verbose                        Use verbose output
      --lib                            Process only this package's library
      --bin <BIN>                      Process only the specified binary
  -p, --package <PACKAGE>              Package to process (see `cargo help pkgid`)
      --no-default-features            Do not activate the `default` feature
      --all-features                   Activate all available features
      --features <FEATURES>            List of features to activate. This will be ignored if `--cargo-all-features` is provided
      --target <TARGET>                Analyze for target triple
      --manifest-path <MANIFEST_PATH>  Path to Cargo.toml [default: .]
      --no-externs                     Filter out extern items from extern crates from graph
      --no-fns                         Filter out functions (e.g. fns, async fns, const fns) from graph
      --no-modules                     Filter out modules (e.g. `mod foo`, `mod foo {}`) from graph
      --no-sysroot                     Filter out sysroot crates (`std`, `core` & friends) from graph
      --no-traits                      Filter out traits (e.g. trait, unsafe trait) from graph
      --no-types                       Filter out types (e.g. structs, unions, enums) from graph
      --no-uses                        Filter out "use" edges from graph
      --acyclic                        Require graph to be acyclic
      --layout <LAYOUT>                The graph layout algorithm to use (e.g. none, dot, neato, twopi, circo, fdp, sfdp) [default: neato]
      --focus-on <FOCUS_ON>            Focus the graph on a particular path or use-tree's environment, e.g. "foo::bar::{self, baz, blee::*}"
      --max-depth <MAX_DEPTH>          The maximum depth of the generated graph relative to the crate's root node, or nodes selected by '--focus-on'
      --cfg-test                       Analyze with `#[cfg(test)]` enabled (i.e as if built via `cargo test`)
  -h, --help                           Print help


        If you have xdot installed on your system, you can run this using:
        `cargo modules dependencies | xdot -`

Example: Graphical Module Structure

cargo modules dependencies --no-externs --no-fns --no-sysroot --no-traits --no-types --no-uses > mods.dot

(The command above is equivalent to cargo-modules generate graph from v0.12.0 or earlier.)

Output of cargo modules dependencies …

Example: Graphical Dependencies

cd ./tests/projects/smoke
cargo-modules dependencies --cfg-test | dot -Tsvg

Output of cargo modules dependencies …

See "./docs/dependencies_output.dot" for the corresponding raw dot file.

(Project source code: readme_graph_example/src/lib.rs)

Node Structure

The individual nodes are structured as follows:

┌────────────────────────┐
│ <visibility> <keyword> │
├────────────────────────┤
│         <path>         │
└────────────────────────┘

Node Colors

The <visibility> (more info) is further more highlighted by the following colors:

Color Meaning
🔵 blue Crates (i.e. their implicit root module)
🟢 green Items visible to all and everything (i.e. pub)
🟡 yellow Items visible to the current crate (i.e. pub(crate))
🟠 orange Items visible to a certain parent module (i.e. pub(in path))
🔴 red Items visible to the current module (i.e. pub(self), implied by lack of pub …)

Acyclic Mode

cargo-modules's dependencies command checks for the presence of a --acyclic flag. If found it will search for cycles in the directed graph and return an error for any cycles it found.

Running cargo modules dependencies --lib --acyclic on the source of the tool itself emits the following cycle error:

Error: Circular dependency between `cargo_modules::options::general` and `cargo_modules::options::generate`.

┌> cargo_modules::options::general
│  └─> cargo_modules::options::generate::graph
│      └─> cargo_modules::options::generate
└──────────┘

cargo modules orphans

Detect unlinked source files within a crate's directory:

cargo modules orphans <OPTIONS>
Command help
$ cargo modules orphans --help

Detects unlinked source files within a crate's directory.

Usage: cargo-modules orphans [OPTIONS]

Options:
      --verbose                        Use verbose output
      --lib                            Process only this package's library
      --bin <BIN>                      Process only the specified binary
  -p, --package <PACKAGE>              Package to process (see `cargo help pkgid`)
      --no-default-features            Do not activate the `default` feature
      --all-features                   Activate all available features
      --features <FEATURES>            List of features to activate. This will be ignored if `--cargo-all-features` is provided
      --target <TARGET>                Analyze for target triple
      --manifest-path <MANIFEST_PATH>  Path to Cargo.toml [default: .]
      --deny                           Returns a failure code if one or more orphans are found
      --cfg-test                       Analyze with `#[cfg(test)]` enabled (i.e as if built via `cargo test`)
  -h, --help                           Print help

Example

cd ./tests/projects/readme_tree_example
cargo-modules structure --types --traits --fns --tests

Output:

Output of cargo modules structure …

2 orphans found:

warning: orphaned module `foo` at src/orphans/foo/mod.rs
  --> src/orphans.rs
   |  ^^^^^^^^^^^^^^ orphan module not loaded from file
   |
 help: consider loading `foo` from module `orphans::orphans`
   |
   |  mod foo;
   |  ++++++++
   |

warning: orphaned module `bar` at src/orphans/bar.rs
  --> src/orphans.rs
   |  ^^^^^^^^^^^^^^ orphan module not loaded from file
   |
 help: consider loading `bar` from module `orphans::orphans`
   |
   |  mod bar;
   |  ++++++++
   |

Error: Found 2 orphans in crate 'orphans'

(Project source code: readme_tree_example/src/lib.rs)

No-Color Mode

cargo-modules checks for the presence of a NO_COLOR environment variable that, when present (regardless of its value), prevents the addition of color to the console output (and only the console output!).

Contributing

Please read CONTRIBUTING.md for details on our code of conduct,
and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

License

This project is licensed under the MPL-2.0 – see the LICENSE.md file for details.

cargo-modules's People

Contributors

andrey-gvrd avatar barafael avatar dependabot[bot] avatar diaevd avatar dtolnay avatar figsoda avatar flier avatar hmvp avatar kvark avatar llogiq avatar marycourtland avatar muhuk avatar nvxxu2i avatar ordovicia avatar regexident avatar renovate[bot] avatar smoelius avatar tobz1000 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cargo-modules's Issues

Install cargo-modules fails

I tried to install cargo-moduleswith latest rust version 1.53 (rustc 1.53.0 (53cb7b09b 2021-06-17) using latest docker image rust:1.53 and nativ on MacOSX). The command cargo install cargo-modules print the error message

   Compiling synstructure v0.12.5
   Compiling env_logger v0.8.4
   Compiling ra_ap_vfs-notify v0.0.49
error[E0599]: no function or associated item named `new_immediate` found for trait object `dyn Watcher` in the current scope
  --> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/ra_ap_vfs-notify-0.0.49/src/lib.rs:83:69
   |
83 | ...                   let watcher = log_notify_error(Watcher::new_immediate(move |event| {
   |                                                               ^^^^^^^^^^^^^ function or associated item not found in `dyn Watcher`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0599`.
error: could not compile `ra_ap_vfs-notify`

Fails to parse JSON when it's not a rust project

When executing cargo modules tree (as well as probably the other subcommands as well) will fail if the corresponding directory you're in is not a rust project with the following error message:

$ cargo modules tree
Error: Failed to parse JSON response.
UnexpectedEndOfJson

It would be awesome if I could get a message like 'There is no rust project here'. Nice project!

Analyze crates in non-test mode (again)

Issue #20 has regressed. cargo-modules is once again unconditionally enabling test mode. For example, with the following input:

use crate::a::X;
#[cfg(not(test))]
use crate::b::Y;
#[cfg(test)]
use crate::c::Z;

pub mod a {
    pub struct X{}
}

pub mod b {
    pub struct Y{}
}

pub mod c {
    pub struct Z{}
}

I would expect the following uses edges:

crate -> a
crate -> b

But cargo-modules doesn't show crate -> b. Instead it shows crate -> c, indicating that cfg(test) is set. It doesn't matter whether I use the --with-tests option. Here are the complete uses edges:

"cfg_not_test" -> "cfg_not_test::a" [label="uses", color="#7f7f7f", style="Dashed"]; // "uses" edge
"cfg_not_test" -> "cfg_not_test::c" [label="uses", color="#7f7f7f", style="Dashed"]; // "uses" edge

Building up a holistic understanding of a larger Rust system

When the context of dependencies and analyzing them, the need is most burning in the larger project. Just recently, Microsoft opensourced OneFuzz, Rust based fuzzing tool, that has quite a bunch of crates.

However, I cannot get the dependency graphs extracted with cargo-modules from OneFuzz. There is a big number of Cargo.toml files and I cannot figure out how to use cargo-modules properly to get the dependencies extracted from all of the crates to build up a holistic dependency data model of that project.

Below shell excerpt shows how I can improve the result of the data by removing main level Cargo.toml file but am still out of clue how to get stuff executed properly to identify all the dependencies between each create.

➜  onefuzz git:(main) cargo modules -p -o tree

atexit : crate
 ├── asan : orphan
 ├── az_copy : orphan
 ├── blob : orphan
 ├── cmd : orphan
 ├── expand : orphan
 ├── fs : orphan
 ├── input_tester : orphan
 ├── libfuzzer : orphan
 ├── machine_id : orphan
 ├── monitor : orphan
 ├── sha256 : orphan
 ├── system : orphan
 ├── telemetry : orphan
 ├── triage : orphan
 └── uploader : orphan

➜  onefuzz git:(main) rm ../Cargo.toml 
➜  onefuzz git:(main) ✗ cargo modules -p -o tree

onefuzz : crate
 ├── asan : public
 ├── az_copy : public
 ├── blob : public
 │   ├── client : orphan
 │   └── url : orphan
 ├── cmd : public
 ├── expand : public
 ├── fs : public
 ├── input_tester : public
 ├── libfuzzer : public
 ├── machine_id : public
 ├── monitor : public
 ├── sha256 : public
 ├── system : public
 ├── telemetry : public
 ├── triage : public @ #[cfg(target_os = "linux")]
 └── uploader : public

Sorry for my mediocre Rust competence here. I am seeking for something similar like madge but for Rust, that would enable easy extraction of the dependency data from Rust projects.

Dependency rustc-ap-arena failing on 1.29.0 nightly

Running cargo +nightly install cargo-modules gives

$ rustup run nightly cargo install cargo-modules
rustc 1.29.0-nightly (254f8796b 2018-07-13)

$ cargo +nightly install cargo-modules

<snip successful module compilations>

   Compiling rustc-ap-arena v154.0.0                                  
error[E0658]: use of unstable library feature 'raw_vec_internals': implemention detailrustc-ap-rustc_target, rust...
  --> /Users/nick/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-arena-154.0.0/lib.rs:46:5   
   |                                                                            
46 | use alloc::raw_vec::RawVec;                                     
   |     ^^^^^^^^^^^^^^^^^^^^^^                                                       
   |                                                                                                   
   = help: add #![feature(raw_vec_internals)] to the crate attributes to enable 
                                                                                     
error[E0658]: use of unstable library feature 'raw_vec_internals': implemention detail
  --> /Users/nick/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-arena-154.0.0/lib.rs:67:14  
   |                                                                            
67 |     storage: RawVec<T>,                                      
   |              ^^^^^^^^^                                                           
   |                                                                                                   
   = help: add #![feature(raw_vec_internals)] to the crate attributes to enable

<snip multiple repetitions of the previous error>

error: Could not compile `rustc-ap-arena`.
warning: build failed, waiting for other jobs to finish...
error: failed to compile `cargo-modules v0.4.1`, intermediate artifacts can be found at `/var/folders/vt/d9_pfw9j10l8jn69g02rjy1h0000gn/T/cargo-installsyJ6gK`

Analyze crates in non-test mode

"cargo modules --graph" analyzes the crate in test mode. This frequently includes extra modules that aren't interesting for understanding the design of a crate, like modules that only contain tests. Sometimes, a crate's module dependencies can differ more radically in test mode, such as when the test_double crate is in use. It would be better to analyze the module graph in non-test mode.

Feature: Add module grouping/Reflection model

Based on http://www.pathsensitive.com/2021/03/developer-tools-can-be-magic-instead.html
The first part speaks about reflection models. It seems to me that should be something powerful but easy to add to cargo modules:

It is starts as basically an option to point to a file with a mapping between modules (files in the original tool, but I suspect modules work better in rust context) and self defined categories. And instead of drawing the modules as nodes for the usage/dependency graph you use the categories and aggregate what is in de modules grouped by that category..

To implement the full model you could also add stuff to draw the graph into an existing dot graph which could contain the hypothesis graph (that should roughly work if the node ids match). However that might not even be needed to make it useful

Option to generate graph for structure/enum

I would like to be able to generate a graph for a structure. I have a heavy numbers of structure for a parsing crate that contains each other a lot, and I would like to generate a visual graph of it. I know this is not the purpose of this repo but I search I didn't find anything.

So I wonder, if anyone know something that do it, or if that could be an additional feature of this crate.

Example:

struct A {
    b: B,
    c: C,
}

struct B {
    c: C,
}

struct C {
    foo: i32,
}

struct D {
    a: A,
    b: B,
}

will produce:

digraph {
  A [shape=record, label="{ struct A | { <b> b| <c> c } }"];
  B [shape=record, label="{ struct B | { <c> c } }"];
  C [shape=record, label="{ struct C | { <foo> foo } }"];
  D [shape=record, label="{ struct D | { <a> a | <b> b } }"];

  A:b -> B;
  A:c -> C;
  B:c -> C;
  C:foo -> i32;
  D:a -> A;
  D:b -> B;
}

and so will produce:

graph

Build error on latest nightly: unknown feature array_value_iter_slice

After updating to the latest nightly using rustup update and installing cargo-modules using cargo +nightly install cargo-modules, this build error occured:

error[E0635]: unknown feature `array_value_iter_slice`
  --> /home/kangalioo/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_arena-693.0.0/src/lib.rs:14:12
   |
14 | #![feature(array_value_iter_slice)]
   |            ^^^^^^^^^^^^^^^^^^^^^^

Presumably, the latest nightly has stabilized the array_value_iter_slice feature which the rustc-ap-rustc_arena crate is not prepared to deal with. Not sure what the best way to resolve this is on cargo-module's side.

The issue can be worked around by manually navigating into the faulty source file and commenting out the #![feature(array_value_iter_slice)] line.

How to show dependencies between modules?

As a test, I created the following project structure:

// src/lib.rs
mod a;
mod b;
mod c;
mod d;
// src/a.rs
use crate::*;
struct A(C);
// src/b.rs
use crate::*;
struct B(C);
// src/c.rs
use crate::*;
struct C;
// src/d.rs
use crate::*;
struct D(A, C);

test.zip

And ran cargo-modules on it (0.5.0-beta.2) :

cargo modules generate graph | dot -Tpng > modules.png

It runs successfully and yields:
modules

As you can see, it does show the parent-child module relations quite well. I was wondering if it's possible to also show inter-module dependencies, to the spirit of the following?
image

Failed to install the latest version

>> cargo install cargo-modules
..........................
   Compiling ra_ap_ide_db v0.0.87
error[E0658]: use of unstable library feature 'iter_map_while': recently added
   --> /home/chz/.cargo/registry/src/github.com-1ecc6299db9ec823/ra_ap_ide_db-0.0.87/src/helpers.rs:313:55
    |
313 |         input.syntax().children_with_tokens().skip(1).map_while(|it| match it.into_token() {
    |                                                       ^^^^^^^^^
    |
    = note: see issue #68537 <https://github.com/rust-lang/rust/issues/68537> for more information

For more information about this error, try `rustc --explain E0658`.
error: could not compile `ra_ap_ide_db` due to previous error
warning: build failed, waiting for other jobs to finish...
error: failed to compile `cargo-modules v0.5.7`, intermediate artifacts can be found at `/tmp/cargo-installASlcUF`

Caused by:
  build failed

>> rustc --version
rustc 1.56.1 (59eed8a2a 2021-11-01)
>> cargo --version
cargo 1.56.0 (4ed5d137b 2021-10-04)
>>

cargo install cargo-modules --version "0.5.6" works OK.

Edition 2018 Support

Edition 2018 changes the way use works in a few different ways. I would like to add support resolving dependencies in projects that use edition = "2018".

My plan is as below:

  • Add a command-line option --enable-edition-2018. Initially this will be ignored. Current code does not take edition into consideration anyway. New option will be documented in --help.
  • Implement an alternate version of the dependency graph in a separate module. Keep the existing code intact. The new algorithm will only support edition 2018. There will be tests.
  • When --enable-edition-2018 is given and edition is "2018" in Cargo.toml, use the alternate implementation. Otherwise keep everything same.

This issue should also close #29 when implemented fully.

--plain option doesn't seem to work as expected

cargo-modules uses gold for some edges and it's almost invisible when printed on BW laser printer.
So I've tried to use --plain option but with no luck:

$ cargo modules --plain graph | grep color | head -1
	"::storage-units" [label="storage-units",color=green];
$ cargo modules graph | grep color | head -1
	"::storage-units" [label="storage-units",color=green];

i.e. the end result stays the same

Identify cycles between imports

As a rule, I try to organize my code so that the relationships between modules are acyclic - if I import something from module a into module b, I don't import anything from module b into module a.

Since this can construct the graph of import relationships between modules, it would be great for it to have a way to identify cycles in that graph, to help find the parts of your program that are getting "spaghetti."

Alternatively, though, I suspect there's already a common utility that can identify cycles in dot graph data (though I don't know what it is), and possibly just documenting and recommending you pipe the data into that could be a good solution.

Doesn't generate uses edges for fully namespaced components

cargo modules generate graph --with-uses is very useful for understanding a crate. However, I notice that it doesn't generate uses edges when one module uses another's components by their fully namespaced names, rather than through a uses statement. Ideally it would, because whether or not the programmer uses a uses statement is just a syntactical detail. For example, I would expect the following crate to have uses edges for both "a -> b" and "a -> c". But it only has the former.

pub mod a {
    use self::b::X;

    pub mod b  {
        pub struct X{}
    }
    pub mod c {
        pub struct Y{}
    }

    pub struct Z {
        x: X,
        y: c::Y
    }
}
digraph {

    graph [
        label="cargo_modules_test",
        labelloc=t,

        pad=0.4,

        // Consider rendering the graph using a different layout algorithm, such as:
        // [dot, neato, twopi, circo, fdp, sfdp]
        layout=neato,
        overlap=false,
        splines="line",
        rankdir=LR,

        fontname="Helvetica", 
        fontsize="36",
    ];

    node [
        fontname="monospace",
        fontsize="10",
        shape="record",
        style="filled",
    ];

    edge [
        fontname="monospace",
        fontsize="10",
    ];

    "cargo_modules_test" [label="crate|cargo_modules_test", fillcolor="#5397c8"]; // "crate" node
    "cargo_modules_test::a" [label="pub mod|a", fillcolor="#81c169"]; // "mod" node
    "cargo_modules_test::a::b" [label="pub mod|a::b", fillcolor="#81c169"]; // "mod" node
    "cargo_modules_test::a::c" [label="pub mod|a::c", fillcolor="#81c169"]; // "mod" node

    "cargo_modules_test" -> "cargo_modules_test::a" [label="owns", color="#000000", style="solid"]; // "owns" edge
    "cargo_modules_test::a" -> "cargo_modules_test::a::b" [label="owns", color="#000000", style="solid"]; // "owns" edge
    "cargo_modules_test::a" -> "cargo_modules_test::a::c" [label="owns", color="#000000", style="solid"]; // "owns" edge
    "cargo_modules_test::a" -> "cargo_modules_test::a::b" [label="uses", color="#7f7f7f", style="Dashed"]; // "uses" edge

}

Wrong "uses" edges for reexported inner modules' types

A common pattern is for a module to define an inner private module, then reexport parts of that private module as its own public API. Two ways of doing this are pub use and pub type. But cargo-modules doesn't seem to generate the correct output for either. For example, when using this input as lib.rs:

pub mod a {
    use self::b::X;
    use self::d::Y;

    pub mod b {
        use self::c;
        pub use c::X;

        mod c {
            pub struct X{}
        }

    }

    pub mod d {
        use self::e;
        pub type Y = e::Y;

        mod e {
            pub struct Y{}
        }
    }
}

I would expect the output to include the following uses edges:

a -> b
a -> d
b -> c
d -> e

However, cargo-modules omits the d -> e edge, and changes the a -> b edge into a -> c. Here are the actual uses edges it generates:

"pub_use::a::b" -> "pub_use::a::b::c" [label="uses", color="#7f7f7f", style="Dashed"]; // "uses" edge
"pub_use::a" -> "pub_use::a::d" [label="uses", color="#7f7f7f", style="Dashed"]; // "uses" edge
"pub_use::a" -> "pub_use::a::b::c" [label="uses", color="#7f7f7f", style="Dashed"]; // "uses" edge

Cannot compile rustc-ap-rustc_data_structures on nightly

error[E0061]: this function takes 1 argument but 0 arguments were supplied
  --> /Users/dmalyshau/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_data_structures-637.0.0/box_region.rs:34:58
   |
34 |         let init = match Pin::new(&mut result.generator).resume() {
   |                                                          ^^^^^^- supplied 0 arguments
   |
help: expected the unit value `()`; create it with empty parentheses
   |
34 |         let init = match Pin::new(&mut result.generator).resume(()) {
   |                                                                 ^^

error[E0061]: this function takes 1 argument but 0 arguments were supplied
  --> /Users/dmalyshau/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_data_structures-637.0.0/box_region.rs:48:76
   |
48 |         if let GeneratorState::Complete(_) = Pin::new(&mut self.generator).resume() {
   |                                                                            ^^^^^^- supplied 0 arguments
   |
help: expected the unit value `()`; create it with empty parentheses
   |
48 |         if let GeneratorState::Complete(_) = Pin::new(&mut self.generator).resume(()) {
   |                                                                                   ^^

error[E0061]: this function takes 1 argument but 0 arguments were supplied
  --> /Users/dmalyshau/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_data_structures-637.0.0/box_region.rs:57:52
   |
57 |         let result = Pin::new(&mut self.generator).resume();
   |                                                    ^^^^^^- supplied 0 arguments
   |
help: expected the unit value `()`; create it with empty parentheses
   |
57 |         let result = Pin::new(&mut self.generator).resume(());
   |                                                           ^^

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0061`.
error: could not compile `rustc-ap-rustc_data_structures`.

Cannot install current crate

$ rustup run nightly cargo install cargo-modules
    Updating crates.io index
  Installing cargo-modules v0.4.7
   Compiling libc v0.2.71
   Compiling autocfg v1.0.0
   Compiling cfg-if v0.1.10
   Compiling maybe-uninit v2.0.0
   Compiling unicode-xid v0.2.1
   Compiling lazy_static v1.4.0
   Compiling semver-parser v0.7.0
   Compiling scopeguard v1.1.0
   Compiling proc-macro2 v1.0.18
   Compiling syn v1.0.33
   Compiling byteorder v1.3.4
   Compiling cc v1.0.57
   Compiling typenum v1.12.0
   Compiling smallvec v1.4.1
   Compiling bitflags v1.2.1
   Compiling log v0.4.8
   Compiling rustc-rayon-core v0.3.0
   Compiling unicode-width v0.1.8
   Compiling byte-tools v0.3.1
   Compiling either v1.5.3
   Compiling rustc-hash v1.1.0
   Compiling stable_deref_trait v1.1.1
   Compiling opaque-debug v0.2.3
   Compiling rustc-ap-graphviz v662.0.0
   Compiling fake-simd v0.1.2
   Compiling scoped-tls v1.0.0
   Compiling version_check v0.9.2
   Compiling rustc-ap-rustc_target v662.0.0
   Compiling rustc-ap-rustc_ast v662.0.0
   Compiling annotate-snippets v0.6.1
   Compiling termcolor v1.1.0
   Compiling unicode-segmentation v1.6.0
   Compiling rustc-ap-rustc_fs_util v662.0.0
   Compiling ansi_term v0.11.0
   Compiling tinyvec v0.3.3
   Compiling strsim v0.8.0
   Compiling vec_map v0.8.2
   Compiling fixedbitset v0.2.0
   Compiling arrayvec v0.5.1
   Compiling json v0.12.4
   Compiling rustc-ap-rustc_lexer v662.0.0
   Compiling crossbeam-utils v0.6.6
   Compiling semver v0.9.0
   Compiling lock_api v0.3.4
   Compiling memoffset v0.5.5
   Compiling crossbeam-utils v0.7.2
   Compiling crossbeam-epoch v0.8.2
   Compiling indexmap v1.4.0
   Compiling textwrap v0.11.0
   Compiling getopts v0.2.21
   Compiling block-padding v0.1.5
   Compiling proc-macro-error-attr v1.0.3
   Compiling proc-macro-error v1.0.3
   Compiling heck v0.3.1
   Compiling unicode-normalization v0.1.13
   Compiling crossbeam-queue v0.1.2
   Compiling rustc_version v0.2.3
   Compiling psm v0.1.10
   Compiling stacker v0.1.9
   Compiling smallvec v0.6.13
   Compiling parking_lot_core v0.6.2
   Compiling parking_lot v0.9.0
   Compiling quote v1.0.7
   Compiling num_cpus v1.13.0
   Compiling parking_lot_core v0.7.2
   Compiling memmap v0.7.0
   Compiling jobserver v0.1.21
   Compiling atty v0.2.14
   Compiling termize v0.1.1
   Compiling ena v0.14.0
   Compiling generic-array v0.12.3
   Compiling parking_lot v0.10.2
   Compiling clap v2.33.1
   Compiling colored v1.9.3
   Compiling block-buffer v0.7.3
   Compiling digest v0.8.1
   Compiling rustc-ap-serialize v662.0.0
   Compiling petgraph v0.5.1
   Compiling once_cell v1.4.0
   Compiling crossbeam-deque v0.7.3
   Compiling sha-1 v0.8.2
   Compiling md-5 v0.8.0
   Compiling rustc-ap-rustc_index v662.0.0
   Compiling synstructure v0.12.4
   Compiling syn-mid v0.5.0
   Compiling measureme v0.7.1
   Compiling rustc-rayon v0.3.0
   Compiling rustc-ap-rustc_data_structures v662.0.0
   Compiling rustc-ap-arena v662.0.0
error[E0599]: no method named `reserve_in_place` found for struct `alloc::raw_vec::RawVec<T>` in the current scope
   --> /Users/austin/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-arena-662.0.0/lib.rs:228:39
    |
228 |                 if last_chunk.storage.reserve_in_place(currently_used_cap, n) {
    |                                       ^^^^^^^^^^^^^^^^ method not found in `alloc::raw_vec::RawVec<T>`

error[E0599]: no method named `reserve_in_place` found for struct `alloc::raw_vec::RawVec<u8>` in the current scope
   --> /Users/austin/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-arena-662.0.0/lib.rs:356:39
    |
356 |                 if last_chunk.storage.reserve_in_place(used_bytes, needed_bytes) {
    |                                       ^^^^^^^^^^^^^^^^ method not found in `alloc::raw_vec::RawVec<u8>`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0599`.
error: could not compile `rustc-ap-arena`.

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: failed to compile `cargo-modules v0.4.7`, intermediate artifacts can be found at `/var/folders/6t/2xp3hp2j1vd5yyklq0b6_lbw0000gn/T/cargo-installo1LFmn`

Caused by:
  build failed

Installation error

Hi, I tried to install cargo-modules but I got the following error:

$ cargo install cargo-modules
...
Compiling rustc-ap-rustc_arena v693.0.0
error[E0635]: unknown feature `array_value_iter_slice`
  --> /home/albtam/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_arena-693.0.0/src/lib.rs:14:12
   |
14 | #![feature(array_value_iter_slice)]
   |            ^^^^^^^^^^^^^^^^^^^^^^

   Compiling getopts v0.2.21
error: aborting due to previous error

For more information about this error, try `rustc --explain E0635`.
error: could not compile `rustc-ap-rustc_arena`

and with verbose if that helps:

Compiling rustc-ap-rustc_arena v693.0.0
     Running `rustc --crate-name rustc_ap_rustc_arena --edition=2018 /home/albtam/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_arena-693.0.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no -C metadata=10bb1db7a81609ce -C extra-filename=-10bb1db7a81609ce --out-dir /tmp/cargo-install7GR5hG/release/deps -L dependency=/tmp/cargo-install7GR5hG/release/deps --extern smallvec=/tmp/cargo-install7GR5hG/release/deps/libsmallvec-6532dd85c8bdaefe.rmeta --cap-lints allow`
     Running `/tmp/cargo-install7GR5hG/release/build/maybe-uninit-7ed2d5a787a172fd/build-script-build`
     Running `/tmp/cargo-install7GR5hG/release/build/getrandom-790df76103279c00/build-script-build`
     Running `/tmp/cargo-install7GR5hG/release/build/typenum-7c639c7a3a22b461/build-script-main`
error[E0635]: unknown feature `array_value_iter_slice`
  --> /home/albtam/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_arena-693.0.0/src/lib.rs:14:12
   |
14 | #![feature(array_value_iter_slice)]
   |            ^^^^^^^^^^^^^^^^^^^^^^

I am using Rust nightly:

$ rustup default nightly
info: using existing install for 'nightly-x86_64-unknown-linux-gnu'
info: default toolchain set to 'nightly-x86_64-unknown-linux-gnu'

  nightly-x86_64-unknown-linux-gnu unchanged - rustc 1.52.0-nightly (107896c32 2021-03-15)

Am I doing something wrong? (I'm a Rust newbie)

Cannot compile rustc-ap-syntax on latest nightly

error[E0046]: not all trait items implemented, missing: mixed_site
--> /home/leandro/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-syntax-583.0.0/ext/proc_macro_server.rs:657:1
|
657 | impl server::Span for Rustc<'_> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing mixed_site in implementation
|
= note: mixed_site from trait: fn(&mut Self) -> <Self as proc_macro::bridge::server::Types>::Span

error: aborting due to previous error

For more information about this error, try rustc --explain E0046.
error: could not compile rustc-ap-syntax.
warning: build failed, waiting for other jobs to finish...
error: build failed

Disable panic backtrace if an error occured

I just thought it was a bug when I've ran this extension and got a big panic backtrace. It took me a while when I actually noticed a readable error message and suggestion with fix at the top.
May be it will be better to remove useless panic backtrace printing?

Crate does not compile with latest rust suite 1.55

I tried to install cargo-moduleswith latest rust version 1.55 (rustc 1.55.0 (c8dfcfe04 2021-09-06) using latest docker image rust:1.55 and nativ on MacOSX). The command cargo install cargo-modules print the error message

   Compiling ra_ap_ide_db v0.0.72
error[E0432]: unresolved import `base_db::salsa::SweepStrategy`
 --> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/ra_ap_ide_db-0.0.72/src/apply_change.rs:6:35
  |
6 |     salsa::{Database, Durability, SweepStrategy},
  |                                   ^^^^^^^^^^^^^ no `SweepStrategy` in `salsa`

error[E0599]: no method named `sweep` found for struct `QueryTable` in the current scope
  --> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/ra_ap_ide_db-0.0.72/src/apply_change.rs:50:41
   |
50 |         base_db::ParseQuery.in_db(self).sweep(sweep);
   |                                         ^^^^^ method not found in `QueryTable<'_, ParseQuery>`

and many more (see attached file). It ends with

error: failed to compile `cargo-modules v0.5.4`, intermediate artifacts can be found at `/tmp/cargo-installSx2FpJ`

Caused by:
  build failed

modules.log

Differentiate between modules with the same name

It's valid in Rust to have equally named modules to appear in different places of module hierarchy. cargo-modules shows them as 2 entries with the same name and just looking at that picture there is no way to understand where which modules is shown. One option to resolve this is to allow full module paths to be used or just to show with a parent module if there are any name clashes.

Build fails with trait not implemented

Hi,
Thanks for the awesome tool!

I would like to work on updating the documentation to match the current CLI. When I run cargo test on current HEAD, I get:

$ cargo test
   Compiling semver-parser v0.7.0
   Compiling nodrop v0.1.13
   Compiling libc v0.2.45
   Compiling cfg-if v0.1.6
   Compiling void v1.0.2
   Compiling rand_core v0.3.0
   Compiling memoffset v0.2.1
   Compiling lazy_static v1.2.0
   Compiling scopeguard v0.3.3
   Compiling stable_deref_trait v1.1.1
   Compiling rustc-rayon-core v0.1.1
   Compiling either v1.5.0
   Compiling unicode-width v0.1.5
   Compiling proc-macro2 v0.4.24
   Compiling bitflags v1.0.4
   Compiling byteorder v1.2.7
   Compiling unicode-xid v0.1.0
   Compiling rustc-ap-graphviz v312.0.0
   Compiling scoped-tls v0.1.2
   Compiling unicode-segmentation v1.2.1
error[E0277]: the trait bound `std::borrow::Cow<'_, str>: std::convert::From<core::str::EscapeDefault<'_>>` is not satisfied
   --> /home/muhuk/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-graphviz-312.0.0/lib.rs:551:44
    |
551 |                     (&*s).escape_default().into()
    |                                            ^^^^ the trait `std::convert::From<core::str::EscapeDefault<'_>>` is not implemented for `std::borrow::Cow<'_, str>`
    |
    = help: the following implementations were found:
              <std::borrow::Cow<'a, [T]> as std::convert::From<&'a [T]>>
              <std::borrow::Cow<'a, [T]> as std::convert::From<&'a std::vec::Vec<T>>>
              <std::borrow::Cow<'a, [T]> as std::convert::From<std::vec::Vec<T>>>
              <std::borrow::Cow<'a, std::ffi::CStr> as std::convert::From<&'a std::ffi::CStr>>
            and 11 others
    = note: required because of the requirements on the impl of `std::convert::Into<std::borrow::Cow<'_, str>>` for `core::str::EscapeDefault<'_>`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
   Compiling rustc-ap-rustc_target v312.0.0
error: Could not compile `rustc-ap-graphviz`.
warning: build failed, waiting for other jobs to finish...
error: build failed

I have tried with rustc-ap-graphviz v312.

Version 373.0.0 seems to work, though I haven't yet do a manual test on an actual project.

Failed to compile with Rust 1.25

Rust Version: 1.25
Cargo Version: 0.26

error[E0433]: failed to resolve. Could not find `VisibilityKind` in `ast`
  --> src/builder.rs:86:59
   |
86 |                 let visibility = if item.vis.node == ast::VisibilityKind::Public {
   |                                                           ^^^^^^^^^^^^^^ Could not find `VisibilityKind` in `ast`

error[E0554]: #![feature] may not be used on the stable release channel
 --> src/main.rs:1:1
  |
1 | #![feature(rustc_private)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors

error: failed to compile `cargo-modules v0.3.6`, intermediate artifacts can be found at `/var/folders/gl/j2cw1zks3ws2qkwqfl_bjwyw0000gp/T/cargo-install.kgfHsMtbq1IV`

Does not compile on stable

error[E0554]: #![feature] may not be used on the stable release channel
--> .cargo\registry\src\github.com-1ecc6299db9ec823\cargo-modules-0.3.5\src\main.rs:1:1
|
1 | #![feature(rustc_private)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

error: failed to compile cargo-modules v0.3.5

Support for cargo workspaces

I have a project making use of a cargo workspace, but only the main crate is revealed when I issue a cargo modules command.

Great tool, thank you!

Cannot compile rustc-ap-syntax on latest nightly

$ rustc -V
rustc 1.30.0-nightly (aaa170beb 2018-08-31)
$ cargo install cargo-modules

...

error: found removed `do catch` syntax
    --> /Users/ykoma/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-syntax-230.0.0/parse/parser.rs:1761:43
     |
1761 |             let pat_arg: PResult<'a, _> = do catch {
     |                                           ^^
     |
     = help: Following RFC #2388, the new non-placeholder syntax is `try`

error: aborting due to previous error

error: failed to compile `cargo-modules v0.4.2`, intermediate artifacts can be found at `/var/folders/0v/t6gp2nld5ndggd9lr_mg47lc0000gn/T/cargo-installk3A2XA`

Caused by:
  Could not compile `rustc-ap-syntax`.

To learn more, run the command again with --verbose.
$

Fails to compile during installation

Trying to install this crate with
cargo install cargo-modules
or
cargo +nightly install --git https://github.com/regexident/cargo-modules cargo-modules
fails with a following error:

   Compiling rustc-ap-arena v460.0.0
error[E0599]: no method named `cap` found for type `alloc::raw_vec::RawVec<T>` in the current scope
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-arena-460.0.0/lib.rs:102:47
    |
102 |                 self.start().add(self.storage.cap())
    |                                               ^^^ private field, not a method

error[E0599]: no method named `cap` found for type `alloc::raw_vec::RawVec<T>` in the current scope
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-arena-460.0.0/lib.rs:273:55
    |
273 |                     new_capacity = last_chunk.storage.cap();
    |                                                       ^^^ private field, not a method

error[E0599]: no method named `cap` found for type `alloc::raw_vec::RawVec<u8>` in the current scope
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-arena-460.0.0/lib.rs:408:55
    |
408 |                     new_capacity = last_chunk.storage.cap();
    |                                                       ^^^ private field, not a method

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0599`.
error: could not compile `rustc-ap-arena`.
warning: build failed, waiting for other jobs to finish...
error: failed to compile `cargo-modules v0.4.4 (https://github.com/regexident/cargo-modules#47498fa0)`, intermediate artifacts can be found at `/tmp/cargo-install51cOgo`

Caused by:
  build failed

Compiler: rustc 1.39.0-nightly (9b9d2aff8 2019-09-19)

Term colors does not work properly on windows

Here is output:

←[1;32mPublic modules←[0m
←[1;33mPrivate modules←[0m
←[1;32msciter←[0m
←[1;34m ├── ←[0m←[1;33mcapi←[0m
←[1;34m │   ├── ←[0m←[1;33mscapi←[0m
←[1;34m │   ├── ←[0m←[1;33mscbehavior←[0m
←[1;34m │   ├── ←[0m←[1;33mscdef←[0m
←[1;34m │   ├── ←[0m←[1;33mscdom←[0m
←[1;34m │   ├── ←[0m←[1;33mscgraphics←[0m
←[1;34m │   ├── ←[0m←[1;33mschandler←[0m
←[1;34m │   ├── ←[0m←[1;33mscrequest←[0m
←[1;34m │   ├── ←[0m←[1;33msctiscript←[0m
←[1;34m │   ├── ←[0m←[1;33msctypes←[0m
←[1;34m │   └── ←[0m←[1;33mscvalue←[0m
←[1;34m ├── ←[0m←[1;32mdom←[0m

rustc-ap-rustc_data_structures fails to compile

cargo-modules fails to compile when building its dependency rustc-ap-rustc_data_structures. It probably should use a newer version - 692.0.0 instead of 673.0.0.

Checked on rustc 1.50.0-nightly (e792288df 2020-12-05).

cargo +nightly install cargo-modules
(...)
Compiling rustc-ap-rustc_data_structures v673.0.0
error[E0557]: feature has been removed
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_data_structures-673.0.0/lib.rs:16:12
   |
16 | #![feature(optin_builtin_traits)]
   |            ^^^^^^^^^^^^^^^^^^^^ feature has been removed
   |
   = note: renamed to `auto_traits`

error[E0658]: auto traits are experimental and possibly buggy
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_data_structures-673.0.0/sync.rs:30:9
   |
30 |         pub auto trait Send {}
   |         ^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #13231 <https://github.com/rust-lang/rust/issues/13231> for more information
   = help: add `#![feature(auto_traits)]` to the crate attributes to enable

error[E0658]: auto traits are experimental and possibly buggy
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_data_structures-673.0.0/sync.rs:31:9
   |
31 |         pub auto trait Sync {}
   |         ^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #13231 <https://github.com/rust-lang/rust/issues/13231> for more information
   = help: add `#![feature(auto_traits)]` to the crate attributes to enable

   Compiling structopt v0.3.21
error: aborting due to 3 previous errors

Some errors have detailed explanations: E0557, E0658.
For more information about an error, try `rustc --explain E0557`.
error: failed to compile `cargo-modules v0.4.9`, intermediate artifacts can be found at `/tmp/cargo-installK6pcGj`

Caused by:
  could not compile `rustc-ap-rustc_data_structures`

To learn more, run the command again with --verbose.

Ignore `build.rs` even if not listed in Cargo.toml

As of lately cargo detects build.rs build-scripts even if they are not listed:

[package]
# ...
build = "build.rs"

"The Rust file designated by the build command (relative to the package root) will be compiled and invoked before anything else is compiled in the package, allowing your Rust code to depend on the built or generated artifacts. Note that if you do not specify a value for build but your package root does contains a "build.rs" file, Cargo will compile and invoke this file for you." – http://doc.crates.io/build-script.html

As such cargo modules should do so, too.

compile fails: method `replace_one` is not a member of trait `std::iter::Step`

I'm running nightly (cargo +nightly --version reports cargo 1.45.0-nightly (9fcb8c1d2 2020-05-25) and I'm seeing cargo +nightly install cargo-modules fail as it tries to build the rustc-ap-rustc_span crate. I might be doing something wrong, but I did notice that that crate is now up to version 661, whereas cargo-module has a Cargo.toml that calls for only version 657.

The full error is here:

   Compiling rustc-ap-rustc_span v657.0.0
error[E0407]: method `replace_one` is not a member of trait `std::iter::Step`
  --> /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_span-657.0.0/def_id.rs:11:1
   |
11 | / rustc_index::newtype_index! {
12 | |     pub struct CrateId {
13 | |         ENCODABLE = custom
14 | |     }
15 | | }
   | |_^ not a member of trait `std::iter::Step`
   |
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0407]: method `replace_zero` is not a member of trait `std::iter::Step`
  --> /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_span-657.0.0/def_id.rs:11:1
   |
11 | / rustc_index::newtype_index! {
12 | |     pub struct CrateId {
13 | |         ENCODABLE = custom
14 | |     }
15 | | }
   | |_^ not a member of trait `std::iter::Step`
   |
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0407]: method `add_one` is not a member of trait `std::iter::Step`
  --> /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_span-657.0.0/def_id.rs:11:1
   |
11 | / rustc_index::newtype_index! {
12 | |     pub struct CrateId {
13 | |         ENCODABLE = custom
14 | |     }
15 | | }
   | |_^ not a member of trait `std::iter::Step`
   |
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0407]: method `sub_one` is not a member of trait `std::iter::Step`
  --> /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_span-657.0.0/def_id.rs:11:1
   |
11 | / rustc_index::newtype_index! {
12 | |     pub struct CrateId {
13 | |         ENCODABLE = custom
14 | |     }
15 | | }
   | |_^ not a member of trait `std::iter::Step`
   |
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0407]: method `add_usize` is not a member of trait `std::iter::Step`
  --> /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_span-657.0.0/def_id.rs:11:1
   |
11 | / rustc_index::newtype_index! {
12 | |     pub struct CrateId {
13 | |         ENCODABLE = custom
14 | |     }
15 | | }
   | |_^ not a member of trait `std::iter::Step`
   |
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0407]: method `sub_usize` is not a member of trait `std::iter::Step`
  --> /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_span-657.0.0/def_id.rs:11:1
   |
11 | / rustc_index::newtype_index! {
12 | |     pub struct CrateId {
13 | |         ENCODABLE = custom
14 | |     }
15 | | }
   | |_^ not a member of trait `std::iter::Step`
   |
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0407]: method `replace_one` is not a member of trait `std::iter::Step`
   --> /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_span-657.0.0/def_id.rs:118:1
    |
118 | / rustc_index::newtype_index! {
119 | |     /// A DefIndex is an index into the hir-map for a crate, identifying a
120 | |     /// particular definition. It should really be considered an interned
121 | |     /// shorthand for a particular DefPath.
...   |
128 | |     }
129 | | }
    | |_^ not a member of trait `std::iter::Step`
    |
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0407]: method `replace_zero` is not a member of trait `std::iter::Step`
   --> /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_span-657.0.0/def_id.rs:118:1
    |
118 | / rustc_index::newtype_index! {
119 | |     /// A DefIndex is an index into the hir-map for a crate, identifying a
120 | |     /// particular definition. It should really be considered an interned
121 | |     /// shorthand for a particular DefPath.
...   |
128 | |     }
129 | | }
    | |_^ not a member of trait `std::iter::Step`
    |
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0407]: method `add_one` is not a member of trait `std::iter::Step`
   --> /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_span-657.0.0/def_id.rs:118:1
    |
118 | / rustc_index::newtype_index! {
119 | |     /// A DefIndex is an index into the hir-map for a crate, identifying a
120 | |     /// particular definition. It should really be considered an interned
121 | |     /// shorthand for a particular DefPath.
...   |
128 | |     }
129 | | }
    | |_^ not a member of trait `std::iter::Step`
    |
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0407]: method `sub_one` is not a member of trait `std::iter::Step`
   --> /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_span-657.0.0/def_id.rs:118:1
    |
118 | / rustc_index::newtype_index! {
119 | |     /// A DefIndex is an index into the hir-map for a crate, identifying a
120 | |     /// particular definition. It should really be considered an interned
121 | |     /// shorthand for a particular DefPath.
...   |
128 | |     }
129 | | }
    | |_^ not a member of trait `std::iter::Step`
    |
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0407]: method `add_usize` is not a member of trait `std::iter::Step`
   --> /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_span-657.0.0/def_id.rs:118:1
    |
118 | / rustc_index::newtype_index! {
119 | |     /// A DefIndex is an index into the hir-map for a crate, identifying a
120 | |     /// particular definition. It should really be considered an interned
121 | |     /// shorthand for a particular DefPath.
...   |
128 | |     }
129 | | }
    | |_^ not a member of trait `std::iter::Step`
    |
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0407]: method `sub_usize` is not a member of trait `std::iter::Step`
   --> /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_span-657.0.0/def_id.rs:118:1
    |
118 | / rustc_index::newtype_index! {
119 | |     /// A DefIndex is an index into the hir-map for a crate, identifying a
120 | |     /// particular definition. It should really be considered an interned
121 | |     /// shorthand for a particular DefPath.
...   |
128 | |     }
129 | | }
    | |_^ not a member of trait `std::iter::Step`
    |
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0407]: method `replace_one` is not a member of trait `std::iter::Step`
    --> /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_span-657.0.0/symbol.rs:1034:1
     |
1034 | / rustc_index::newtype_index! {
1035 | |     pub struct SymbolIndex { .. }
1036 | | }
     | |_^ not a member of trait `std::iter::Step`
     |
     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0407]: method `replace_zero` is not a member of trait `std::iter::Step`
    --> /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_span-657.0.0/symbol.rs:1034:1
     |
1034 | / rustc_index::newtype_index! {
1035 | |     pub struct SymbolIndex { .. }
1036 | | }
     | |_^ not a member of trait `std::iter::Step`
     |
     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0407]: method `add_one` is not a member of trait `std::iter::Step`
    --> /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_span-657.0.0/symbol.rs:1034:1
     |
1034 | / rustc_index::newtype_index! {
1035 | |     pub struct SymbolIndex { .. }
1036 | | }
     | |_^ not a member of trait `std::iter::Step`
     |
     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0407]: method `sub_one` is not a member of trait `std::iter::Step`
    --> /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_span-657.0.0/symbol.rs:1034:1
     |
1034 | / rustc_index::newtype_index! {
1035 | |     pub struct SymbolIndex { .. }
1036 | | }
     | |_^ not a member of trait `std::iter::Step`
     |
     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0407]: method `add_usize` is not a member of trait `std::iter::Step`
    --> /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_span-657.0.0/symbol.rs:1034:1
     |
1034 | / rustc_index::newtype_index! {
1035 | |     pub struct SymbolIndex { .. }
1036 | | }
     | |_^ not a member of trait `std::iter::Step`
     |
     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0407]: method `sub_usize` is not a member of trait `std::iter::Step`
    --> /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_span-657.0.0/symbol.rs:1034:1
     |
1034 | / rustc_index::newtype_index! {
1035 | |     pub struct SymbolIndex { .. }
1036 | | }
     | |_^ not a member of trait `std::iter::Step`
     |
     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0200]: the trait `std::iter::Step` requires an `unsafe impl` declaration
  --> /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_span-657.0.0/def_id.rs:11:1
   |
11 | / rustc_index::newtype_index! {
12 | |     pub struct CrateId {
13 | |         ENCODABLE = custom
14 | |     }
15 | | }
   | |_^
   |
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0200]: the trait `std::iter::Step` requires an `unsafe impl` declaration
   --> /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_span-657.0.0/def_id.rs:118:1
    |
118 | / rustc_index::newtype_index! {
119 | |     /// A DefIndex is an index into the hir-map for a crate, identifying a
120 | |     /// particular definition. It should really be considered an interned
121 | |     /// shorthand for a particular DefPath.
...   |
128 | |     }
129 | | }
    | |_^
    |
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0200]: the trait `std::iter::Step` requires an `unsafe impl` declaration
    --> /home/warner/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_span-657.0.0/symbol.rs:1034:1
     |
1034 | / rustc_index::newtype_index! {
1035 | |     pub struct SymbolIndex { .. }
1036 | | }
     | |_^
     |
     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 21 previous errors

Some errors have detailed explanations: E0200, E0407.
For more information about an error, try `rustc --explain E0200`.
error: could not compile `rustc-ap-rustc_span`.

Show module type definitions

Hello, what do you guys think about adding a flag for showing the types defined in a module? This might seem out of scope for this project, but it is sort of an extension of the module tree in a syntactic meaning, because of the way you reference types in other modules.

This could be extended for functions aswell, maybe even methods or trait implementations

I imagine this to look something like this:

% cargo modules --enable-edition-2018 tree --types
server : crate
 ├── websocket : private
 ├── message_stream : orphan
 │    ├── struct MessageStream
 │    └── impl futures::Stream for MessageStream
 └── websocket : private
     ├── struct WebSocket
     │    ├── fn new(host: &str) -> Self
     │    └── fn close(&self)
     └── enum Msg

cannot compile #![feature(optin_builtin_traits)]

cargo --version
cargo 1.50.0-nightly (bfca1cd22 2020-11-24)
cargo +nightly install cargo-modules

  --> /home/alexandre/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_data_structures-693.0.0/src/sync.rs:30:9
   |
30 |         pub auto trait Send {}
   |         ^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #13231 <https://github.com/rust-lang/rust/issues/13231> for more information
   = help: add `#![feature(optin_builtin_traits)]` to the crate attributes to enable

error[E0658]: auto traits are experimental and possibly buggy
  --> /home/alexandre/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_data_structures-693.0.0/src/sync.rs:31:9
   |
31 |         pub auto trait Sync {}
   |         ^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #13231 <https://github.com/rust-lang/rust/issues/13231> for more information
   = help: add `#![feature(optin_builtin_traits)]` to the crate attributes to enable

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0658`.
error: failed to compile `cargo-modules v0.4.10`, intermediate artifacts can be found at `/tmp/cargo-installKkbYC7`

Caused by:
  could not compile `rustc-ap-rustc_data_structures`

To learn more, run the command again with --verbose.

internal compiler error: Error constructed but not emitted

When running cargo modules tree (cargo-modules 0.4.3) on a crate which cannot compile, an internal compiler error is emitted. For example, create a crate and introduce an obvious error:

$ cargo init reproduce --lib
$ cd reproduce
$ cat > src/lib.rs <<EOF
# src/lib.rs
mod does_not_exist;
EOF
$ RUST_BACKTRACE=1 rustup run nightly cargo modules tree
error: internal compiler error: Error constructed but not emitted

thread 'main' panicked at 'explicit panic', /home/evnu/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_errors-263.0.0/diagnostic_builder.rs:308:13
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:476
   5: std::panicking::begin_panic
   6: <rustc_errors::diagnostic_builder::DiagnosticBuilder<'a> as core::ops::drop::Drop>::drop
   7: <scoped_tls::ScopedKey<T>>::set
   8: syntax::with_globals
   9: cargo_modules::main
  10: std::rt::lang_start::{{closure}}
  11: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
  12: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:102
  13: std::rt::lang_start_internal
             at libstd/panicking.rs:289
             at libstd/panic.rs:392
             at libstd/rt.rs:58
  14: main
  15: __libc_start_main
  16: _start

Can this be handled by cargo-modules?

Option to disable module nodes in graph

I'd love to use cargo modules as a tool to optimize my project's module structure. When rendering items and their interdependencies, the output looks very messy:
image

If it were possible to disable modules nodes, this graph would look significantly cleaner but still contain the information about item interdependencies.

`cargo-modules -V` should print the version

cargo-modules -V doesn't print the version.

$ cargo-modules -V
cargo-modules

Surely the version info can be retrieved from ~/.cargo/.crates.toml however it's a bit inconvenient.

Using rust-analyzer

From rust-lang/rust-analyzer#4405, you guys can use RA to run this.

I have a visitor trait code (I can extract this to a separate crate) you guys can use.

But from what I understand, you guys do not need it and can do something like this

Support crates that use impl trait

I think this is as simple as bumping the syntex dependency to 0.42. The current failure is:

$ cargo modules
error: internal compiler error: Error constructed but not emitted
thread 'main' panicked at 'explicit panic', ~/.cargo/registry/src/github.com-1ecc6299db9ec823/syntex_syntax-0.36.0/src/errors/mod.rs:370
note: Run with `RUST_BACKTRACE=1` for a backtrace.

Modules in subdirectories are not shown

This code produces output as expected:

pub mod mod1 {
    mod mod2 {
        pub fn mod2_fn() {}
    }

    mod mod3 {
        use crate::mod1::mod2;

        pub fn mod3_fn() {
            mod2::mod2_fn()
        }
    }

    pub use mod3::mod3_fn;
}

pub fn crate_fn() {
    mod1::mod3_fn()
}
# cargo modules tree

temp : crate
 └── mod1 : public
     ├── mod2 : private
     └── mod3 : private

However when I move the same code into a standard directory structure there is almost no output from cargo modules:

# find . -name "*.rs"
./src/lib.rs
./src/mod1/mod.rs
./src/mod1/mod3.rs
./src/mod1/mod2.rs
# cargo modules tree

temp : crate
 └── mod1 : public

cargo modules graph is affected in the same way.

I installed cargo modules using nightly toolchain 2020-10-19.

Doesn't understand cfg-if

Cargo-modules tries to show the full dependency graph including all conditional dependencies. However, it doesn't understand the popular cfg-if macro, leading to missing dependencies. As an example, create a crate with four empty files: src/{foo, bar, baz, bean}.rs, and main.rs having the following content:

use cfg_if::cfg_if;

cfg_if! {
    if #[cfg(test)] {
        pub use self::foo;
    } else {
        pub use self::bar;
    }
}

#[cfg(test)]
pub use self::baz;

#[cfg(not(test))]
pub use self::bean;

cargo-modules gives the following output:

digraph {
    label="cmci";
    pad=0.4;

    // Modules
    "cmci" [label="cmci", color=green4, fontcolor=green4 style=filled, fillcolor=greenyellow]

    // Hierarchy
    "cmci" -> "cmci::bar" [weight=50, color=firebrick4, penwidth=1]
    "cmci" -> "cmci::foo" [weight=50, color=firebrick4, penwidth=1]
    "cmci" -> "cmci::baz" [weight=50, color=firebrick4, penwidth=1]
    "cmci" -> "cmci::bean" [weight=50, color=firebrick4, penwidth=1]

    // Dependencies
    "cmci" -> "cmci::baz" [weight=90, color=azure3, penwidth=2, label=<<FONT POINT-SIZE="10" COLOR="azure3">use <B>self</B></FONT>>]
    "cmci" -> "cmci::bean" [weight=90, color=azure3, penwidth=2, label=<<FONT POINT-SIZE="10" COLOR="azure3">use <B>self</B></FONT>>]
}

Notice that the cmci->cmci::foo and cmci->cmci::bar dependencies are missing.

Could not compile scoped-tls on nighly

Hello, this project seems really promising! But I'm having trouble installing the tool. Please let me know if I'm doing something wrong. Here is my error message:

olega@DESKTOP-B47K2S5 MINGW64 ~/Documents/Rust/udemy (master)
$ rustup default nightly
info: using existing install for 'nightly-x86_64-pc-windows-msvc'
info: default toolchain set to 'nightly-x86_64-pc-windows-msvc'

  nightly-x86_64-pc-windows-msvc unchanged - rustc 1.40.0-nightly (518deda77 2019-10-18)


olega@DESKTOP-B47K2S5 MINGW64 ~/Documents/Rust/udemy (master)
$ cargo install cargo-modules
    Updating crates.io index
  Installing cargo-modules v0.4.4
   Compiling winapi v0.3.8
   Compiling cfg-if v0.1.10
   Compiling lazy_static v1.4.0
   Compiling semver-parser v0.7.0
   Compiling arrayvec v0.4.12
   Compiling scopeguard v0.3.3
   Compiling bitflags v1.2.1
   Compiling libc v0.2.65
   Compiling nodrop v0.1.14
   Compiling memoffset v0.2.1
   Compiling rand_core v0.4.2
   Compiling log v0.4.8
   Compiling unicode-width v0.1.6
   Compiling rustc-rayon-core v0.1.2
   Compiling byteorder v1.3.2
   Compiling stable_deref_trait v1.1.1
   Compiling smallvec v0.6.10
   Compiling rustc-rayon v0.1.2
   Compiling autocfg v0.1.6
   Compiling either v1.5.3
   Compiling proc-macro2 v0.4.30
   Compiling rustc-ap-graphviz v373.0.0
   Compiling unicode-xid v0.1.0
   Compiling cgmath v0.16.1
   Compiling syn v0.15.44
   Compiling unicode-segmentation v1.3.0
   Compiling rustc-ap-rustc_target v373.0.0
   Compiling approx v0.1.1
   Compiling scoped-tls v0.1.2
error: allow_internal_unstable expects list of feature names
  --> C:\Users\olega\.cargo\registry\src\github.com-1ecc6299db9ec823\scoped-tls-0.1.2\src\lib.rs:71:1
   |
71 | #[allow_internal_unstable]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

   Compiling rgb v0.8.14
error: could not compile `scoped-tls`.
warning: build failed, waiting for other jobs to finish...
error: failed to compile `cargo-modules v0.4.4`, intermediate artifacts can be found at `C:\Users\olega\AppData\Local\Temp\cargo-installPd81Wa`

Caused by:
  build failed

Improvements for alternative color-less mode

cargo-modules in its current and initial release makes use of ANSI terminal colors for distinguishing between different "types" of modules. This unfortunately not only alienates Windows users (due to a lack of Windows support by the colored crate), and those with a dark-on-light terminal theme, but even worse: it alienates color-blind users. That's unacceptable to me.


There are currently four different colors used for distinguishing between:

  • test modules
  • public modules
  • private modules
  • orphaned modules

How would you for an alternative plain display mode prefer the tree to be presented?

Please feel free to leave comments and/or alternative suggestions in the comments.


There are basically three usage scenarios to cover here:

  • user has terminal with color support and prefers colored tree.
  • user has terminal with color support and prefers plain tree.
  • user has terminal without color support and has no choice.

So looking at this I'm wondering if colored output should actually be made opt-in via --colors?

Panic with rustc 1.27.0-nightly (4b9b70c39 2018-04-09)

Sorry if this is not caused by cargo-modules.

Running cargo modules panics.

$ cargo new modules-test
     Created binary (application) `modules-test` project
$ cd modules-test/
$ cargo +nightly modules
thread 'main' panicked at 'cannot access a scoped thread local variable without calling `set` first', /cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.1/src/lib.rs:186:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.

Meta:

$ rustc +nightly --version
rustc 1.27.0-nightly (4b9b70c39 2018-04-09)

$ cargo +nightly modules --version
cargo-modules 0.3.6

Backtrace:

$ RUST_BACKTRACE=1 cargo +nightly modules
thread 'main' panicked at 'cannot access a scoped thread local variable without calling `set` first', /cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.1/src/lib.rs:186:9
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:206
   3: std::panicking::default_hook
             at libstd/panicking.rs:222
   4: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:400
   5: std::panicking::begin_panic
   6: <scoped_tls::ScopedKey<T>>::with
   7: syntax_pos::symbol::Ident::from_str
   8: syntax::parse::lexer::StringReader::next_token_inner
   9: syntax::parse::lexer::StringReader::advance_token
  10: syntax::parse::lexer::StringReader::new
  11: syntax::parse::filemap_to_stream
  12: syntax::parse::filemap_to_parser
  13: syntax::parse::parse_crate_from_file
  14: cargo_modules::main
  15: std::rt::lang_start::{{closure}}
  16: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:305
  17: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:102
  18: std::rt::lang_start_internal
             at libstd/panicking.rs:284
             at libstd/panic.rs:361
             at libstd/rt.rs:58
  19: main
  20: __libc_start_main
  21: _start

Module graph missing links

Hi all! This is one great project, and I'm looking forward to use to for good.
Just trying it on WebRender, I'm missing quite a few links in the generated module graph:

mod-graph

This was generated via the following command, using the code from #50 :

cargo-modules --enable-edition-2018 graph | dot -Tpng > mod-graph.png

I removed the top-level Cargo.toml to convince it that it's not a cargo workspace (otherwise it doesn't work at all, see #8 (comment)).
It shows the graph to be pretty flat, even though the modules clearly depend on each other a lot. For example, no arrows originate from batch module, even though it clearly uses a whole bunch of stuff.

Is this a known issue? Is it related to 2018 edition (cc @muhuk)? Anything I could help with to investigate?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.