Create some minimal HIR for associated opaque types
This commit is contained in:
parent
9ce37dc729
commit
b6312eb943
@ -55,6 +55,7 @@ pub(super) fn index_hir<'hir>(
|
|||||||
OwnerNode::TraitItem(item) => collector.visit_trait_item(item),
|
OwnerNode::TraitItem(item) => collector.visit_trait_item(item),
|
||||||
OwnerNode::ImplItem(item) => collector.visit_impl_item(item),
|
OwnerNode::ImplItem(item) => collector.visit_impl_item(item),
|
||||||
OwnerNode::ForeignItem(item) => collector.visit_foreign_item(item),
|
OwnerNode::ForeignItem(item) => collector.visit_foreign_item(item),
|
||||||
|
OwnerNode::AssocOpaqueTy(..) => unreachable!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
for (local_id, node) in collector.nodes.iter_enumerated() {
|
for (local_id, node) in collector.nodes.iter_enumerated() {
|
||||||
|
@ -2553,6 +2553,11 @@ pub struct OpaqueTy<'hir> {
|
|||||||
pub in_trait: bool,
|
pub in_trait: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, HashStable_Generic)]
|
||||||
|
pub struct AssocOpaqueTy {
|
||||||
|
// Add some data if necessary
|
||||||
|
}
|
||||||
|
|
||||||
/// From whence the opaque type came.
|
/// From whence the opaque type came.
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Debug, HashStable_Generic)]
|
#[derive(Copy, Clone, PartialEq, Eq, Debug, HashStable_Generic)]
|
||||||
pub enum OpaqueTyOrigin {
|
pub enum OpaqueTyOrigin {
|
||||||
@ -3363,6 +3368,7 @@ pub enum OwnerNode<'hir> {
|
|||||||
TraitItem(&'hir TraitItem<'hir>),
|
TraitItem(&'hir TraitItem<'hir>),
|
||||||
ImplItem(&'hir ImplItem<'hir>),
|
ImplItem(&'hir ImplItem<'hir>),
|
||||||
Crate(&'hir Mod<'hir>),
|
Crate(&'hir Mod<'hir>),
|
||||||
|
AssocOpaqueTy(&'hir AssocOpaqueTy),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'hir> OwnerNode<'hir> {
|
impl<'hir> OwnerNode<'hir> {
|
||||||
@ -3372,7 +3378,7 @@ impl<'hir> OwnerNode<'hir> {
|
|||||||
| OwnerNode::ForeignItem(ForeignItem { ident, .. })
|
| OwnerNode::ForeignItem(ForeignItem { ident, .. })
|
||||||
| OwnerNode::ImplItem(ImplItem { ident, .. })
|
| OwnerNode::ImplItem(ImplItem { ident, .. })
|
||||||
| OwnerNode::TraitItem(TraitItem { ident, .. }) => Some(*ident),
|
| OwnerNode::TraitItem(TraitItem { ident, .. }) => Some(*ident),
|
||||||
OwnerNode::Crate(..) => None,
|
OwnerNode::Crate(..) | OwnerNode::AssocOpaqueTy(..) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3385,6 +3391,7 @@ impl<'hir> OwnerNode<'hir> {
|
|||||||
| OwnerNode::ImplItem(ImplItem { span, .. })
|
| OwnerNode::ImplItem(ImplItem { span, .. })
|
||||||
| OwnerNode::TraitItem(TraitItem { span, .. }) => span,
|
| OwnerNode::TraitItem(TraitItem { span, .. }) => span,
|
||||||
OwnerNode::Crate(Mod { spans: ModSpans { inner_span, .. }, .. }) => inner_span,
|
OwnerNode::Crate(Mod { spans: ModSpans { inner_span, .. }, .. }) => inner_span,
|
||||||
|
OwnerNode::AssocOpaqueTy(..) => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3443,6 +3450,7 @@ impl<'hir> OwnerNode<'hir> {
|
|||||||
| OwnerNode::ImplItem(ImplItem { owner_id, .. })
|
| OwnerNode::ImplItem(ImplItem { owner_id, .. })
|
||||||
| OwnerNode::ForeignItem(ForeignItem { owner_id, .. }) => *owner_id,
|
| OwnerNode::ForeignItem(ForeignItem { owner_id, .. }) => *owner_id,
|
||||||
OwnerNode::Crate(..) => crate::CRATE_HIR_ID.owner,
|
OwnerNode::Crate(..) => crate::CRATE_HIR_ID.owner,
|
||||||
|
OwnerNode::AssocOpaqueTy(..) => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3486,6 +3494,7 @@ impl<'hir> Into<Node<'hir>> for OwnerNode<'hir> {
|
|||||||
OwnerNode::ImplItem(n) => Node::ImplItem(n),
|
OwnerNode::ImplItem(n) => Node::ImplItem(n),
|
||||||
OwnerNode::TraitItem(n) => Node::TraitItem(n),
|
OwnerNode::TraitItem(n) => Node::TraitItem(n),
|
||||||
OwnerNode::Crate(n) => Node::Crate(n),
|
OwnerNode::Crate(n) => Node::Crate(n),
|
||||||
|
OwnerNode::AssocOpaqueTy(n) => Node::AssocOpaqueTy(n),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3523,6 +3532,7 @@ pub enum Node<'hir> {
|
|||||||
WhereBoundPredicate(&'hir WhereBoundPredicate<'hir>),
|
WhereBoundPredicate(&'hir WhereBoundPredicate<'hir>),
|
||||||
// FIXME: Merge into `Node::Infer`.
|
// FIXME: Merge into `Node::Infer`.
|
||||||
ArrayLenInfer(&'hir InferArg),
|
ArrayLenInfer(&'hir InferArg),
|
||||||
|
AssocOpaqueTy(&'hir AssocOpaqueTy),
|
||||||
// Span by reference to minimize `Node`'s size
|
// Span by reference to minimize `Node`'s size
|
||||||
#[allow(rustc::pass_by_value)]
|
#[allow(rustc::pass_by_value)]
|
||||||
Err(&'hir Span),
|
Err(&'hir Span),
|
||||||
@ -3573,6 +3583,7 @@ impl<'hir> Node<'hir> {
|
|||||||
| Node::Infer(..)
|
| Node::Infer(..)
|
||||||
| Node::WhereBoundPredicate(..)
|
| Node::WhereBoundPredicate(..)
|
||||||
| Node::ArrayLenInfer(..)
|
| Node::ArrayLenInfer(..)
|
||||||
|
| Node::AssocOpaqueTy(..)
|
||||||
| Node::Err(..) => None,
|
| Node::Err(..) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3678,6 +3689,7 @@ impl<'hir> Node<'hir> {
|
|||||||
Node::TraitItem(i) => Some(OwnerNode::TraitItem(i)),
|
Node::TraitItem(i) => Some(OwnerNode::TraitItem(i)),
|
||||||
Node::ImplItem(i) => Some(OwnerNode::ImplItem(i)),
|
Node::ImplItem(i) => Some(OwnerNode::ImplItem(i)),
|
||||||
Node::Crate(i) => Some(OwnerNode::Crate(i)),
|
Node::Crate(i) => Some(OwnerNode::Crate(i)),
|
||||||
|
Node::AssocOpaqueTy(i) => Some(OwnerNode::AssocOpaqueTy(i)),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -196,6 +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::TraitItem(item) => check_trait_item(tcx, item),
|
||||||
hir::OwnerNode::ImplItem(item) => check_impl_item(tcx, item),
|
hir::OwnerNode::ImplItem(item) => check_impl_item(tcx, item),
|
||||||
hir::OwnerNode::ForeignItem(item) => check_foreign_item(tcx, item),
|
hir::OwnerNode::ForeignItem(item) => check_foreign_item(tcx, item),
|
||||||
|
hir::OwnerNode::AssocOpaqueTy(..) => unreachable!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(generics) = node.generics() {
|
if let Some(generics) = node.generics() {
|
||||||
|
@ -262,6 +262,7 @@ fn resolve_bound_vars(tcx: TyCtxt<'_>, local_def_id: hir::OwnerId) -> ResolveBou
|
|||||||
visitor.visit_impl_item(item)
|
visitor.visit_impl_item(item)
|
||||||
}
|
}
|
||||||
hir::OwnerNode::Crate(_) => {}
|
hir::OwnerNode::Crate(_) => {}
|
||||||
|
hir::OwnerNode::AssocOpaqueTy(..) => unreachable!(),
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut rl = ResolveBoundVars::default();
|
let mut rl = ResolveBoundVars::default();
|
||||||
|
@ -121,6 +121,7 @@ impl<'a> State<'a> {
|
|||||||
self.print_bounds(":", pred.bounds);
|
self.print_bounds(":", pred.bounds);
|
||||||
}
|
}
|
||||||
Node::ArrayLenInfer(_) => self.word("_"),
|
Node::ArrayLenInfer(_) => self.word("_"),
|
||||||
|
Node::AssocOpaqueTy(..) => unreachable!(),
|
||||||
Node::Err(_) => self.word("/*ERROR*/"),
|
Node::Err(_) => self.word("/*ERROR*/"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2174,7 +2174,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
let mut call_finder = FindClosureArg { tcx: self.tcx, calls: vec![] };
|
let mut call_finder = FindClosureArg { tcx: self.tcx, calls: vec![] };
|
||||||
let node = self
|
let node = self
|
||||||
.tcx
|
.tcx
|
||||||
.opt_local_def_id_to_hir_id(self.tcx.hir().get_parent_item(call_expr.hir_id))
|
.opt_local_def_id_to_hir_id(
|
||||||
|
self.tcx.hir().get_parent_item(call_expr.hir_id).def_id,
|
||||||
|
)
|
||||||
.map(|hir_id| self.tcx.hir_node(hir_id));
|
.map(|hir_id| self.tcx.hir_node(hir_id));
|
||||||
match node {
|
match node {
|
||||||
Some(hir::Node::Item(item)) => call_finder.visit_item(item),
|
Some(hir::Node::Item(item)) => call_finder.visit_item(item),
|
||||||
|
@ -2554,6 +2554,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||||||
hir::OwnerNode::ImplItem(i) => visitor.visit_impl_item(i),
|
hir::OwnerNode::ImplItem(i) => visitor.visit_impl_item(i),
|
||||||
hir::OwnerNode::TraitItem(i) => visitor.visit_trait_item(i),
|
hir::OwnerNode::TraitItem(i) => visitor.visit_trait_item(i),
|
||||||
hir::OwnerNode::Crate(_) => bug!("OwnerNode::Crate doesn't not have generics"),
|
hir::OwnerNode::Crate(_) => bug!("OwnerNode::Crate doesn't not have generics"),
|
||||||
|
hir::OwnerNode::AssocOpaqueTy(..) => unreachable!(),
|
||||||
}
|
}
|
||||||
|
|
||||||
let ast_generics = self.tcx.hir().get_generics(lifetime_scope).unwrap();
|
let ast_generics = self.tcx.hir().get_generics(lifetime_scope).unwrap();
|
||||||
|
@ -356,7 +356,7 @@ pub fn late_lint_mod<'tcx, T: LateLintPass<'tcx> + 'tcx>(
|
|||||||
cached_typeck_results: Cell::new(None),
|
cached_typeck_results: Cell::new(None),
|
||||||
param_env: ty::ParamEnv::empty(),
|
param_env: ty::ParamEnv::empty(),
|
||||||
effective_visibilities: tcx.effective_visibilities(()),
|
effective_visibilities: tcx.effective_visibilities(()),
|
||||||
last_node_with_lint_attrs: tcx.local_def_id_to_hir_id(module_def_id.into()),
|
last_node_with_lint_attrs: tcx.local_def_id_to_hir_id(module_def_id),
|
||||||
generics: None,
|
generics: None,
|
||||||
only_module: true,
|
only_module: true,
|
||||||
};
|
};
|
||||||
|
@ -190,6 +190,7 @@ fn shallow_lint_levels_on(tcx: TyCtxt<'_>, owner: hir::OwnerId) -> ShallowLintLe
|
|||||||
levels.add_id(hir::CRATE_HIR_ID);
|
levels.add_id(hir::CRATE_HIR_ID);
|
||||||
levels.visit_mod(mod_, mod_.spans.inner_span, hir::CRATE_HIR_ID)
|
levels.visit_mod(mod_, mod_.spans.inner_span, hir::CRATE_HIR_ID)
|
||||||
}
|
}
|
||||||
|
hir::OwnerNode::AssocOpaqueTy(..) => unreachable!(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,6 +115,7 @@ macro_rules! arena_types {
|
|||||||
[] features: rustc_feature::Features,
|
[] features: rustc_feature::Features,
|
||||||
[decode] specialization_graph: rustc_middle::traits::specialization_graph::Graph,
|
[decode] specialization_graph: rustc_middle::traits::specialization_graph::Graph,
|
||||||
[] crate_inherent_impls: rustc_middle::ty::CrateInherentImpls,
|
[] crate_inherent_impls: rustc_middle::ty::CrateInherentImpls,
|
||||||
|
[] hir_owner_nodes: rustc_hir::OwnerNodes<'tcx>,
|
||||||
]);
|
]);
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
/// Retrieves the `hir::Node` corresponding to `id`, returning `None` if cannot be found.
|
/// Retrieves the `hir::Node` corresponding to `id`, returning `None` if cannot be found.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn opt_hir_node_by_def_id(self, id: LocalDefId) -> Option<Node<'tcx>> {
|
pub fn opt_hir_node_by_def_id(self, id: LocalDefId) -> Option<Node<'tcx>> {
|
||||||
Some(self.hir_node(self.opt_local_def_id_to_hir_id(id)?))
|
Some(self.hir_node_by_def_id(id))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves the `hir::Node` corresponding to `id`.
|
/// Retrieves the `hir::Node` corresponding to `id`.
|
||||||
@ -169,12 +169,10 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
self.hir_owner_nodes(id.owner).nodes[id.local_id].node
|
self.hir_owner_nodes(id.owner).nodes[id.local_id].node
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves the `hir::Node` corresponding to `id`, panicking if it cannot be found.
|
/// Retrieves the `hir::Node` corresponding to `id`.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[track_caller]
|
|
||||||
pub fn hir_node_by_def_id(self, id: LocalDefId) -> Node<'tcx> {
|
pub fn hir_node_by_def_id(self, id: LocalDefId) -> Node<'tcx> {
|
||||||
self.opt_hir_node_by_def_id(id)
|
self.hir_node(self.local_def_id_to_hir_id(id))
|
||||||
.unwrap_or_else(|| bug!("couldn't find HIR node for def id {id:?}"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `HirId` of the parent HIR node of node with this `hir_id`.
|
/// Returns `HirId` of the parent HIR node of node with this `hir_id`.
|
||||||
@ -963,6 +961,7 @@ impl<'hir> Map<'hir> {
|
|||||||
Node::Crate(item) => item.spans.inner_span,
|
Node::Crate(item) => item.spans.inner_span,
|
||||||
Node::WhereBoundPredicate(pred) => pred.span,
|
Node::WhereBoundPredicate(pred) => pred.span,
|
||||||
Node::ArrayLenInfer(inf) => inf.span,
|
Node::ArrayLenInfer(inf) => inf.span,
|
||||||
|
Node::AssocOpaqueTy(..) => unreachable!(),
|
||||||
Node::Err(span) => *span,
|
Node::Err(span) => *span,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1227,6 +1226,7 @@ fn hir_id_to_string(map: Map<'_>, id: HirId) -> String {
|
|||||||
Node::Crate(..) => String::from("(root_crate)"),
|
Node::Crate(..) => String::from("(root_crate)"),
|
||||||
Node::WhereBoundPredicate(_) => node_str("where bound predicate"),
|
Node::WhereBoundPredicate(_) => node_str("where bound predicate"),
|
||||||
Node::ArrayLenInfer(_) => node_str("array len infer"),
|
Node::ArrayLenInfer(_) => node_str("array len infer"),
|
||||||
|
Node::AssocOpaqueTy(..) => unreachable!(),
|
||||||
Node::Err(_) => node_str("error"),
|
Node::Err(_) => node_str("error"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,12 +127,10 @@ pub fn provide(providers: &mut Providers) {
|
|||||||
providers.hir_crate_items = map::hir_crate_items;
|
providers.hir_crate_items = map::hir_crate_items;
|
||||||
providers.crate_hash = map::crate_hash;
|
providers.crate_hash = map::crate_hash;
|
||||||
providers.hir_module_items = map::hir_module_items;
|
providers.hir_module_items = map::hir_module_items;
|
||||||
providers.opt_local_def_id_to_hir_id = |tcx, def_id| {
|
providers.local_def_id_to_hir_id = |tcx, def_id| match tcx.hir_crate(()).owners[def_id] {
|
||||||
Some(match tcx.hir_crate(()).owners[def_id] {
|
MaybeOwner::Owner(_) => HirId::make_owner(def_id),
|
||||||
MaybeOwner::Owner(_) => HirId::make_owner(def_id),
|
MaybeOwner::NonOwner(hir_id) => hir_id,
|
||||||
MaybeOwner::NonOwner(hir_id) => hir_id,
|
MaybeOwner::Phantom => bug!("No HirId for {:?}", def_id),
|
||||||
MaybeOwner::Phantom => bug!("No HirId for {:?}", def_id),
|
|
||||||
})
|
|
||||||
};
|
};
|
||||||
providers.opt_hir_owner_nodes =
|
providers.opt_hir_owner_nodes =
|
||||||
|tcx, id| tcx.hir_crate(()).owners.get(id)?.as_owner().map(|i| &i.nodes);
|
|tcx, id| tcx.hir_crate(()).owners.get(id)?.as_owner().map(|i| &i.nodes);
|
||||||
|
@ -174,10 +174,8 @@ rustc_queries! {
|
|||||||
cache_on_disk_if { true }
|
cache_on_disk_if { true }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gives access to the HIR ID for the given `LocalDefId` owner `key` if any.
|
/// Returns HIR ID for the given `LocalDefId`.
|
||||||
///
|
query local_def_id_to_hir_id(key: LocalDefId) -> hir::HirId {
|
||||||
/// Definitions that were generated with no HIR, would be fed to return `None`.
|
|
||||||
query opt_local_def_id_to_hir_id(key: LocalDefId) -> Option<hir::HirId>{
|
|
||||||
desc { |tcx| "getting HIR ID of `{}`", tcx.def_path_str(key) }
|
desc { |tcx| "getting HIR ID of `{}`", tcx.def_path_str(key) }
|
||||||
feedable
|
feedable
|
||||||
}
|
}
|
||||||
@ -196,6 +194,7 @@ rustc_queries! {
|
|||||||
/// Avoid calling this query directly.
|
/// Avoid calling this query directly.
|
||||||
query opt_hir_owner_nodes(key: LocalDefId) -> Option<&'tcx hir::OwnerNodes<'tcx>> {
|
query opt_hir_owner_nodes(key: LocalDefId) -> Option<&'tcx hir::OwnerNodes<'tcx>> {
|
||||||
desc { |tcx| "getting HIR owner items in `{}`", tcx.def_path_str(key) }
|
desc { |tcx| "getting HIR owner items in `{}`", tcx.def_path_str(key) }
|
||||||
|
feedable
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gives access to the HIR attributes inside the HIR owner `key`.
|
/// Gives access to the HIR attributes inside the HIR owner `key`.
|
||||||
@ -204,6 +203,7 @@ rustc_queries! {
|
|||||||
/// Avoid calling this query directly.
|
/// Avoid calling this query directly.
|
||||||
query hir_attrs(key: hir::OwnerId) -> &'tcx hir::AttributeMap<'tcx> {
|
query hir_attrs(key: hir::OwnerId) -> &'tcx hir::AttributeMap<'tcx> {
|
||||||
desc { |tcx| "getting HIR owner attributes in `{}`", tcx.def_path_str(key) }
|
desc { |tcx| "getting HIR owner attributes in `{}`", tcx.def_path_str(key) }
|
||||||
|
feedable
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Given the def_id of a const-generic parameter, computes the associated default const
|
/// Given the def_id of a const-generic parameter, computes the associated default const
|
||||||
|
@ -589,6 +589,11 @@ impl<'tcx> TyCtxtFeed<'tcx, LocalDefId> {
|
|||||||
pub fn def_id(&self) -> LocalDefId {
|
pub fn def_id(&self) -> LocalDefId {
|
||||||
self.key
|
self.key
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Caller must ensure that `self.key` ID is indeed an owner.
|
||||||
|
pub fn feed_owner_id(&self) -> TyCtxtFeed<'tcx, hir::OwnerId> {
|
||||||
|
TyCtxtFeed { tcx: self.tcx, key: hir::OwnerId { def_id: self.key } }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The central data structure of the compiler. It stores references
|
/// The central data structure of the compiler. It stores references
|
||||||
@ -2350,8 +2355,8 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
self.intrinsic_raw(def_id)
|
self.intrinsic_raw(def_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn local_def_id_to_hir_id(self, local_def_id: LocalDefId) -> HirId {
|
pub fn opt_local_def_id_to_hir_id(self, local_def_id: LocalDefId) -> Option<HirId> {
|
||||||
self.opt_local_def_id_to_hir_id(local_def_id).unwrap()
|
Some(self.local_def_id_to_hir_id(local_def_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn next_trait_solver_globally(self) -> bool {
|
pub fn next_trait_solver_globally(self) -> bool {
|
||||||
|
@ -270,7 +270,8 @@ impl<'tcx> ReachableContext<'tcx> {
|
|||||||
| Node::Ctor(..)
|
| Node::Ctor(..)
|
||||||
| Node::Field(_)
|
| Node::Field(_)
|
||||||
| Node::Ty(_)
|
| Node::Ty(_)
|
||||||
| Node::Crate(_) => {}
|
| Node::Crate(_)
|
||||||
|
| Node::AssocOpaqueTy(..) => {}
|
||||||
_ => {
|
_ => {
|
||||||
bug!(
|
bug!(
|
||||||
"found unexpected node kind in worklist: {} ({:?})",
|
"found unexpected node kind in worklist: {} ({:?})",
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
use rustc_data_structures::fx::FxIndexSet;
|
use rustc_data_structures::fx::FxIndexSet;
|
||||||
use rustc_hir as hir;
|
|
||||||
use rustc_hir::def::DefKind;
|
use rustc_hir::def::DefKind;
|
||||||
use rustc_hir::def_id::{DefId, DefIdMap, LocalDefId};
|
use rustc_hir::def_id::{DefId, DefIdMap, LocalDefId};
|
||||||
use rustc_hir::intravisit::{self, Visitor};
|
use rustc_hir::intravisit::{self, Visitor};
|
||||||
|
use rustc_hir::{self as hir, HirId};
|
||||||
|
use rustc_index::IndexVec;
|
||||||
use rustc_middle::query::Providers;
|
use rustc_middle::query::Providers;
|
||||||
use rustc_middle::ty::{self, ImplTraitInTraitData, TyCtxt};
|
use rustc_middle::ty::{self, ImplTraitInTraitData, TyCtxt, TyCtxtFeed};
|
||||||
use rustc_span::symbol::kw;
|
use rustc_span::symbol::kw;
|
||||||
|
|
||||||
pub(crate) fn provide(providers: &mut Providers) {
|
pub(crate) fn provide(providers: &mut Providers) {
|
||||||
@ -237,6 +238,22 @@ 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()));
|
||||||
|
feed.opt_hir_owner_nodes(Some(feed.tcx.arena.alloc(hir::OwnerNodes {
|
||||||
|
opt_hash_including_bodies: None,
|
||||||
|
nodes: IndexVec::from_elem_n(
|
||||||
|
hir::ParentedNode {
|
||||||
|
parent: hir::ItemLocalId::INVALID,
|
||||||
|
node: hir::Node::AssocOpaqueTy(&hir::AssocOpaqueTy {}),
|
||||||
|
},
|
||||||
|
1,
|
||||||
|
),
|
||||||
|
bodies: Default::default(),
|
||||||
|
})));
|
||||||
|
feed.feed_owner_id().hir_attrs(hir::AttributeMap::EMPTY);
|
||||||
|
}
|
||||||
|
|
||||||
/// Given an `opaque_ty_def_id` corresponding to an `impl Trait` in an associated
|
/// Given an `opaque_ty_def_id` corresponding to an `impl Trait` in an associated
|
||||||
/// function from a trait, synthesize an associated type for that `impl Trait`
|
/// function from a trait, synthesize an associated type for that `impl Trait`
|
||||||
/// that inherits properties that we infer from the method and the opaque type.
|
/// that inherits properties that we infer from the method and the opaque type.
|
||||||
@ -258,9 +275,7 @@ fn associated_type_for_impl_trait_in_trait(
|
|||||||
let local_def_id = trait_assoc_ty.def_id();
|
let local_def_id = trait_assoc_ty.def_id();
|
||||||
let def_id = local_def_id.to_def_id();
|
let def_id = local_def_id.to_def_id();
|
||||||
|
|
||||||
// There's no HIR associated with this new synthesized `def_id`, so feed
|
feed_hir(&trait_assoc_ty);
|
||||||
// `opt_local_def_id_to_hir_id` with `None`.
|
|
||||||
trait_assoc_ty.opt_local_def_id_to_hir_id(None);
|
|
||||||
|
|
||||||
// Copy span of the opaque.
|
// Copy span of the opaque.
|
||||||
trait_assoc_ty.def_ident_span(Some(span));
|
trait_assoc_ty.def_ident_span(Some(span));
|
||||||
@ -318,9 +333,7 @@ fn associated_type_for_impl_trait_in_impl(
|
|||||||
let local_def_id = impl_assoc_ty.def_id();
|
let local_def_id = impl_assoc_ty.def_id();
|
||||||
let def_id = local_def_id.to_def_id();
|
let def_id = local_def_id.to_def_id();
|
||||||
|
|
||||||
// There's no HIR associated with this new synthesized `def_id`, so feed
|
feed_hir(&impl_assoc_ty);
|
||||||
// `opt_local_def_id_to_hir_id` with `None`.
|
|
||||||
impl_assoc_ty.opt_local_def_id_to_hir_id(None);
|
|
||||||
|
|
||||||
// Copy span of the opaque.
|
// Copy span of the opaque.
|
||||||
impl_assoc_ty.def_ident_span(Some(span));
|
impl_assoc_ty.def_ident_span(Some(span));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user