Skip to content

Commit

Permalink
Rollup merge of #77936 - est31:remove_needless_alloc_slice, r=jonas-s…
Browse files Browse the repository at this point in the history
…chievink

Remove needless alloc_slice

Don't invoke alloc_slice.

Arenas are temporary,
empty slices are eternal!
  • Loading branch information
JohnTitor authored Oct 14, 2020
2 parents 0cf86c2 + 3019074 commit df08fe7
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 df08fe7

Please sign in to comment.