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

@ -45,7 +45,6 @@ use rustc_hir::def::NonMacroAttrKind;
use rustc_hir::def::{self, CtorOf, DefKind, DocLinkResMap, LifetimeRes, PartialRes, PerNS};
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LocalDefIdMap, LocalDefIdSet};
use rustc_hir::def_id::{CRATE_DEF_ID, LOCAL_CRATE};
use rustc_hir::definitions::DefPathData;
use rustc_hir::{PrimTy, TraitCandidate};
use rustc_index::IndexVec;
use rustc_metadata::creader::{CStore, CrateLoader};
@ -1212,11 +1211,12 @@ impl<'tcx> Resolver<'_, 'tcx> {
&mut self,
parent: LocalDefId,
node_id: ast::NodeId,
data: DefPathData,
name: Symbol,
def_kind: DefKind,
expn_id: ExpnId,
span: Span,
) -> LocalDefId {
let data = def_kind.def_path_data(name);
assert!(
!self.node_id_to_def_id.contains_key(&node_id),
"adding a def'n for node-id {:?} and data {:?} but a previous def'n exists: {:?}",