-
Notifications
You must be signed in to change notification settings - Fork 48
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
Edition 2018 Support #34
Comments
Hi @muhuk, sounds good to me! (Especially the "Implement an alternate version of the dependency graph in a separate module." bit.) Optimally we should generate a kind of IR of the dependency graph. The best fit for such an IR would probably be an actual graph representation using e.g. petgraph. // lib.rs:
mod foo {
use std::mem;
mod bar {
struct Baz;
}
use bar::Baz;
}
use foo::bar::Baz; // petgraph IR:
crate --[mod]-> crate::foo;
crate --[use]-> crate::foo::bar::Baz;
crate::foo --[use]-> std::mem;
crate::foo --[mod]-> crate::foo::bar;
crate::foo --[use]-> crate::foo::bar::Baz;
crate::foo::bar --[struct]-> crate::foo::bar::Baz; As such we would only need to have two implementations of the "frontend" generating the dependency-graph IR from the parsed Rust source, one for 2015, one for 2018 edition. We could then share everything else between editions and even port the tree mode to generate its output from the IR. And last but not least a petgraph IR would allow us to implement this: #18. |
I have started working on detection of edition (not in the plan above 😕 ). WIP branch is here |
I have a couple of questions. I have notices these two things while working on this feature:
(I am using Debian, cargo 1.34.0-nightly) |
If I remember correctly cargo-modules would wrongly list those files as modules even though they are not part of the crate. |
Currently we have the following files:
Looks like we will be:
Note I: Replace above means eventually replace when the implementation is complete. |
Hi @regexident , I have pushed my WIP branch to 34-new-dependency-graph. It is not yet in a shape to be merged, but can be reviewed. I'll crate a pull request once it's more complete. |
Just checking in. I was in a business trip and now I'm back. Part III starts. |
Some more progress here, still needs a couple more sessions to put it all together. |
The rules for use path prefixes, as far as I can understand is as below:
Two things are not handled (AFAICU):
|
Work in progress. Turns out petgraph does not support multiple edges (same direction) between two nodes. I will have to combine parent-child edge and use edge. |
Looking great! Putting a bitflags label on the edge should work, I suppose? Wrapping the petgraph in a wrapper type that does the projection from/to multigraph might help, too? |
Hi @regexident , As for rendering (turning a single petgraph edge into multiple dot edges) that should be a non-issue. |
I ended up with this Edge implementation. |
@muhuk: @skade just pointed me towards the ra_hir_def crate (thanks, @skade!) from @matklad's awesome rust-analyzer, which implements path resolving. Might be worth a look, I guess? |
Right now I'm leaning more towards cleaning things up than making the scope bigger. Let me see though. 😉 |
I have tried to upgrade all deps and the toolchain to more recent versions but couldn't make it work in the end. Looks like I was hoping to do this and somehow unify the two sets of analyzers and printers (getting rid of the ridiculous Maybe Cleanup aside, I think we can close this ticket as we have (some sort of) Edition 2018 support now. |
This should now be fixed with #66 having been merged. 🎉 😃 |
Edition 2018 changes the way
use
works in a few different ways. I would like to add support resolving dependencies in projects that useedition = "2018"
.My plan is as below:
--enable-edition-2018
. Initially this will be ignored. Current code does not takeedition
into consideration anyway. New option will be documented in--help
.--enable-edition-2018
is given andedition
is"2018"
inCargo.toml
, use the alternate implementation. Otherwise keep everything same.This issue should also close #29 when implemented fully.
The text was updated successfully, but these errors were encountered: