diff --git a/library/std/src/path.rs b/library/std/src/path.rs index 7b8caaa268473..c2aeb00b500bb 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -1290,7 +1290,8 @@ impl PathBuf { fn _push(&mut self, path: &Path) { // in general, a separator is needed if the rightmost byte is not a separator - let mut need_sep = self.as_mut_vec().last().map(|c| !is_sep_byte(*c)).unwrap_or(false); + let buf = self.inner.as_encoded_bytes(); + let mut need_sep = buf.last().map(|c| !is_sep_byte(*c)).unwrap_or(false); // in the special case of `C:` on Windows, do *not* add a separator let comps = self.components();