-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Windows verbatim paths shouldn't normalize path when .push-ed #11594
Comments
@erickt When pushing anything onto a verbatim path, we explicitly normalize the pushed argument first. When pushing onto a non-verbatim path, we concatenate them and normalize the result. The idea here is that we're pushing paths, not arbitrary strings. This makes for an argument that we should have another method However, I am leery about the idea of adding 4 more API methods ( |
Yeah, I don't love the idea of adding more API methods either. What do you think about changing how normalization is done? If we didn't normalize by default, the end user could decide that they didn't want to run normalization on a verbatim path. |
@erickt We need to normalize. The entire way the path module is implemented assumes that all Another option is to add a There's a third option which might solve your specific use-case, which is a |
This PR implements [path reform](rust-lang/rfcs#474), and motivation and details for the change can be found there. For convenience, the old path API is being kept as `old_path` for the time being. Updating after this PR is just a matter of changing imports to `old_path` (which is likely not needed, since the prelude entries still export the old path API). This initial PR does not include additional normalization or platform-specific path extensions. These will be done in follow up commits or PRs. [breaking-change] Closes rust-lang#20034 Closes rust-lang#12056 Closes rust-lang#11594 Closes rust-lang#14028 Closes rust-lang#14049 Closes rust-lang#10035
…fate [`get_first`]: lint on non-primitive slices Fixes rust-lang#11594 I left the issue open for a couple days before making the PR to see if anyone has something to say, but it looks like there aren't any objections to removing this check that prevented linting on non-primitive slices, so here's the PR now. There's a couple of instances in clippy itself where we now emit the lint. The actual relevant change is in the first commit and fixing the `.get(0)` instances in clippy itself is in the 2nd commit. changelog: [`get_first`]: lint on non-primitive slices
cc: @kballard
If I understand windows verbatim paths correctly, a path like
\\?\a\b\
should not normalize away that last trailing slash.WindowsPath::new
does this correctly. However, if we break up the paths into\\?a
andb\
and use push to join the paths, that trailing slash is removed:The text was updated successfully, but these errors were encountered: