Skip to content

Commit 6548ad8

Browse files
committed
Auto merge of rust-lang#133360 - compiler-errors:rollup-a2o38tq, r=compiler-errors
Rollup of 8 pull requests Successful merges: - rust-lang#132090 (Stop being so bail-y in candidate assembly) - rust-lang#132658 (Detect const in pattern with typo) - rust-lang#132911 (Pretty print async fn sugar in opaques and trait bounds) - rust-lang#133102 (aarch64 softfloat target: always pass floats in int registers) - rust-lang#133159 (Don't allow `-Zunstable-options` to take a value ) - rust-lang#133208 (generate-copyright: Now generates a library file too.) - rust-lang#133215 (Fix missing submodule in `./x vendor`) - rust-lang#133264 (implement OsString::truncate) r? `@ghost` `@rustbot` modify labels: rollup
2 parents a939801 + a4f797e commit 6548ad8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

std/src/ffi/os_str.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -550,11 +550,15 @@ impl OsString {
550550
OsStr::from_inner_mut(self.inner.leak())
551551
}
552552

553-
/// Provides plumbing to core `Vec::truncate`.
554-
/// More well behaving alternative to allowing outer types
555-
/// full mutable access to the core `Vec`.
553+
/// Truncate the the `OsString` to the specified length.
554+
///
555+
/// # Panics
556+
/// Panics if `len` does not lie on a valid `OsStr` boundary
557+
/// (as described in [`OsStr::slice_encoded_bytes`]).
556558
#[inline]
557-
pub(crate) fn truncate(&mut self, len: usize) {
559+
#[unstable(feature = "os_string_truncate", issue = "133262")]
560+
pub fn truncate(&mut self, len: usize) {
561+
self.as_os_str().inner.check_public_boundary(len);
558562
self.inner.truncate(len);
559563
}
560564

0 commit comments

Comments
 (0)