Inline encode_enum_variant_info.
This commit is contained in:
parent
d7f6564fdd
commit
6ecf30d67d
@ -1223,36 +1223,26 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
|||||||
// so it's easier to do that here then to wait until we would encounter
|
// so it's easier to do that here then to wait until we would encounter
|
||||||
// normally in the visitor walk.
|
// normally in the visitor walk.
|
||||||
for variant in adt_def.variants().iter() {
|
for variant in adt_def.variants().iter() {
|
||||||
self.encode_enum_variant_info(variant);
|
let data = VariantData {
|
||||||
}
|
discr: variant.discr,
|
||||||
}
|
ctor: variant.ctor.map(|(kind, def_id)| (kind, def_id.index)),
|
||||||
|
is_non_exhaustive: variant.is_field_list_non_exhaustive(),
|
||||||
|
};
|
||||||
|
record!(self.tables.variant_data[variant.def_id] <- data);
|
||||||
|
|
||||||
fn encode_enum_variant_info(&mut self, variant: &ty::VariantDef) {
|
self.tables.constness.set(variant.def_id.index, hir::Constness::Const);
|
||||||
let tcx = self.tcx;
|
record_array!(self.tables.children[variant.def_id] <- variant.fields.iter().map(|f| {
|
||||||
let def_id = variant.def_id;
|
assert!(f.did.is_local());
|
||||||
debug!("EncodeContext::encode_enum_variant_info({:?})", def_id);
|
f.did.index
|
||||||
|
}));
|
||||||
|
|
||||||
let data = VariantData {
|
if let Some((CtorKind::Fn, ctor_def_id)) = variant.ctor {
|
||||||
discr: variant.discr,
|
self.tables.constness.set(ctor_def_id.index, hir::Constness::Const);
|
||||||
ctor: variant.ctor.map(|(kind, def_id)| (kind, def_id.index)),
|
let fn_sig = tcx.fn_sig(ctor_def_id);
|
||||||
is_non_exhaustive: variant.is_field_list_non_exhaustive(),
|
record!(self.tables.fn_sig[ctor_def_id] <- fn_sig);
|
||||||
};
|
// FIXME only encode signature for ctor_def_id
|
||||||
|
record!(self.tables.fn_sig[variant.def_id] <- fn_sig);
|
||||||
record!(self.tables.variant_data[def_id] <- data);
|
}
|
||||||
self.tables.constness.set(def_id.index, hir::Constness::Const);
|
|
||||||
record_array!(self.tables.children[def_id] <- variant.fields.iter().map(|f| {
|
|
||||||
assert!(f.did.is_local());
|
|
||||||
f.did.index
|
|
||||||
}));
|
|
||||||
if let Some((CtorKind::Fn, ctor_def_id)) = variant.ctor {
|
|
||||||
debug!("EncodeContext::encode_enum_variant_ctor({:?})", ctor_def_id);
|
|
||||||
|
|
||||||
self.tables.constness.set(ctor_def_id.index, hir::Constness::Const);
|
|
||||||
|
|
||||||
let fn_sig = tcx.fn_sig(ctor_def_id);
|
|
||||||
record!(self.tables.fn_sig[ctor_def_id] <- fn_sig);
|
|
||||||
// FIXME(eddyb) encode signature only for `ctor_def_id`.
|
|
||||||
record!(self.tables.fn_sig[def_id] <- fn_sig);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user