match on type directlty

This commit is contained in:
Ralf Jung 2019-05-04 13:49:04 +02:00
parent 64967b693c
commit c5c161e394

View File

@ -264,10 +264,11 @@ impl<'rt, 'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>>
variant_id: VariantIdx,
new_op: OpTy<'tcx, M::PointerTag>
) -> EvalResult<'tcx> {
let name = match old_op.layout.ty.ty_adt_def() {
Some(def) => PathElem::Variant(def.variants[variant_id].ident.name),
// Generators also have variants but no def
None => PathElem::GeneratoreState(variant_id),
let name = match old_op.layout.ty.sty {
ty::Adt(adt, _) => PathElem::Variant(adt.variants[variant_id].ident.name),
// Generators also have variants
ty::Generator(..) => PathElem::GeneratoreState(variant_id),
_ => bug!("Unexpected type with variant: {:?}", old_op.layout.ty),
};
self.visit_elem(new_op, name)
}