Skip to content

Commit c5c161e

Browse files
committed
match on type directlty
1 parent 64967b6 commit c5c161e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/librustc_mir/interpret/validity.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,11 @@ impl<'rt, 'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>>
264264
variant_id: VariantIdx,
265265
new_op: OpTy<'tcx, M::PointerTag>
266266
) -> EvalResult<'tcx> {
267-
let name = match old_op.layout.ty.ty_adt_def() {
268-
Some(def) => PathElem::Variant(def.variants[variant_id].ident.name),
269-
// Generators also have variants but no def
270-
None => PathElem::GeneratoreState(variant_id),
267+
let name = match old_op.layout.ty.sty {
268+
ty::Adt(adt, _) => PathElem::Variant(adt.variants[variant_id].ident.name),
269+
// Generators also have variants
270+
ty::Generator(..) => PathElem::GeneratoreState(variant_id),
271+
_ => bug!("Unexpected type with variant: {:?}", old_op.layout.ty),
271272
};
272273
self.visit_elem(new_op, name)
273274
}

0 commit comments

Comments
 (0)