1
Fork 0

Add generic arg infer

This commit is contained in:
kadmin 2021-04-24 21:41:57 +00:00
parent 71a6c7c803
commit 417b098cfc
28 changed files with 265 additions and 89 deletions

View file

@ -404,6 +404,14 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
});
}
fn visit_infer(&mut self, inf: &'hir InferArg) {
self.insert(inf.span, inf.hir_id, Node::Infer(inf));
self.with_parent(inf.hir_id, |this| {
intravisit::walk_inf(this, inf);
});
}
fn visit_trait_ref(&mut self, tr: &'hir TraitRef<'hir>) {
self.insert(tr.path.span, tr.hir_ref_id, Node::TraitRef(tr));

View file

@ -272,6 +272,7 @@ impl<'hir> Map<'hir> {
GenericParamKind::Type { .. } => DefKind::TyParam,
GenericParamKind::Const { .. } => DefKind::ConstParam,
},
Node::Infer(_) => todo!(),
Node::Crate(_) => DefKind::Mod,
Node::Stmt(_)
| Node::PathSegment(_)
@ -882,6 +883,7 @@ impl<'hir> Map<'hir> {
node: VisibilityKind::Restricted { ref path, .. },
..
}) => path.span,
Node::Infer(i) => i.span,
Node::Visibility(v) => bug!("unexpected Visibility {:?}", v),
Node::Local(local) => local.span,
Node::MacroDef(macro_def) => macro_def.span,
@ -1129,6 +1131,7 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId) -> String {
Some(Node::Param(_)) => node_str("param"),
Some(Node::Arm(_)) => node_str("arm"),
Some(Node::Block(_)) => node_str("block"),
Some(Node::Infer(_)) => node_str("infer"),
Some(Node::Local(_)) => node_str("local"),
Some(Node::Ctor(..)) => format!("ctor {}{}", path_str(), id_str),
Some(Node::Lifetime(_)) => node_str("lifetime"),

View file

@ -133,6 +133,11 @@ rustc_queries! {
cache_on_disk_if { key.is_local() }
}
query generic_arg_for_infer_arg(key: DefId) -> hir::GenericArg<'tcx> {
desc { |tcx| "computes concrete type for inference, `{}`", tcx.def_path_str(key) }
storage(ArenaCacheSelector<'tcx>)
}
/// Maps from the `DefId` of an item (trait/struct/enum/fn) to the
/// predicates (where-clauses) that must be proven true in order
/// to reference it. This is almost always the "predicates query"