Skip to content

chore(path): drop debug_assert from set_file_name - #69

Closed
chipsenkbeil wants to merge 1 commit into
mainfrom
chore/remove-debug-asserts
Closed

chipsenkbeil wants to merge 1 commit into
mainfrom
chore/remove-debug-asserts

Conversation

@chipsenkbeil

Copy link
Copy Markdown
Owner

Follow-up cleanup, split out of #68 so that PR stays scoped to the set_extension fix. Independent of #68 — this branch is cut from main and 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 PathBuf and Utf8PathBuf. These were the only two debug_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: pop returns false only when parent is None, and the enclosing file_name().is_some() has already ruled that out.

Verification

  • cargo build --all-features with RUSTFLAGS=-Dwarnings exits 0 — no unused-variable warning, since pop is not #[must_use] here
  • cargo test --all-features — 193 unit tests, 367 doctests, all passing
  • cargo fmt --check clean

No CHANGELOG entry, as nothing user-visible changes.

https://claude.ai/code/session_01A5uCQTmXn119ATyfP27hfe

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
@chipsenkbeil
chipsenkbeil deleted the chore/remove-debug-asserts branch August 28, 2026 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant