1
Fork 0

rustc: Harmonize DefKind and DefPathData

`DefPathData::(ClosureExpr,ImplTrait)` are renamed to match `DefKind::(Closure,OpaqueTy)`.

`DefPathData::ImplTraitAssocTy` is replaced with `DefPathData::TypeNS(kw::Empty)` because both correspond to `DefKind::AssocTy`.
It's possible that introducing `(DefKind,DefPathData)::AssocOpaqueTy` could be a better solution, but that would be a much more invasive change.

Const generic parameters introduced for effects are moved from `DefPathData::TypeNS` to `DefPathData::ValueNS`, because constants are values.

`DefPathData` is no longer passed to `create_def` functions to avoid redundancy.
This commit is contained in:
Vadim Petrochenkov 2023-12-03 12:29:59 +03:00
parent 7ceaf19868
commit 17e799c270
17 changed files with 133 additions and 132 deletions

View file

@ -379,14 +379,13 @@ fn encode_ty_name(tcx: TyCtxt<'_>, def_id: DefId) -> String {
hir::definitions::DefPathData::ForeignMod => "F", // Not specified in v0's <namespace>
hir::definitions::DefPathData::TypeNs(..) => "t",
hir::definitions::DefPathData::ValueNs(..) => "v",
hir::definitions::DefPathData::ClosureExpr => "C",
hir::definitions::DefPathData::Closure => "C",
hir::definitions::DefPathData::Ctor => "c",
hir::definitions::DefPathData::AnonConst => "k",
hir::definitions::DefPathData::ImplTrait => "i",
hir::definitions::DefPathData::OpaqueTy => "i",
hir::definitions::DefPathData::CrateRoot
| hir::definitions::DefPathData::Use
| hir::definitions::DefPathData::GlobalAsm
| hir::definitions::DefPathData::ImplTraitAssocTy
| hir::definitions::DefPathData::MacroNs(..)
| hir::definitions::DefPathData::LifetimeNs(..) => {
bug!("encode_ty_name: unexpected `{:?}`", disambiguated_data.data);

View file

@ -770,17 +770,16 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
// Uppercase categories are more stable than lowercase ones.
DefPathData::TypeNs(_) => 't',
DefPathData::ValueNs(_) => 'v',
DefPathData::ClosureExpr => 'C',
DefPathData::Closure => 'C',
DefPathData::Ctor => 'c',
DefPathData::AnonConst => 'k',
DefPathData::ImplTrait => 'i',
DefPathData::OpaqueTy => 'i',
// These should never show up as `path_append` arguments.
DefPathData::CrateRoot
| DefPathData::Use
| DefPathData::GlobalAsm
| DefPathData::Impl
| DefPathData::ImplTraitAssocTy
| DefPathData::MacroNs(_)
| DefPathData::LifetimeNs(_) => {
bug!("symbol_names: unexpected DefPathData: {:?}", disambiguated_data.data)