diff options
| author | Ralf Jung <post@ralfj.de> | 2019-05-04 13:49:04 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2019-05-04 13:49:04 +0200 |
| commit | c5c161e39497887abf78ef7da0d53c3dcf22a059 (patch) | |
| tree | bc5695c8899e885a11a09ff0d3d05a61066fa1cc | |
| parent | 64967b693cb2692f0c3f770a66bbde7eaa38153e (diff) | |
| download | rust-c5c161e39497887abf78ef7da0d53c3dcf22a059.tar.gz rust-c5c161e39497887abf78ef7da0d53c3dcf22a059.zip | |
match on type directlty
| -rw-r--r-- | src/librustc_mir/interpret/validity.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs index 807da7340f8..772cbcf9447 100644 --- a/src/librustc_mir/interpret/validity.rs +++ b/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) } |
