Skip to content

Commit

Permalink
match on type directlty
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed May 4, 2019
1 parent 64967b6 commit c5c161e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/librustc_mir/interpret/validity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit c5c161e

Please sign in to comment.