Add const params to Def
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
This commit is contained in:
parent
ea0d99829d
commit
29f7206366
7 changed files with 21 additions and 3 deletions
|
@ -52,6 +52,7 @@ pub enum Def {
|
|||
AssociatedExistential(DefId),
|
||||
PrimTy(hir::PrimTy),
|
||||
TyParam(DefId),
|
||||
ConstParam(DefId),
|
||||
SelfTy(Option<DefId> /* trait */, Option<DefId> /* impl */),
|
||||
ToolMod, // e.g., `rustfmt` in `#[rustfmt::skip]`
|
||||
|
||||
|
@ -265,7 +266,8 @@ impl Def {
|
|||
Def::Fn(id) | Def::Mod(id) | Def::Static(id, _) |
|
||||
Def::Variant(id) | Def::VariantCtor(id, ..) | Def::Enum(id) |
|
||||
Def::TyAlias(id) | Def::TraitAlias(id) |
|
||||
Def::AssociatedTy(id) | Def::TyParam(id) | Def::Struct(id) | Def::StructCtor(id, ..) |
|
||||
Def::AssociatedTy(id) | Def::TyParam(id) | Def::ConstParam(id) | Def::Struct(id) |
|
||||
Def::StructCtor(id, ..) |
|
||||
Def::Union(id) | Def::Trait(id) | Def::Method(id) | Def::Const(id) |
|
||||
Def::AssociatedConst(id) | Def::Macro(id, ..) |
|
||||
Def::Existential(id) | Def::AssociatedExistential(id) | Def::ForeignTy(id) => {
|
||||
|
@ -322,6 +324,7 @@ impl Def {
|
|||
Def::Const(..) => "constant",
|
||||
Def::AssociatedConst(..) => "associated constant",
|
||||
Def::TyParam(..) => "type parameter",
|
||||
Def::ConstParam(..) => "const parameter",
|
||||
Def::PrimTy(..) => "builtin type",
|
||||
Def::Local(..) => "local variable",
|
||||
Def::Upvar(..) => "closure capture",
|
||||
|
|
|
@ -218,6 +218,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
|
|||
let def_path_data = match param.kind {
|
||||
GenericParamKind::Lifetime { .. } => DefPathData::LifetimeParam(name),
|
||||
GenericParamKind::Type { .. } => DefPathData::TypeParam(name),
|
||||
GenericParamKind::Const { .. } => DefPathData::ConstParam(name),
|
||||
};
|
||||
self.create_def(param.id, def_path_data, REGULAR_SPACE, param.ident.span);
|
||||
|
||||
|
|
|
@ -356,10 +356,12 @@ pub enum DefPathData {
|
|||
/// A closure expression
|
||||
ClosureExpr,
|
||||
// Subportions of items
|
||||
/// A type parameter (generic parameter)
|
||||
/// A type (generic) parameter
|
||||
TypeParam(InternedString),
|
||||
/// A lifetime definition
|
||||
/// A lifetime (generic) parameter
|
||||
LifetimeParam(InternedString),
|
||||
/// A const (generic) parameter
|
||||
ConstParam(InternedString),
|
||||
/// A variant of a enum
|
||||
EnumVariant(InternedString),
|
||||
/// A struct field
|
||||
|
@ -641,6 +643,7 @@ impl DefPathData {
|
|||
MacroDef(name) |
|
||||
TypeParam(name) |
|
||||
LifetimeParam(name) |
|
||||
ConstParam(name) |
|
||||
EnumVariant(name) |
|
||||
Field(name) |
|
||||
GlobalMetaData(name) => Some(name),
|
||||
|
@ -669,6 +672,7 @@ impl DefPathData {
|
|||
MacroDef(name) |
|
||||
TypeParam(name) |
|
||||
LifetimeParam(name) |
|
||||
ConstParam(name) |
|
||||
EnumVariant(name) |
|
||||
Field(name) |
|
||||
GlobalMetaData(name) => {
|
||||
|
|
|
@ -1046,6 +1046,7 @@ impl_stable_hash_for!(enum hir::def::Def {
|
|||
AssociatedExistential(def_id),
|
||||
PrimTy(prim_ty),
|
||||
TyParam(def_id),
|
||||
ConstParam(def_id),
|
||||
SelfTy(trait_def_id, impl_def_id),
|
||||
ForeignTy(def_id),
|
||||
Fn(def_id),
|
||||
|
|
|
@ -325,6 +325,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
data @ DefPathData::Module(..) |
|
||||
data @ DefPathData::TypeParam(..) |
|
||||
data @ DefPathData::LifetimeParam(..) |
|
||||
data @ DefPathData::ConstParam(..) |
|
||||
data @ DefPathData::EnumVariant(..) |
|
||||
data @ DefPathData::Field(..) |
|
||||
data @ DefPathData::AnonConst |
|
||||
|
|
|
@ -426,6 +426,7 @@ impl PrintContext {
|
|||
DefPathData::ClosureExpr |
|
||||
DefPathData::TypeParam(_) |
|
||||
DefPathData::LifetimeParam(_) |
|
||||
DefPathData::ConstParam(_) |
|
||||
DefPathData::Field(_) |
|
||||
DefPathData::StructCtor |
|
||||
DefPathData::AnonConst |
|
||||
|
|
|
@ -762,6 +762,13 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
ref_id: id_from_def_id(def_id),
|
||||
})
|
||||
}
|
||||
HirDef::ConstParam(def_id) => {
|
||||
Some(Ref {
|
||||
kind: RefKind::Variable,
|
||||
span,
|
||||
ref_id: id_from_def_id(def_id),
|
||||
})
|
||||
}
|
||||
HirDef::StructCtor(def_id, _) => {
|
||||
// This is a reference to a tuple struct where the def_id points
|
||||
// to an invisible constructor function. That is not a very useful
|
||||
|
|
Loading…
Add table
Reference in a new issue