Repository navigation
chore(path): drop debug_assert from set_file_name - #69
Closed
chipsenkbeil wants to merge 1 commit into
Closed
chipsenkbeil wants to merge 1 commit into
chipsenkbeil wants to merge 1 commit into
Conversation
These two were transcribed verbatim from std's `PathBuf::_set_file_name` during the original port and are not a pattern used anywhere else in the crate. They also assert something the surrounding code already guarantees: `pop` returns `false` only when `parent` is `None`, which the enclosing `file_name().is_some()` check has already ruled out. Claude-Session: https://claude.ai/code/session_01A5uCQTmXn119ATyfP27hfe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up cleanup, split out of #68 so that PR stays scoped to the
set_extensionfix. Independent of #68 — this branch is cut frommainand touches different lines.What
fn _set_file_name(&mut self, file_name: &[u8]) { if self.file_name().is_some() { - let popped = self.pop(); - debug_assert!(popped); + self.pop(); } self.push(file_name); }Same change in
PathBufandUtf8PathBuf. These were the only twodebug_assert!s in the crate.Why
They came in as a verbatim transcription of std's
PathBuf::_set_file_name(library/std/src/path.rs:1589) during the original 2022 port, not as a deliberate pattern — nothing else in the crate asserts this way.They also don't check anything the code doesn't already guarantee:
popreturnsfalseonly whenparentisNone, and the enclosingfile_name().is_some()has already ruled that out.Verification
cargo build --all-featureswithRUSTFLAGS=-Dwarningsexits 0 — no unused-variable warning, sincepopis not#[must_use]herecargo test --all-features— 193 unit tests, 367 doctests, all passingcargo fmt --checkcleanNo CHANGELOG entry, as nothing user-visible changes.
https://claude.ai/code/session_01A5uCQTmXn119ATyfP27hfe