Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module graph missing links #51

Closed
kvark opened this issue May 5, 2020 · 4 comments
Closed

Module graph missing links #51

kvark opened this issue May 5, 2020 · 4 comments

Comments

@kvark
Copy link
Collaborator

kvark commented May 5, 2020

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?

@kvark
Copy link
Collaborator Author

kvark commented May 6, 2020

I suspect #34 is just not finished yet. I tried copying the "example-lib-edition-2018" out (of the workspace) and generating the graph from it:

../cargo-modules/target/debug/cargo-modules --enable-edition-2018 graph | dot -Tpng >example.png

It produced the following picture:
example

It looks to be missing all the back edges ("submodule" -> "A", "subsubbmodule" -> "submodule", "A").

@kvark
Copy link
Collaborator Author

kvark commented May 7, 2020

One issue that I realized here is that cargo-modules doesn't even realize that subsubmodule is a module. On the graph, it shows it as an orphan. I asked about this on Rust Zulip, and the answer was:

simulacrum: iirc mod statements are "inlined" during expansion
simulacrum: so you won't actually parse the submodule (or the subsubmodule) until expansion runs

I don't yet understand the whole picture. Maybe @regexident you can shed some light on it?
Also, it would be nice to reach you on some more immediate medium, like the Matrix/Zulip/Gitter/etc

@regexident
Copy link
Owner

Before Rust 2018 the complexity of name/module resolution reasonably simple.
Rust 2018 made things considerably more complex.

@muhuk has been spearheading most of the efforts to add full support for Rust 2018, with me mostly doing code review and joining in on discussions on implementation details.


In light of the recent "library-ification" by the Rust compiler team I more and more wonder if it wouldn't make sense to tap into some of the logic/crates that are falling out of these efforts, the great work @matklad is doing with rust-analyzer in particular, such as ra_hir, which might be able to solve the whole name resolution issue for us for free.

@regexident
Copy link
Owner

This should now be fixed with #66 having been merged. 🎉 😃
(The release still needs a it more work. If you're feeling lucky you can install from source and give it a try, though.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants