Rewrite check_pat_enum, split it into check_pat_tuple_struct and check_pat_path
Update definitions in def_map for associated types written in unqualified form (like `Self::Output`) Cleanup finish_resolving_def_to_ty/resolve_ty_and_def_ufcs Make VariantDef's available through constructor IDs
This commit is contained in:
parent
eb32440d45
commit
2cdd9f1c97
17 changed files with 229 additions and 327 deletions
|
|
@ -471,23 +471,29 @@ pub fn get_adt_def<'a, 'tcx>(intr: &IdentInterner,
|
|||
|
||||
let doc = cdata.lookup_item(item_id);
|
||||
let did = DefId { krate: cdata.cnum, index: item_id };
|
||||
let mut ctor_did = None;
|
||||
let (kind, variants) = match item_family(doc) {
|
||||
Enum => {
|
||||
(ty::AdtKind::Enum,
|
||||
get_enum_variants(intr, cdata, doc))
|
||||
}
|
||||
Struct(..) => {
|
||||
let ctor_did =
|
||||
reader::maybe_get_doc(doc, tag_items_data_item_struct_ctor).
|
||||
map_or(did, |ctor_doc| translated_def_id(cdata, ctor_doc));
|
||||
// Use separate constructor id for unit/tuple structs and reuse did for braced structs.
|
||||
ctor_did = reader::maybe_get_doc(doc, tag_items_data_item_struct_ctor).map(|ctor_doc| {
|
||||
translated_def_id(cdata, ctor_doc)
|
||||
});
|
||||
(ty::AdtKind::Struct,
|
||||
vec![get_struct_variant(intr, cdata, doc, ctor_did)])
|
||||
vec![get_struct_variant(intr, cdata, doc, ctor_did.unwrap_or(did))])
|
||||
}
|
||||
_ => bug!("get_adt_def called on a non-ADT {:?} - {:?}",
|
||||
item_family(doc), did)
|
||||
};
|
||||
|
||||
let adt = tcx.intern_adt_def(did, kind, variants);
|
||||
if let Some(ctor_did) = ctor_did {
|
||||
// Make adt definition available through constructor id as well.
|
||||
tcx.insert_adt_def(ctor_did, adt);
|
||||
}
|
||||
|
||||
// this needs to be done *after* the variant is interned,
|
||||
// to support recursive structures
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue