From 301907497fa16e8df8d86eecaff3bf4639fd5e00 Mon Sep 17 00:00:00 2001 From: est31 Date: Wed, 14 Oct 2020 14:22:22 +0200 Subject: [PATCH] Remove needless alloc_slice Don't invoke alloc_slice. Arenas are temporary, empty slices are eternal! --- compiler/rustc_mir/src/const_eval/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_mir/src/const_eval/mod.rs b/compiler/rustc_mir/src/const_eval/mod.rs index 978d2fe000468..4b235e1aa4a50 100644 --- a/compiler/rustc_mir/src/const_eval/mod.rs +++ b/compiler/rustc_mir/src/const_eval/mod.rs @@ -50,7 +50,7 @@ pub(crate) fn destructure_const<'tcx>( let (field_count, variant, down) = match val.ty.kind() { ty::Array(_, len) => (usize::try_from(len.eval_usize(tcx, param_env)).unwrap(), None, op), ty::Adt(def, _) if def.variants.is_empty() => { - return mir::DestructuredConst { variant: None, fields: tcx.arena.alloc_slice(&[]) }; + return mir::DestructuredConst { variant: None, fields: &[] }; } ty::Adt(def, _) => { let variant = ecx.read_discriminant(op).unwrap().1;