diff --git a/src/libsyntax/owned_slice.rs b/src/libsyntax/owned_slice.rs index 7eb6709919aa..d368477cd33a 100644 --- a/src/libsyntax/owned_slice.rs +++ b/src/libsyntax/owned_slice.rs @@ -58,9 +58,12 @@ impl OwnedSlice { if len == 0 { OwnedSlice::empty() } else { + // drop excess capacity to avoid breaking sized deallocation + v.shrink_to_fit(); + let p = v.as_mut_ptr(); // we own the allocation now - unsafe {mem::forget(v)} + unsafe { mem::forget(v) } OwnedSlice { data: p, len: len } }