Skip to content

std: introduce path normalize methods at top of std::path#142957

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
xizheyin:142931
Feb 9, 2026
Merged

std: introduce path normalize methods at top of std::path#142957
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
xizheyin:142931

Conversation

@xizheyin
Copy link
Member

@xizheyin xizheyin commented Jun 24, 2025

Closes #142931

Mention other methods that call conponents and canonicalize that fully normalize path. And fix two typo.

r? libs

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 24, 2025
@rust-log-analyzer

This comment has been minimized.

@ibraheemdev
Copy link
Member

ibraheemdev commented Jul 6, 2025

Given the discussion on the issue, I think it would make more sense to have an overview in the top-level std::path documentation rather than intra-linking everything. You can open a separate PR for the typos if you wish to get that merged sooner.

@ibraheemdev ibraheemdev 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 Jul 6, 2025
@xizheyin
Copy link
Member Author

xizheyin commented Jul 7, 2025

@rustbot ready

I added a section Path normalization on top of std::Path.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 7, 2025
@xizheyin xizheyin changed the title std: mention other methods that normalize a path in normalize_lexically doc std: introduce path normalize methods at top of std::path Jul 7, 2025
@ibraheemdev
Copy link
Member

Going to pass this one on because I'm not sure when I'll have time to get to it. r? libs

@rustbot rustbot assigned tgross35 and unassigned ibraheemdev Aug 28, 2025
//! - [`PartialEq<Path>`], [`PartialOrd<Path>`], and [`Ord<Path>`] implementations
//! perform the same normalization for comparison
//! - [`Path::has_root`] and [`PathBuf::push`] also apply this normalization
//!
Copy link
Contributor

Choose a reason for hiding this comment

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

Since they all say they do the same normalization, it would probably be good to move that part outside of the list. Maybe roughly:

Several methods in this module perform basic path normalization by disregarding
repeated separators, non-leading `.` components, and trailing separators. These include:

