Skip to content

Commit 60d4777

Browse files
committed
rust-lang#126333 literal removal of PathBuf::as_mut_vec
1 parent 4333551 commit 60d4777

File tree

5 files changed

+10
-34
lines changed

5 files changed

+10
-34
lines changed

library/std/src/ffi/os_str.rs

-6
Original file line numberDiff line numberDiff line change
@@ -551,12 +551,6 @@ impl OsString {
551551
pub fn leak<'a>(self) -> &'a mut OsStr {
552552
OsStr::from_inner_mut(self.inner.leak())
553553
}
554-
555-
/// Part of a hack to make PathBuf::push/pop more efficient.
556-
#[inline]
557-
pub(crate) fn as_mut_vec_for_path_buf(&mut self) -> &mut Vec<u8> {
558-
self.inner.as_mut_vec_for_path_buf()
559-
}
560554
}
561555

562556
#[stable(feature = "rust1", since = "1.0.0")]

library/std/src/path.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,11 @@ impl<'a> Components<'a> {
655655
/// how much of the prefix is left from the point of view of iteration?
656656
#[inline]
657657
fn prefix_remaining(&self) -> usize {
658-
if self.front == State::Prefix { self.prefix_len() } else { 0 }
658+
if self.front == State::Prefix {
659+
self.prefix_len()
660+
} else {
661+
0
662+
}
659663
}
660664

661665
// Given the iteration so far, how much of the pre-State::Body path is left?
@@ -674,7 +678,11 @@ impl<'a> Components<'a> {
674678

675679
#[inline]
676680
fn is_sep_byte(&self, b: u8) -> bool {
677-
if self.prefix_verbatim() { is_verbatim_sep(b) } else { is_sep_byte(b) }
681+
if self.prefix_verbatim() {
682+
is_verbatim_sep(b)
683+
} else {
684+
is_sep_byte(b)
685+
}
678686
}
679687

680688
/// Extracts a slice corresponding to the portion of the path remaining for iteration.
@@ -1163,11 +1171,6 @@ pub struct PathBuf {
11631171
}
11641172

11651173
impl PathBuf {
1166-
#[inline]
1167-
fn as_mut_vec(&mut self) -> &mut Vec<u8> {
1168-
self.inner.as_mut_vec_for_path_buf()
1169-
}
1170-
11711174
/// Allocates an empty `PathBuf`.
11721175
///
11731176
/// # Examples

library/std/src/sys/os_str/bytes.rs

-6
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,6 @@ impl Buf {
201201
pub fn into_rc(&self) -> Rc<Slice> {
202202
self.as_slice().into_rc()
203203
}
204-
205-
/// Part of a hack to make PathBuf::push/pop more efficient.
206-
#[inline]
207-
pub(crate) fn as_mut_vec_for_path_buf(&mut self) -> &mut Vec<u8> {
208-
&mut self.inner
209-
}
210204
}
211205

212206
impl Slice {

library/std/src/sys/os_str/wtf8.rs

-6
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,6 @@ impl Buf {
164164
pub fn into_rc(&self) -> Rc<Slice> {
165165
self.as_slice().into_rc()
166166
}
167-
168-
/// Part of a hack to make PathBuf::push/pop more efficient.
169-
#[inline]
170-
pub(crate) fn as_mut_vec_for_path_buf(&mut self) -> &mut Vec<u8> {
171-
self.inner.as_mut_vec_for_path_buf()
172-
}
173167
}
174168

175169
impl Slice {

library/std/src/sys_common/wtf8.rs

-9
Original file line numberDiff line numberDiff line change
@@ -473,15 +473,6 @@ impl Wtf8Buf {
473473
let bytes: Box<[u8]> = unsafe { mem::transmute(boxed) };
474474
Wtf8Buf { bytes: bytes.into_vec(), is_known_utf8: false }
475475
}
476-
477-
/// Part of a hack to make PathBuf::push/pop more efficient.
478-
#[inline]
479-
pub(crate) fn as_mut_vec_for_path_buf(&mut self) -> &mut Vec<u8> {
480-
// FIXME: this function should not even exist, as it implies violating Wtf8Buf invariants
481-
// For now, simply assume that is about to happen.
482-
self.is_known_utf8 = false;
483-
&mut self.bytes
484-
}
485476
}
486477

487478
/// Creates a new WTF-8 string from an iterator of code points.

0 commit comments

Comments
 (0)