]> git.lizzy.rs Git - rust.git/commit
Auto merge of #51425 - QuietMisdreavus:thats-def-a-namespace-there, r=petrochenkov
authorbors <bors@rust-lang.org>
Sun, 17 Jun 2018 09:48:10 +0000 (09:48 +0000)
committerbors <bors@rust-lang.org>
Sun, 17 Jun 2018 09:48:10 +0000 (09:48 +0000)
commit594b05dd9786c09c916745c1b1c281a3c54cdbd1
tree2b277ef34c86f1d97de5494eb492218c26fa5c25
parentaec00f97e1cdcea2b079e209a7e759201ba6ca7c
parent903e2c8afe6907b8828202345f2677a8e14f78fa
Auto merge of #51425 - QuietMisdreavus:thats-def-a-namespace-there, r=petrochenkov

refactor: create multiple HIR items for imports

When lowering `use` statements into HIR, they get a `Def` of the thing they're pointing at. This is great for things that need to know what was just pulled into scope. However, this is a bit misleading, because a `use` statement can pull things from multiple namespaces if their names collide. This is a problem for rustdoc, because if there are a module and a function with the same name (for example) then it will only document the module import, because that's that the lowered `use` statement points to.

The current version of this PR does the following:

* Whenever the resolver comes across a `use` statement, it loads the definitions into a new `import_map` instead of the existing `def_map`. This keeps the resolutions per-namespace so that all the target definitions are available.
* When lowering `use` statements, it looks up the resolutions in the `import_map` and creates multiple `Item`s if there is more than one resolution.
* To ensure the `NodeId`s are properly tracked in the lowered module, they need to be created in the AST, and pulled out as needed if multiple resolutions are available.

Fixes https://github.com/rust-lang/rust/issues/34843
src/libsyntax/feature_gate.rs