Can't dump compiler dependencies graph

Good day!

I have a trivial test app:

fn bar() {
    let y = 25;

fn main() {
    let x = 123456;

I read Guide and try to dump a compiler dependencies graph as described with command

cargo rustc -- -Z dump-dep-graph

It works fine and creates giant dep_graph.txt. But when I try to filter this graph by setting environment variable (Windows 7)

set RUST_DEP_GRAPH_FILTER="Hir&bar ->"

then empty graph outputs.
I try to set many other values of this env variable but empty dep_graph.txt outputs always.

Is this Guide actual about RUST_DEP_GRAPH_FILTER?
Help please: how to get filtered dependencies graph in Windows.

I find that "Hir&bar ->" returns an empty graph, but "-> Hir&bar" returns a graph with several nodes.

I think this is just because there are no rules with Hir(bar) on the left side, so there's nothing reachable from that node, and therefore your filter is filtering out everything.

I tried...
Unfortunately "-> Hir&bar" and many-many other alternatives outputs only empty graph for me.

Are you use Windows and "set" command?

Make sure you force rustc to re-run, by changing the modification date of your file or by running cargo clean before cargo rustc. Otherwise, the Cargo command will do nothing if your program was previously built. (You can delete the dep_graph.txt file between runs to check whether it is regenerated or not.)

No, sorry.

Thank you. I do all of this. Before every attempt I'm change source file, delete dep-graph output files and sure that after changing environment variable output files really updates.

Problem solved.
When I use Windows "set" command

set RUST_DEP_GRAPH_FILTER="-> Hir&bar"

then there are three problems:

  1. value is case sensitive. So "Hir" is wrong, but "hir" is right.
  2. Windows includes double quotes in RUST_DEP_GRAPH_FILTER value. So they must be eliminated.
  3. Without doublequotes this value contain special symbols ">" and "&". So quotes must be escaped.

Correct solution is:

set RUST_DEP_GRAPH_FILTER=-^> hir^&bar

It's ugly a bit but it works.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.