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

Merge `ModuleTree` and `ModuleItemMap` #723

Closed
matklad opened this Issue Feb 1, 2019 · 2 comments

Comments

Projects
None yet
1 participant
@matklad
Copy link
Collaborator

matklad commented Feb 1, 2019

Currently, building the tree of modules and resolving use items are separate phases. This is because we don't handle macros yet :-)

WIth macros, a module can be defined by a macro invocation, which is imported by a use path. To handle this, we should merge two things into one.

Specifically, we should create a new struct and query, CrateSymbols, which contains a module tree, a mapping from module to declared/imported symbols and a mapping from macro invocations to the expansion results.

The LowerModule step should work on the raw syntax and should be oblivious of the particular module. Specifically, it shouldn't do macro expansion, while it does it today.

A possible further extension here is to split import into two categories: imports that can affect macro resolution, and other imports. Ideally, we should lazily resolve the second category.

@matklad matklad added E-hard fun labels Feb 1, 2019

@matklad matklad changed the title Merge `ModleTree` and `ModuleItemMap` Merge `ModuleTree` and `ModuleItemMap` Feb 1, 2019

@matklad

This comment has been minimized.

Copy link
Collaborator Author

matklad commented Feb 8, 2019

cc @pnkfelix @michaelwoerister, this the main "name resolution/macro expansion" issue in rust-analyzer.

The code which handles this currently is

https://github.com/rust-analyzer/rust-analyzer/blob/12e3b4c70b5ef23b2fdfc197296d483680e125f9/crates/ra_hir/src/module_tree.rs

https://github.com/rust-analyzer/rust-analyzer/blob/12e3b4c70b5ef23b2fdfc197296d483680e125f9/crates/ra_hir/src/nameres.rs

#724 (in-progress PR which adds macro-expansion, outside of the resolution atm)

@matklad

This comment has been minimized.

Copy link
Collaborator Author

matklad commented Mar 21, 2019

fixed

@matklad matklad closed this Mar 21, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.