diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2022-12-01 18:51:20 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2022-12-01 18:51:20 +0300 |
| commit | b32a4edb2078ca61ebcd9bad993905873f4a990a (patch) | |
| tree | 50acd792b559138cc1c306259b5886d3ce1004bb /compiler/rustc_resolve/src/effective_visibilities.rs | |
| parent | 1f259ae6799e7e0a08e5b84fc5686e404b17eef0 (diff) | |
| download | rust-b32a4edb2078ca61ebcd9bad993905873f4a990a.tar.gz rust-b32a4edb2078ca61ebcd9bad993905873f4a990a.zip | |
rustc_ast_lowering: Stop lowering imports into multiple items
Lower them into a single item with multiple resolutions instead. This also allows to remove additional `NodId`s and `DefId`s related to those additional items.
Diffstat (limited to 'compiler/rustc_resolve/src/effective_visibilities.rs')
| -rw-r--r-- | compiler/rustc_resolve/src/effective_visibilities.rs | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/compiler/rustc_resolve/src/effective_visibilities.rs b/compiler/rustc_resolve/src/effective_visibilities.rs index 3aa8d52db03..85399385d1f 100644 --- a/compiler/rustc_resolve/src/effective_visibilities.rs +++ b/compiler/rustc_resolve/src/effective_visibilities.rs @@ -1,4 +1,4 @@ -use crate::{ImportKind, NameBinding, NameBindingKind, Resolver, ResolverTree}; +use crate::{NameBinding, NameBindingKind, Resolver, ResolverTree}; use rustc_ast::ast; use rustc_ast::visit; use rustc_ast::visit::Visitor; @@ -104,28 +104,11 @@ impl<'r, 'a> EffectiveVisibilitiesVisitor<'r, 'a> { for (binding, eff_vis) in visitor.import_effective_visibilities.iter() { let NameBindingKind::Import { import, .. } = binding.kind else { unreachable!() }; if let Some(node_id) = import.id() { - let mut update = |node_id| { - r.effective_visibilities.update_eff_vis( - r.local_def_id(node_id), - eff_vis, - ResolverTree(&r.definitions, &r.crate_loader), - ) - }; - update(node_id); - if let ImportKind::Single { additional_ids: (id1, id2), .. } = import.kind { - // In theory all the single import IDs have individual visibilities and - // effective visibilities, but in practice these IDs go straight to HIR - // where all their few uses assume that their (effective) visibility - // applies to the whole syntactic `use` item. So they all get the same - // value which is the maximum of all bindings. Maybe HIR for imports - // shouldn't use three IDs at all. - if id1 != ast::DUMMY_NODE_ID { - update(id1); - } - if id2 != ast::DUMMY_NODE_ID { - update(id2); - } - } + r.effective_visibilities.update_eff_vis( + r.local_def_id(node_id), + eff_vis, + ResolverTree(&r.definitions, &r.crate_loader), + ) } } |
