-
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
Pushing an empty path to a verbatim path no longer adds a separator #89658
Comments
Since rust-lang/rust#89270 rust's pathbuf push() normalizes the path if it is a verbatim path, so that the result is still a valid verbatim path. This involves parsing reconstructing the path. Appending a path separator using push("") will no longer work, and if it did, it would be very inefficient. rust-lang/rust#89658 Signed-off-by: Sean Young <[email protected]>
This is an interesting case. The normpath crate has its own path push function to work around the issue of verbatim paths not working with PathBuf::push(), which is exactly the same issue that my PR #89270 was trying to solve upstream. The normpath push() function uses pathbuf push function to append a directory separator by calling I've created a PR on normpath to fix the issue there: dylni/normpath#4 So since verbatim paths have special handling to ensure the returned path normalized, yes there are differences. If you call |
Hm, should this not be special cased so that it works the same for all paths? Otherwise the only way to push a trailing separator is to convert to an IMHO, ideally this would be fixed in |
We could special case it so that |
Would this break existing code though? |
@ChrisDenton on second thought, maybe you are right. Let me see what I can do. |
Ensure that pushing empty path works as before on verbatim paths Fixes: rust-lang#89658 Signed-off-by: Sean Young <[email protected]>
Ensure that pushing empty path works as before on verbatim paths Fixes: rust-lang#89658 Signed-off-by: Sean Young <[email protected]>
This reverts commit da9b7b2.
This reverts commit da9b7b2. rust-lang/rust#89665
This reverts commit da9b7b2. This workaround is no longer necessary: rust-lang/rust#89665
Fixes: rust-lang#89658 (cherry picked from commit 1bb399c)
Code
I tried this code:
I expected to see this happen: Both assertions succeed.
Instead, this happened: The second assertion fails, likely due to #89270:
Although adding a separator when pushing an empty path is debatable, the behavior should probably be consistent for verbatim and non-verbatim paths.
This change caused normpath to break. I can add an inefficient workaround, but is this change intentional?
Version it worked on
It most recently worked on: 1.56.0-beta.4
Version with regression
rustc --version --verbose
:@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged +O-windows
cc @seanyoung
The text was updated successfully, but these errors were encountered: