Skip to content

Fix path_trailing_sep methods for Windows verbatim paths - #162643

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
ChrisDenton:trailing-sep-verbatim
Sep 15, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
ChrisDenton:trailing-sep-verbatim

Conversation

@ChrisDenton

@ChrisDenton ChrisDenton commented Sep 11, 2026 •

Copy link
Copy Markdown
Member

Normally on Windows the path separator is either \ or / but for verbatim paths it is only \. Currently the unstable path_trailing_sep methods (#142503) do not take that into account and just use the general is_sep_byte method.

This PR changes it to use the internal Components::is_sep(self, b) method that takes into account verbatim paths.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 11, 2026
@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Sep 11, 2026
@rustbot

rustbot commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ChrisDenton, libs
  • @ChrisDenton, libs expanded to 13 candidates
  • Random selection from Darksonn, JohnTitor, Mark-Simulacrum

@Mark-Simulacrum Mark-Simulacrum left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me unless you want to extend this per the comment, if not maybe cut an issue?

View changes since this review

Comment thread library/std/src/path.rs
if self.has_trailing_sep() && (!self.has_root() || self.parent().is_some()) {
let mut bytes = self.inner.as_encoded_bytes();
while let Some((last, init)) = bytes.split_last()
&& is_sep_byte(*last)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we rename is_sep_byte to something less easy to reach for? It seems like in most (all?) cases code should be using path.components().is_sep_byte(...) instead? Should we document this on std::path::is_separator? I'm not 100% sure if all the existing usages are doing the right thing...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest I'd like to rewrite our path handling a fair bit. Trying to be maximally generic over all possible path types on all platforms ends up being overly complicated and easy to mess up because you have to be on guard all the time. I think it'd be better if we, at the very least, had system specific sys::Path types even if all they do is implement a few lowish level methods that the higher level std::path::Path can build on.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 15, 2026
@ChrisDenton

Copy link
Copy Markdown
Member Author

I think it's fine to merge this as is but I do agree we should have an issue for improving this. I'll write something up.

@bors r=Mark-Simulacrum rollup

@rust-bors

rust-bors Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 4750ec7 has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 15, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Sep 15, 2026
… r=Mark-Simulacrum

Fix `path_trailing_sep` methods for Windows verbatim paths

Normally on Windows the path separator is either `\` or `/` but for verbatim paths it is only `\`. Currently the unstable `path_trailing_sep` methods (rust-lang#142503) do not take that into account and just use the general `is_sep_byte` method.

This PR changes it to use the internal `Components::is_sep(self, b)` method that takes into account verbatim paths.
rust-bors Bot pushed a commit that referenced this pull request Sep 15, 2026
Rollup of 7 pull requests

Successful merges:

 - #160911 (Remove d32 feature from 32-bit Arm targets)
 - #162771 (Filter do_not_recommend impls before handling a single candidate)
 - #162779 (rustdoc: Revert "fix bare urls split text")
 - #161612 (std: make a lot of items crate private)
 - #162372 (Clean up `test/rustdoc-html` folder by moving tests where appropriate)
 - #162643 (Fix `path_trailing_sep` methods for Windows verbatim paths)
 - #162784 (AGENTS.md: Permit local experimentation, per the online policy.)
jhpratt added a commit to jhpratt/rust that referenced this pull request Sep 15, 2026
… r=Mark-Simulacrum

Fix `path_trailing_sep` methods for Windows verbatim paths

Normally on Windows the path separator is either `\` or `/` but for verbatim paths it is only `\`. Currently the unstable `path_trailing_sep` methods (rust-lang#142503) do not take that into account and just use the general `is_sep_byte` method.

This PR changes it to use the internal `Components::is_sep(self, b)` method that takes into account verbatim paths.
rust-bors Bot pushed a commit that referenced this pull request Sep 15, 2026
Rollup of 10 pull requests

Successful merges:

 - #160911 (Remove d32 feature from 32-bit Arm targets)
 - #162771 (Filter do_not_recommend impls before handling a single candidate)
 - #162779 (rustdoc: Revert "fix bare urls split text")
 - #161548 (hir_typeck: Don't ICE on closures without drop location in closure capture lint)
 - #161612 (std: make a lot of items crate private)
 - #162204 (Suggest keyword order for `extern "C" const unsafe fn`)
 - #162372 (Clean up `test/rustdoc-html` folder by moving tests where appropriate)
 - #162638 (dont suggest changing the mutability of a borrow that comes from a macro)
 - #162643 (Fix `path_trailing_sep` methods for Windows verbatim paths)
 - #162784 (AGENTS.md: Permit local experimentation, per the online policy.)
rust-bors Bot pushed a commit that referenced this pull request Sep 15, 2026
Rollup of 10 pull requests

Successful merges:

 - #160911 (Remove d32 feature from 32-bit Arm targets)
 - #162771 (Filter do_not_recommend impls before handling a single candidate)
 - #162779 (rustdoc: Revert "fix bare urls split text")
 - #161548 (hir_typeck: Don't ICE on closures without drop location in closure capture lint)
 - #161612 (std: make a lot of items crate private)
 - #162204 (Suggest keyword order for `extern "C" const unsafe fn`)
 - #162372 (Clean up `test/rustdoc-html` folder by moving tests where appropriate)
 - #162638 (dont suggest changing the mutability of a borrow that comes from a macro)
 - #162643 (Fix `path_trailing_sep` methods for Windows verbatim paths)
 - #162784 (AGENTS.md: Permit local experimentation, per the online policy.)
rust-bors Bot pushed a commit that referenced this pull request Sep 15, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - #160911 (Remove d32 feature from 32-bit Arm targets)
 - #161868 (libtest: never iterate over all tests in `--exact` mode)
 - #162771 (Filter do_not_recommend impls before handling a single candidate)
 - #162779 (rustdoc: Revert "fix bare urls split text")
 - #161548 (hir_typeck: Don't ICE on closures without drop location in closure capture lint)
 - #161612 (std: make a lot of items crate private)
 - #162204 (Suggest keyword order for `extern "C" const unsafe fn`)
 - #162372 (Clean up `test/rustdoc-html` folder by moving tests where appropriate)
 - #162638 (dont suggest changing the mutability of a borrow that comes from a macro)
 - #162643 (Fix `path_trailing_sep` methods for Windows verbatim paths)
 - #162654 (Improve Armv7-R documentation)
 - #162784 (AGENTS.md: Permit local experimentation, per the online policy.)
@rust-bors
rust-bors Bot merged commit 83e19bc into rust-lang:main Sep 15, 2026
13 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Sep 15, 2026
rust-bors Bot pushed a commit that referenced this pull request Sep 15, 2026
Rollup merge of #162643 - ChrisDenton:trailing-sep-verbatim, r=Mark-Simulacrum

Fix `path_trailing_sep` methods for Windows verbatim paths

Normally on Windows the path separator is either `\` or `/` but for verbatim paths it is only `\`. Currently the unstable `path_trailing_sep` methods (#142503) do not take that into account and just use the general `is_sep_byte` method.

This PR changes it to use the internal `Components::is_sep(self, b)` method that takes into account verbatim paths.
@ChrisDenton
ChrisDenton deleted the trailing-sep-verbatim branch September 15, 2026 12:18
github-actions Bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Sep 17, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - rust-lang/rust#160911 (Remove d32 feature from 32-bit Arm targets)
 - rust-lang/rust#161868 (libtest: never iterate over all tests in `--exact` mode)
 - rust-lang/rust#162771 (Filter do_not_recommend impls before handling a single candidate)
 - rust-lang/rust#162779 (rustdoc: Revert "fix bare urls split text")
 - rust-lang/rust#161548 (hir_typeck: Don't ICE on closures without drop location in closure capture lint)
 - rust-lang/rust#161612 (std: make a lot of items crate private)
 - rust-lang/rust#162204 (Suggest keyword order for `extern "C" const unsafe fn`)
 - rust-lang/rust#162372 (Clean up `test/rustdoc-html` folder by moving tests where appropriate)
 - rust-lang/rust#162638 (dont suggest changing the mutability of a borrow that comes from a macro)
 - rust-lang/rust#162643 (Fix `path_trailing_sep` methods for Windows verbatim paths)
 - rust-lang/rust#162654 (Improve Armv7-R documentation)
 - rust-lang/rust#162784 (AGENTS.md: Permit local experimentation, per the online policy.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants