The AssocOpaqueTy HIR node is not actually needed to differentiate from other hir nodes that were fed

This commit is contained in:
Oli Scherer 2024-03-19 08:37:53 +00:00
parent 196ff446d2
commit bdb682eda6
10 changed files with 21 additions and 27 deletions

View File

@ -55,7 +55,7 @@ pub(super) fn index_hir<'hir>(
OwnerNode::TraitItem(item) => collector.visit_trait_item(item),
OwnerNode::ImplItem(item) => collector.visit_impl_item(item),
OwnerNode::ForeignItem(item) => collector.visit_foreign_item(item),
OwnerNode::AssocOpaqueTy(..) => unreachable!(),
OwnerNode::Synthetic => unreachable!(),
};
for (local_id, node) in collector.nodes.iter_enumerated() {

View File

@ -2552,11 +2552,6 @@ pub struct OpaqueTy<'hir> {
pub in_trait: bool,
}
#[derive(Copy, Clone, Debug, HashStable_Generic)]
pub struct AssocOpaqueTy {
// Add some data if necessary
}
/// From whence the opaque type came.
#[derive(Copy, Clone, PartialEq, Eq, Debug, HashStable_Generic)]
pub enum OpaqueTyOrigin {
@ -3367,7 +3362,7 @@ pub enum OwnerNode<'hir> {
TraitItem(&'hir TraitItem<'hir>),
ImplItem(&'hir ImplItem<'hir>),
Crate(&'hir Mod<'hir>),
AssocOpaqueTy(&'hir AssocOpaqueTy),
Synthetic,
}
impl<'hir> OwnerNode<'hir> {
@ -3377,7 +3372,7 @@ impl<'hir> OwnerNode<'hir> {
| OwnerNode::ForeignItem(ForeignItem { ident, .. })
| OwnerNode::ImplItem(ImplItem { ident, .. })
| OwnerNode::TraitItem(TraitItem { ident, .. }) => Some(*ident),
OwnerNode::Crate(..) | OwnerNode::AssocOpaqueTy(..) => None,
OwnerNode::Crate(..) | OwnerNode::Synthetic => None,
}
}
@ -3390,7 +3385,7 @@ impl<'hir> OwnerNode<'hir> {
| OwnerNode::ImplItem(ImplItem { span, .. })
| OwnerNode::TraitItem(TraitItem { span, .. }) => span,
OwnerNode::Crate(Mod { spans: ModSpans { inner_span, .. }, .. }) => inner_span,
OwnerNode::AssocOpaqueTy(..) => unreachable!(),
OwnerNode::Synthetic => unreachable!(),
}
}
@ -3449,7 +3444,7 @@ impl<'hir> OwnerNode<'hir> {
| OwnerNode::ImplItem(ImplItem { owner_id, .. })
| OwnerNode::ForeignItem(ForeignItem { owner_id, .. }) => *owner_id,
OwnerNode::Crate(..) => crate::CRATE_HIR_ID.owner,
OwnerNode::AssocOpaqueTy(..) => unreachable!(),
OwnerNode::Synthetic => unreachable!(),
}
}
@ -3493,7 +3488,7 @@ impl<'hir> Into<Node<'hir>> for OwnerNode<'hir> {
OwnerNode::ImplItem(n) => Node::ImplItem(n),
OwnerNode::TraitItem(n) => Node::TraitItem(n),
OwnerNode::Crate(n) => Node::Crate(n),
OwnerNode::AssocOpaqueTy(n) => Node::AssocOpaqueTy(n),
OwnerNode::Synthetic => Node::Synthetic,
}
}
}
@ -3531,7 +3526,8 @@ pub enum Node<'hir> {
WhereBoundPredicate(&'hir WhereBoundPredicate<'hir>),
// FIXME: Merge into `Node::Infer`.
ArrayLenInfer(&'hir InferArg),
AssocOpaqueTy(&'hir AssocOpaqueTy),
// Created by query feeding
Synthetic,
// Span by reference to minimize `Node`'s size
#[allow(rustc::pass_by_value)]
Err(&'hir Span),
@ -3582,7 +3578,7 @@ impl<'hir> Node<'hir> {
| Node::Infer(..)
| Node::WhereBoundPredicate(..)
| Node::ArrayLenInfer(..)
| Node::AssocOpaqueTy(..)
| Node::Synthetic
| Node::Err(..) => None,
}
}
@ -3688,7 +3684,7 @@ impl<'hir> Node<'hir> {
Node::TraitItem(i) => Some(OwnerNode::TraitItem(i)),
Node::ImplItem(i) => Some(OwnerNode::ImplItem(i)),
Node::Crate(i) => Some(OwnerNode::Crate(i)),
Node::AssocOpaqueTy(i) => Some(OwnerNode::AssocOpaqueTy(i)),
Node::Synthetic => Some(OwnerNode::Synthetic),
_ => None,
}
}

View File

@ -196,7 +196,7 @@ fn check_well_formed(tcx: TyCtxt<'_>, def_id: hir::OwnerId) -> Result<(), ErrorG
hir::OwnerNode::TraitItem(item) => check_trait_item(tcx, item),
hir::OwnerNode::ImplItem(item) => check_impl_item(tcx, item),
hir::OwnerNode::ForeignItem(item) => check_foreign_item(tcx, item),
hir::OwnerNode::AssocOpaqueTy(..) => unreachable!(),
hir::OwnerNode::Synthetic => unreachable!(),
};
if let Some(generics) = node.generics() {

View File

@ -262,7 +262,7 @@ fn resolve_bound_vars(tcx: TyCtxt<'_>, local_def_id: hir::OwnerId) -> ResolveBou
visitor.visit_impl_item(item)
}
hir::OwnerNode::Crate(_) => {}
hir::OwnerNode::AssocOpaqueTy(..) => unreachable!(),
hir::OwnerNode::Synthetic => unreachable!(),
}
let mut rl = ResolveBoundVars::default();

View File

@ -121,7 +121,7 @@ impl<'a> State<'a> {
self.print_bounds(":", pred.bounds);
}
Node::ArrayLenInfer(_) => self.word("_"),
Node::AssocOpaqueTy(..) => unreachable!(),
Node::Synthetic => unreachable!(),
Node::Err(_) => self.word("/*ERROR*/"),
}
}

View File

@ -2553,7 +2553,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
hir::OwnerNode::ImplItem(i) => visitor.visit_impl_item(i),
hir::OwnerNode::TraitItem(i) => visitor.visit_trait_item(i),
hir::OwnerNode::Crate(_) => bug!("OwnerNode::Crate doesn't not have generics"),
hir::OwnerNode::AssocOpaqueTy(..) => unreachable!(),
hir::OwnerNode::Synthetic => unreachable!(),
}
let ast_generics = self.tcx.hir().get_generics(lifetime_scope).unwrap();

View File

@ -191,7 +191,7 @@ fn shallow_lint_levels_on(tcx: TyCtxt<'_>, owner: hir::OwnerId) -> ShallowLintLe
levels.add_id(hir::CRATE_HIR_ID);
levels.visit_mod(mod_, mod_.spans.inner_span, hir::CRATE_HIR_ID)
}
hir::OwnerNode::AssocOpaqueTy(..) => unreachable!(),
hir::OwnerNode::Synthetic => unreachable!(),
},
}

View File

@ -954,7 +954,7 @@ impl<'hir> Map<'hir> {
Node::Crate(item) => item.spans.inner_span,
Node::WhereBoundPredicate(pred) => pred.span,
Node::ArrayLenInfer(inf) => inf.span,
Node::AssocOpaqueTy(..) => unreachable!(),
Node::Synthetic => unreachable!(),
Node::Err(span) => *span,
}
}
@ -1219,7 +1219,7 @@ fn hir_id_to_string(map: Map<'_>, id: HirId) -> String {
Node::Crate(..) => String::from("(root_crate)"),
Node::WhereBoundPredicate(_) => node_str("where bound predicate"),
Node::ArrayLenInfer(_) => node_str("array len infer"),
Node::AssocOpaqueTy(..) => unreachable!(),
Node::Synthetic => unreachable!(),
Node::Err(_) => node_str("error"),
}
}

View File

@ -247,7 +247,7 @@ impl<'tcx> ReachableContext<'tcx> {
| Node::Field(_)
| Node::Ty(_)
| Node::Crate(_)
| Node::AssocOpaqueTy(..) => {}
| Node::Synthetic => {}
_ => {
bug!(
"found unexpected node kind in worklist: {} ({:?})",

View File

@ -241,18 +241,16 @@ fn associated_types_for_impl_traits_in_associated_fn(
fn feed_hir(feed: &TyCtxtFeed<'_, LocalDefId>) {
feed.local_def_id_to_hir_id(HirId::make_owner(feed.def_id()));
let node = hir::OwnerNode::AssocOpaqueTy(&hir::AssocOpaqueTy {});
let node = hir::OwnerNode::Synthetic;
let bodies = Default::default();
let attrs = hir::AttributeMap::EMPTY;
let (opt_hash_including_bodies, _) = feed.tcx.hash_owner_nodes(node, &bodies, &attrs.map);
let node = node.into();
feed.opt_hir_owner_nodes(Some(feed.tcx.arena.alloc(hir::OwnerNodes {
opt_hash_including_bodies,
nodes: IndexVec::from_elem_n(
hir::ParentedNode {
parent: hir::ItemLocalId::INVALID,
node: hir::Node::AssocOpaqueTy(&hir::AssocOpaqueTy {}),
},
hir::ParentedNode { parent: hir::ItemLocalId::INVALID, node },
1,
),
bodies,