Add generic arg infer
This commit is contained in:
@@ -253,11 +253,24 @@ pub struct ConstArg {
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Encodable, Debug, HashStable_Generic)]
|
||||
pub struct InferArg {
|
||||
pub hir_id: HirId,
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl InferArg {
|
||||
pub fn to_ty(&self) -> Ty<'_> {
|
||||
Ty { kind: TyKind::Infer, span: self.span, hir_id: self.hir_id }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, HashStable_Generic)]
|
||||
pub enum GenericArg<'hir> {
|
||||
Lifetime(Lifetime),
|
||||
Type(Ty<'hir>),
|
||||
Const(ConstArg),
|
||||
Infer(InferArg),
|
||||
}
|
||||
|
||||
impl GenericArg<'_> {
|
||||
@@ -266,6 +279,7 @@ impl GenericArg<'_> {
|
||||
GenericArg::Lifetime(l) => l.span,
|
||||
GenericArg::Type(t) => t.span,
|
||||
GenericArg::Const(c) => c.span,
|
||||
GenericArg::Infer(i) => i.span,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,6 +288,7 @@ impl GenericArg<'_> {
|
||||
GenericArg::Lifetime(l) => l.hir_id,
|
||||
GenericArg::Type(t) => t.hir_id,
|
||||
GenericArg::Const(c) => c.value.hir_id,
|
||||
GenericArg::Infer(i) => i.hir_id,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,6 +305,7 @@ impl GenericArg<'_> {
|
||||
GenericArg::Lifetime(_) => "lifetime",
|
||||
GenericArg::Type(_) => "type",
|
||||
GenericArg::Const(_) => "constant",
|
||||
GenericArg::Infer(_) => "inferred",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,6 +316,7 @@ impl GenericArg<'_> {
|
||||
GenericArg::Const(_) => {
|
||||
ast::ParamKindOrd::Const { unordered: feats.unordered_const_ty_params() }
|
||||
}
|
||||
GenericArg::Infer(_) => ast::ParamKindOrd::Infer,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -341,6 +358,7 @@ impl GenericArgs<'_> {
|
||||
break;
|
||||
}
|
||||
GenericArg::Const(_) => {}
|
||||
GenericArg::Infer(_) => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -358,6 +376,7 @@ impl GenericArgs<'_> {
|
||||
GenericArg::Lifetime(_) => own_counts.lifetimes += 1,
|
||||
GenericArg::Type(_) => own_counts.types += 1,
|
||||
GenericArg::Const(_) => own_counts.consts += 1,
|
||||
GenericArg::Infer(_) => own_counts.infer += 1,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -484,6 +503,7 @@ pub struct GenericParamCount {
|
||||
pub lifetimes: usize,
|
||||
pub types: usize,
|
||||
pub consts: usize,
|
||||
pub infer: usize,
|
||||
}
|
||||
|
||||
/// Represents lifetimes and type parameters attached to a declaration
|
||||
@@ -2987,6 +3007,8 @@ pub enum Node<'hir> {
|
||||
Visibility(&'hir Visibility<'hir>),
|
||||
|
||||
Crate(&'hir Mod<'hir>),
|
||||
|
||||
Infer(&'hir InferArg),
|
||||
}
|
||||
|
||||
impl<'hir> Node<'hir> {
|
||||
@@ -3055,6 +3077,7 @@ impl<'hir> Node<'hir> {
|
||||
| Node::Local(Local { hir_id, .. })
|
||||
| Node::Lifetime(Lifetime { hir_id, .. })
|
||||
| Node::Param(Param { hir_id, .. })
|
||||
| Node::Infer(InferArg { hir_id, .. })
|
||||
| Node::GenericParam(GenericParam { hir_id, .. }) => Some(*hir_id),
|
||||
Node::TraitRef(TraitRef { hir_ref_id, .. }) => Some(*hir_ref_id),
|
||||
Node::PathSegment(PathSegment { hir_id, .. }) => *hir_id,
|
||||
|
||||
Reference in New Issue
Block a user