- Methods for iteration, such as [`Path::components`] and [`Path::iter`]
- Methods for inspection, such as [`Path::has_root`]
- Comparisons using [`PartialEq`]` and [`PartialOrd`]

[`Path::join`] and [`PathBuf::push`] also disregard trailing slashes.

I moved push and join out since I think they don't really interact with anything other than the trailing separator?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ord is missing?

- Comparisons using [`PartialEq`], [`PartialOrd`], and [`Ord`]

I revise the doc. Sorry for late response. :)

@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 2, 2025
@rustbot
Copy link
Collaborator

rustbot commented Feb 9, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

Copy link
Member Author

@xizheyin xizheyin left a comment

Choose a reason for hiding this comment

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

//! - [`PartialEq<Path>`], [`PartialOrd<Path>`], and [`Ord<Path>`] implementations
//! perform the same normalization for comparison
//! - [`Path::has_root`] and [`PathBuf::push`] also apply this normalization
//!
Copy link
Member Author

Choose a reason for hiding this comment

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

Ord is missing?

- Comparisons using [`PartialEq`], [`PartialOrd`], and [`Ord`]

I revise the doc. Sorry for late response. :)

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

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

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

@tgross35
Copy link
Contributor

tgross35 commented Feb 9, 2026

@bors r+ rollup

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 9, 2026

📌 Commit 88c296a has been approved by tgross35

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-review Status: Awaiting review from the assignee but also interested parties. labels Feb 9, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 9, 2026
std: introduce path normalize methods at top of `std::path`

Closes rust-lang#142931

Mention other methods that call `conponents` and `canonicalize` that fully normalize path. And fix two typo.

r? libs
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 9, 2026
std: introduce path normalize methods at top of `std::path`

Closes rust-lang#142931

Mention other methods that call `conponents` and `canonicalize` that fully normalize path. And fix two typo.

r? libs
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 9, 2026
std: introduce path normalize methods at top of `std::path`

Closes rust-lang#142931

Mention other methods that call `conponents` and `canonicalize` that fully normalize path. And fix two typo.

r? libs
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 9, 2026
std: introduce path normalize methods at top of `std::path`

Closes rust-lang#142931

Mention other methods that call `conponents` and `canonicalize` that fully normalize path. And fix two typo.

r? libs
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 9, 2026
std: introduce path normalize methods at top of `std::path`

Closes rust-lang#142931

Mention other methods that call `conponents` and `canonicalize` that fully normalize path. And fix two typo.

r? libs
rust-bors bot pushed a commit that referenced this pull request Feb 9, 2026
Rollup of 12 pull requests

Successful merges:

 - #152388 (`rust-analyzer` subtree update)
 - #151613 (Align `ArrayWindows` trait impls with `Windows`)
 - #152134 (Set crt_static_allow_dylibs to true for Emscripten target)
 - #152166 (cleanup some more things in `proc_macro::bridge`)
 - #152236 (compiletest: `-Zunstable-options` for json targets)
 - #152287 (Fix an ICE in the vtable iteration for a trait reference in const eval when a supertrait not implemented)
 - #142957 (std: introduce path normalize methods at top of `std::path`)
 - #145504 (Add some conversion trait impls)
 - #152131 (Port rustc_no_implicit_bounds attribute to parser.)
 - #152315 (fix: rhs_span to rhs_span_new)
 - #152327 (Check stalled coroutine obligations eagerly)
 - #152377 (Rename the query system's `JobOwner` to `ActiveJobGuard`, and include `key_hash`)
rust-bors bot pushed a commit that referenced this pull request Feb 9, 2026
Rollup of 12 pull requests

Successful merges:

 - #152388 (`rust-analyzer` subtree update)
 - #151613 (Align `ArrayWindows` trait impls with `Windows`)
 - #152134 (Set crt_static_allow_dylibs to true for Emscripten target)
 - #152166 (cleanup some more things in `proc_macro::bridge`)
 - #152236 (compiletest: `-Zunstable-options` for json targets)
 - #152287 (Fix an ICE in the vtable iteration for a trait reference in const eval when a supertrait not implemented)
 - #142957 (std: introduce path normalize methods at top of `std::path`)
 - #145504 (Add some conversion trait impls)
 - #152131 (Port rustc_no_implicit_bounds attribute to parser.)
 - #152315 (fix: rhs_span to rhs_span_new)
 - #152327 (Check stalled coroutine obligations eagerly)
 - #152377 (Rename the query system's `JobOwner` to `ActiveJobGuard`, and include `key_hash`)
rust-bors bot pushed a commit that referenced this pull request Feb 9, 2026
Rollup of 12 pull requests

Successful merges:

 - #152388 (`rust-analyzer` subtree update)
 - #151613 (Align `ArrayWindows` trait impls with `Windows`)
 - #152134 (Set crt_static_allow_dylibs to true for Emscripten target)
 - #152166 (cleanup some more things in `proc_macro::bridge`)
 - #152236 (compiletest: `-Zunstable-options` for json targets)
 - #152287 (Fix an ICE in the vtable iteration for a trait reference in const eval when a supertrait not implemented)
 - #142957 (std: introduce path normalize methods at top of `std::path`)
 - #145504 (Add some conversion trait impls)
 - #152131 (Port rustc_no_implicit_bounds attribute to parser.)
 - #152315 (fix: rhs_span to rhs_span_new)
 - #152327 (Check stalled coroutine obligations eagerly)
 - #152377 (Rename the query system's `JobOwner` to `ActiveJobGuard`, and include `key_hash`)
@rust-bors rust-bors bot merged commit c15f4e0 into rust-lang:main Feb 9, 2026
11 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Feb 9, 2026
rust-timer added a commit that referenced this pull request Feb 9, 2026
Rollup merge of #142957 - xizheyin:142931, r=tgross35

std: introduce path normalize methods at top of `std::path`

Closes #142931

Mention other methods that call `conponents` and `canonicalize` that fully normalize path. And fix two typo.

r? libs
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.

normalize_lexically should mention other functions that do basic normalization

5 participants