Skip to content

Rollup of 8 pull requests #126965

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
553a690
Specify target specific linker for riscv64gc-gnu job
Hoverbear Jun 24, 2024
8016940
Tweak a confusing comment in `create_match_candidates`
Zalathar Jun 24, 2024
050595a
core: VaArgSafe is an unsafe trait
workingjubilee Jun 25, 2024
c2f1072
Tweak `FlatPat::new` to avoid a temporarily-invalid state
Zalathar Jun 25, 2024
c7b579a
Add missing slash in const_eval_select doc comment
cyrgani Jun 25, 2024
2155c6c
#126333 remove `PathBuf::as_mut_vec` reference at top of `PathBuf::_p…
tnuha Jun 23, 2024
b08cd69
inner truncate methods for UEFI platforms
tnuha Jun 23, 2024
7e187e8
remove references to `PathBuf::as_mut_vec` in `PathBuf::_set_extension`
tnuha Jun 23, 2024
aa46a33
`PathBuf::as_mut_vec` removed and verified for UEFI and Windows platf…
tnuha Jun 25, 2024
d30d85f
Delegation: ast lowering refactor
Bryanskiy Jun 25, 2024
6997b68
Detect unused structs which derived Default
mu001999 Jun 25, 2024
58bbade
Rollup merge of #126302 - mu001999-contrib:ignore/default, r=michaelw…
matthiaskrgr Jun 25, 2024
9d7e146
Rollup merge of #126885 - Borgerr:rm_internal_pathbuf_asmutvec, r=wor…
matthiaskrgr Jun 25, 2024
e29cc5d
Rollup merge of #126916 - ferrocene:hoverbear/riscv64gc-gnu-specify-l…
matthiaskrgr Jun 25, 2024
6077c0e
Rollup merge of #126926 - Zalathar:candidate-per-arm, r=Nadrieril
matthiaskrgr Jun 25, 2024
3795c56
Rollup merge of #126927 - workingjubilee:vaargsafe-is-unsafe, r=joboet
matthiaskrgr Jun 25, 2024
7e1489c
Rollup merge of #126932 - Zalathar:flat-pat, r=Nadrieril
matthiaskrgr Jun 25, 2024
e970017
Rollup merge of #126946 - cyrgani:patch-1, r=compiler-errors
matthiaskrgr Jun 25, 2024
4ebd69c
Rollup merge of #126947 - Bryanskiy:delegation-lowering-refactoring, …
matthiaskrgr Jun 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
PathBuf::as_mut_vec removed and verified for UEFI and Windows platf…
…orms #126333
  • Loading branch information
tnuha committed Jun 25, 2024
commit aa46a3368eb017eba41bfab956c7787d46c09935
15 changes: 10 additions & 5 deletions library/std/src/ffi/os_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,15 +552,20 @@ impl OsString {
OsStr::from_inner_mut(self.inner.leak())
}

