-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rustc: collapse relevant DefPathData variants into {Type,Value,Macro,Lifetime}Ns. #60525
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -586,8 +586,13 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { | |
let data = VariantData { | ||
ctor_kind: variant.ctor_kind, | ||
discr: variant.discr, | ||
// FIXME(eddyb) deduplicate these with `encode_enum_variant_ctor`. | ||
ctor: variant.ctor_def_id.map(|did| did.index), | ||
ctor_sig: None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure how this worked before. |
||
ctor_sig: if variant.ctor_kind == CtorKind::Fn { | ||
variant.ctor_def_id.map(|ctor_def_id| self.lazy(&tcx.fn_sig(ctor_def_id))) | ||
} else { | ||
None | ||
}, | ||
}; | ||
|
||
let enum_id = tcx.hir().as_local_hir_id(enum_did).unwrap(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
mod environment; | ||
|
||
use rustc::hir::def::DefKind; | ||
use rustc::hir::def_id::DefId; | ||
use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; | ||
use rustc::hir::map::definitions::DefPathData; | ||
|
@@ -157,13 +158,27 @@ crate fn program_clauses_for<'a, 'tcx>( | |
tcx: TyCtxt<'a, 'tcx, 'tcx>, | ||
def_id: DefId, | ||
) -> Clauses<'tcx> { | ||
// FIXME(eddyb) this should only be using `def_kind`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean introducing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I think |
||
match tcx.def_key(def_id).disambiguated_data.data { | ||
DefPathData::Trait(_) | | ||
DefPathData::TraitAlias(_) => program_clauses_for_trait(tcx, def_id), | ||
DefPathData::TypeNs(..) => match tcx.def_kind(def_id) { | ||
Some(DefKind::Trait) | ||
| Some(DefKind::TraitAlias) => program_clauses_for_trait(tcx, def_id), | ||
// FIXME(eddyb) deduplicate this `associated_item` call with | ||
// `program_clauses_for_associated_type_{value,def}`. | ||
Some(DefKind::AssociatedTy) => match tcx.associated_item(def_id).container { | ||
ty::AssociatedItemContainer::ImplContainer(_) => | ||
program_clauses_for_associated_type_value(tcx, def_id), | ||
ty::AssociatedItemContainer::TraitContainer(_) => | ||
program_clauses_for_associated_type_def(tcx, def_id) | ||
}, | ||
Some(DefKind::Struct) | ||
| Some(DefKind::Enum) | ||
| Some(DefKind::TyAlias) | ||
| Some(DefKind::Union) | ||
| Some(DefKind::Existential) => program_clauses_for_type_def(tcx, def_id), | ||
_ => List::empty(), | ||
}, | ||
DefPathData::Impl => program_clauses_for_impl(tcx, def_id), | ||
DefPathData::AssocTypeInImpl(..) => program_clauses_for_associated_type_value(tcx, def_id), | ||
DefPathData::AssocTypeInTrait(..) => program_clauses_for_associated_type_def(tcx, def_id), | ||
DefPathData::TypeNs(..) => program_clauses_for_type_def(tcx, def_id), | ||
_ => List::empty(), | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: could you use an exhaustive match here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intentionally not using it because this are not really in the type namespace.
Maybe I should've made this function return
-> Option<Namespace>
, but it's really just a private hack.