Skip to content

Commit

Permalink
Remove needless alloc_slice
Browse files Browse the repository at this point in the history
Don't invoke alloc_slice.

Arenas are temporary,
empty slices are eternal!
  • Loading branch information
est31 committed Oct 14, 2020
1 parent f243a2a commit 3019074
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_mir/src/const_eval/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3019074

Please sign in to comment.