/// Part of a hack to make PathBuf::push/pop more efficient.
/// Provides plumbing to core `Vec::truncate`.
/// More well behaving alternative to allowing outer types
/// full mutable access to the core `Vec`.
#[inline]
pub(crate) fn as_mut_vec_for_path_buf(&mut self) -> &mut Vec<u8> {
self.inner.as_mut_vec_for_path_buf()
pub(crate) fn truncate(&mut self, len: usize) {
self.inner.truncate(len);
}

/// Provides plumbing to core `Vec::extend_from_slice`.
/// More well behaving alternative to allowing outer types
/// full mutable access to the core `Vec`.
#[inline]
pub(crate) fn truncate(&mut self, len: usize) {
self.inner.truncate(len);
pub(crate) fn extend_from_slice(&mut self, other: &[u8]) {
self.inner.extend_from_slice(other);
}
}

Expand Down
11 changes: 3 additions & 8 deletions library/std/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1163,11 +1163,6 @@ pub struct PathBuf {
}

impl PathBuf {
#[inline]
fn as_mut_vec(&mut self) -> &mut Vec<u8> {
self.inner.as_mut_vec_for_path_buf()
}

/// Allocates an empty `PathBuf`.
///
/// # Examples
Expand Down Expand Up @@ -2645,18 +2640,18 @@ impl Path {
None => {
// Enough capacity for the extension and the dot
let capacity = self_len + extension.len() + 1;
let whole_path = self_bytes.iter();
let whole_path = self_bytes;
(capacity, whole_path)
}
Some(previous_extension) => {
let capacity = self_len + extension.len() - previous_extension.len();
let path_till_dot = self_bytes[..self_len - previous_extension.len()].iter();
let path_till_dot = &self_bytes[..self_len - previous_extension.len()];
(capacity, path_till_dot)
}
};

let mut new_path = PathBuf::with_capacity(new_capacity);
new_path.as_mut_vec().extend(slice_to_copy);
new_path.inner.extend_from_slice(slice_to_copy);
new_path.set_extension(extension);
new_path
}
Expand Down
15 changes: 10 additions & 5 deletions library/std/src/sys/os_str/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,20 @@ impl Buf {
self.as_slice().into_rc()
}

/// Part of a hack to make PathBuf::push/pop more efficient.
/// Provides plumbing to core `Vec::truncate`.
/// More well behaving alternative to allowing outer types
/// full mutable access to the core `Vec`.
#[inline]
pub(crate) fn as_mut_vec_for_path_buf(&mut self) -> &mut Vec<u8> {
&mut self.inner
pub(crate) fn truncate(&mut self, len: usize) {
self.inner.truncate(len);
}

/// Provides plumbing to core `Vec::extend_from_slice`.
/// More well behaving alternative to allowing outer types
/// full mutable access to the core `Vec`.
#[inline]
pub(crate) fn truncate(&mut self, len: usize) {
self.inner.truncate(len);
pub(crate) fn extend_from_slice(&mut self, other: &[u8]) {
self.inner.extend_from_slice(other);
}
}

Expand Down
16 changes: 13 additions & 3 deletions library/std/src/sys/os_str/wtf8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,20 @@ impl Buf {
self.as_slice().into_rc()
}

/// Part of a hack to make PathBuf::push/pop more efficient.
/// Provides plumbing to core `Vec::truncate`.
/// More well behaving alternative to allowing outer types
/// full mutable access to the core `Vec`.
#[inline]
pub(crate) fn as_mut_vec_for_path_buf(&mut self) -> &mut Vec<u8> {
self.inner.as_mut_vec_for_path_buf()
pub(crate) fn truncate(&mut self, len: usize) {
self.inner.truncate(len);
}

/// Provides plumbing to core `Vec::extend_from_slice`.
/// More well behaving alternative to allowing outer types
/// full mutable access to the core `Vec`.
#[inline]
pub(crate) fn extend_from_slice(&mut self, other: &[u8]) {
self.inner.extend_from_slice(other);
}
}

Expand Down
12 changes: 6 additions & 6 deletions library/std/src/sys_common/wtf8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,13 +474,13 @@ impl Wtf8Buf {
Wtf8Buf { bytes: bytes.into_vec(), is_known_utf8: false }
}

/// Part of a hack to make PathBuf::push/pop more efficient.
/// Provides plumbing to core `Vec::extend_from_slice`.
/// More well behaving alternative to allowing outer types
/// full mutable access to the core `Vec`.
#[inline]
pub(crate) fn as_mut_vec_for_path_buf(&mut self) -> &mut Vec<u8> {
// FIXME: this function should not even exist, as it implies violating Wtf8Buf invariants
// For now, simply assume that is about to happen.
self.is_known_utf8 = false;
&mut self.bytes
pub(crate) fn extend_from_slice(&mut self, other: &[u8]) {
self.bytes.extend_from_slice(other);
self.is_known_utf8 = self.is_known_utf8 || self.next_surrogate(0).is_none();
}
}

Expand Down