Skip to content
Permalink
Browse files

match on type directlty

  • Loading branch information...
RalfJung committed May 4, 2019
1 parent 64967b6 commit c5c161e39497887abf78ef7da0d53c3dcf22a059
Showing with 5 additions and 4 deletions.
  1. +5 −4 src/librustc_mir/interpret/validity.rs
@@ -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)
}

0 comments on commit c5c161e

Please sign in to comment.
You can’t perform that action at this time.