Skip to content

Implement normalize_lexically #134696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ChrisDenton
Copy link
Member

Implements #134694

This is, I think, the most straightforward implementation I could do, which will hopefully more easily allow experimentation if we decide to change the design here.

@rustbot
Copy link
Collaborator

rustbot commented Dec 23, 2024

r? @workingjubilee

rustbot has assigned @workingjubilee.
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

@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 Dec 23, 2024
@ChrisDenton ChrisDenton force-pushed the normalize-lexically branch 2 times, most recently from c08079c to 8a3fb66 Compare December 23, 2024 17:44

for component in iter {
match component {
Component::RootDir | Component::Prefix(_) => return Err(NormalizeError),
Copy link
Member

@workingjubilee workingjubilee Dec 29, 2024

Choose a reason for hiding this comment

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

Shouldn't Component::RootDir be unreachable? (We just checked it and skipped it.)

Comment on lines +3014 to +3012
Component::RootDir | Component::Prefix(_) => return Err(NormalizeError),
Component::CurDir => continue,
Component::ParentDir => {
if lexical.as_os_str().len() == root {
return Err(NormalizeError);
Copy link
Member

Choose a reason for hiding this comment

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

This is also a "should never happen" case, isn't it?

@workingjubilee workingjubilee 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 Jan 4, 2025
@bors
Copy link
Collaborator

bors commented Feb 4, 2025

☔ The latest upstream changes (presumably #136533) made this pull request unmergeable. Please resolve the merge conflicts.

@workingjubilee
Copy link
Member

Hmm. This wasn't supposed to get frozen on those two questions, so I'm just going to rebase this and approve it. If I think we maybe should call unreachable!() instead of returning I can just PR that.

@workingjubilee workingjubilee force-pushed the normalize-lexically branch from 8a3fb66 to 2955213 Compare May 2, 2025 21:10
@rust-log-analyzer
Copy link
Collaborator

The job mingw-check failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[RUSTC-TIMING] run_time_detect test:true 0.054
error[E0423]: expected value, found struct `NormalizeError`
    --> library/std/tests/path.rs:1996:21
     |
1996 |     check("..", Err(NormalizeError));
     |                     ^^^^^^^^^^^^^^ constructor is not visible here due to private fields

error[E0423]: expected value, found struct `NormalizeError`
    --> library/std/tests/path.rs:1997:24
     |
1997 |     check("../..", Err(NormalizeError));
     |                        ^^^^^^^^^^^^^^ constructor is not visible here due to private fields

error[E0423]: expected value, found struct `NormalizeError`
    --> library/std/tests/path.rs:1998:26
     |
1998 |     check("a/../..", Err(NormalizeError));
     |                          ^^^^^^^^^^^^^^ constructor is not visible here due to private fields

error[E0423]: expected value, found struct `NormalizeError`
    --> library/std/tests/path.rs:1999:28
     |
1999 |     check("a/../../b", Err(NormalizeError));
     |                            ^^^^^^^^^^^^^^ constructor is not visible here due to private fields

error[E0423]: expected value, found struct `NormalizeError`
    --> library/std/tests/path.rs:2000:30
     |
2000 |     check("a/../../b/c", Err(NormalizeError));
     |                              ^^^^^^^^^^^^^^ constructor is not visible here due to private fields

error[E0423]: expected value, found struct `NormalizeError`
    --> library/std/tests/path.rs:2001:31
     |
2001 |     check("a/../b/../..", Err(NormalizeError));
     |                               ^^^^^^^^^^^^^^ constructor is not visible here due to private fields

error[E0423]: expected value, found struct `NormalizeError`
    --> library/std/tests/path.rs:2011:29
     |
2011 |         check(r"C:\..", Err(NormalizeError));
     |                             ^^^^^^^^^^^^^^ constructor is not visible here due to private fields

error[E0423]: expected value, found struct `NormalizeError`
    --> library/std/tests/path.rs:2012:34
     |
2012 |         check(r"C:\a\..\..", Err(NormalizeError));
     |                                  ^^^^^^^^^^^^^^ constructor is not visible here due to private fields

error[E0423]: expected value, found struct `NormalizeError`
    --> library/std/tests/path.rs:2014:28
     |
2014 |         check(r"C:..", Err(NormalizeError));
     |                            ^^^^^^^^^^^^^^ constructor is not visible here due to private fields

error[E0423]: expected value, found struct `NormalizeError`
    --> library/std/tests/path.rs:2015:33
     |
2015 |         check(r"C:a\..\..", Err(NormalizeError));
     |                                 ^^^^^^^^^^^^^^ constructor is not visible here due to private fields

error[E0423]: expected value, found struct `NormalizeError`
    --> library/std/tests/path.rs:2017:41
     |
2017 |         check(r"\\server\share\..", Err(NormalizeError));
     |                                         ^^^^^^^^^^^^^^ constructor is not visible here due to private fields

error[E0423]: expected value, found struct `NormalizeError`
    --> library/std/tests/path.rs:2018:46
     |
2018 |         check(r"\\server\share\a\..\..", Err(NormalizeError));
     |                                              ^^^^^^^^^^^^^^ constructor is not visible here due to private fields

error[E0423]: expected value, found struct `NormalizeError`
    --> library/std/tests/path.rs:2020:27
     |
2020 |         check(r"\..", Err(NormalizeError));
     |                           ^^^^^^^^^^^^^^ constructor is not visible here due to private fields

error[E0423]: expected value, found struct `NormalizeError`
    --> library/std/tests/path.rs:2021:32
     |
2021 |         check(r"\a\..\..", Err(NormalizeError));
     |                                ^^^^^^^^^^^^^^ constructor is not visible here due to private fields

error[E0423]: expected value, found struct `NormalizeError`
    --> library/std/tests/path.rs:2023:47
     |
2023 |         check(r"\\?\UNC\server\share\..", Err(NormalizeError));
     |                                               ^^^^^^^^^^^^^^ constructor is not visible here due to private fields

error[E0423]: expected value, found struct `NormalizeError`
    --> library/std/tests/path.rs:2024:52
     |
2024 |         check(r"\\?\UNC\server\share\a\..\..", Err(NormalizeError));
     |                                                    ^^^^^^^^^^^^^^ constructor is not visible here due to private fields

[RUSTC-TIMING] minmax_stability_issue_23687 test:true 0.064
[RUSTC-TIMING] win_delete_self test:true 0.035
[RUSTC-TIMING] stdbenches test:true 0.139
error[E0658]: use of unstable library feature `normalize_lexically`
    --> library/std/tests/path.rs:1983:39
     |
1983 |     fn check(a: &str, b: Result<&str, NormalizeError>) {
     |                                       ^^^^^^^^^^^^^^
     |
     = note: see issue #134694 <https://github.com/rust-lang/rust/issues/134694> for more information
     = help: add `#![feature(normalize_lexically)]` to the crate attributes to enable
     = note: this compiler was built on 2025-04-01; consider upgrading it if it is out of date
---
[RUSTC-TIMING] builtin_clone test:true 0.051
error[E0658]: use of unstable library feature `normalize_lexically`
    --> library/std/tests/path.rs:1984:33
     |
1984 |         assert_eq!(Path::new(a).normalize_lexically(), b.map(PathBuf::from));
     |                                 ^^^^^^^^^^^^^^^^^^^
     |
     = note: see issue #134694 <https://github.com/rust-lang/rust/issues/134694> for more information
     = help: add `#![feature(normalize_lexically)]` to the crate attributes to enable
     = note: this compiler was built on 2025-04-01; consider upgrading it if it is out of date

@workingjubilee
Copy link
Member

workingjubilee commented May 2, 2025

ugh, the move of the tests breaks them because they relied on a struct expr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

5 participants