diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2022-06-12 00:47:21 +0200 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2022-06-21 23:56:17 +0200 |
| commit | 9ae2546907d8ef6d0bcd8c81f9e89457d6b79d02 (patch) | |
| tree | 022f0a90c0f491f8e81feaa0238980f3ac618d1b /compiler/rustc_middle/src/hir | |
| parent | 21e9336fe81a1fce364349bb7a35a0347c369f34 (diff) | |
| download | rust-9ae2546907d8ef6d0bcd8c81f9e89457d6b79d02.tar.gz rust-9ae2546907d8ef6d0bcd8c81f9e89457d6b79d02.zip | |
Only keep a single well-formed query.
Diffstat (limited to 'compiler/rustc_middle/src/hir')
| -rw-r--r-- | compiler/rustc_middle/src/hir/map/mod.rs | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index 738d47ba296..a27b8470e95 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -612,23 +612,6 @@ impl<'hir> Map<'hir> { } } - /// A parallel version of `visit_all_item_likes`. - pub fn par_visit_all_item_likes<V>(self, visitor: &V) - where - V: itemlikevisit::ParItemLikeVisitor<'hir> + Sync + Send, - { - let krate = self.krate(); - par_for_each_in(&krate.owners.raw, |owner| match owner.map(OwnerInfo::node) { - MaybeOwner::Owner(OwnerNode::Item(item)) => visitor.visit_item(item), - MaybeOwner::Owner(OwnerNode::ForeignItem(item)) => visitor.visit_foreign_item(item), - MaybeOwner::Owner(OwnerNode::ImplItem(item)) => visitor.visit_impl_item(item), - MaybeOwner::Owner(OwnerNode::TraitItem(item)) => visitor.visit_trait_item(item), - MaybeOwner::Owner(OwnerNode::Crate(_)) - | MaybeOwner::NonOwner(_) - | MaybeOwner::Phantom => {} - }) - } - /// If you don't care about nesting, you should use the /// `tcx.hir_module_items()` query or `module_items()` instead. /// Please see notes in `deep_visit_all_item_likes`. @@ -867,6 +850,10 @@ impl<'hir> Map<'hir> { ) } + pub fn expect_owner(self, id: LocalDefId) -> OwnerNode<'hir> { + self.tcx.hir_owner(id).unwrap_or_else(|| bug!("expected owner for {:?}", id)).node + } + pub fn expect_item(self, id: LocalDefId) -> &'hir Item<'hir> { match self.tcx.hir_owner(id) { Some(Owner { node: OwnerNode::Item(item), .. }) => item, |
