1
Fork 0

Put checking if anonct is a default into a method on hir map

This commit is contained in:
Ellen 2021-07-13 17:23:26 +01:00
parent e276b860e2
commit 8c40360ed4
4 changed files with 28 additions and 29 deletions

View file

@ -901,6 +901,19 @@ impl<'hir> Map<'hir> {
pub fn node_to_string(&self, id: HirId) -> String {
hir_id_to_string(self, id)
}
/// Returns the HirId of `N` in `struct Foo<const N: usize = { ... }>` when
/// called with the HirId for the `{ ... }` anon const
pub fn opt_const_param_default_param_hir_id(&self, anon_const: HirId) -> Option<HirId> {
match self.get(self.get_parent_node(anon_const)) {
Node::GenericParam(GenericParam {
hir_id: param_id,
kind: GenericParamKind::Const { .. },
..
}) => Some(*param_id),
_ => None,
}
}
}
impl<'hir> intravisit::Map<'hir> for Map<'hir> {