Skip to content
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

Fixup Windows verbatim paths when used with the include! macro #125205

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

Conversation

ChrisDenton
Copy link
Contributor

On Windows, the following code can fail if the OUT_DIR environment variable is a verbatim path (i.e. begins with \\?\):

include!(concat!(env!("OUT_DIR"), "/src/repro.rs"));

This is because verbatim paths treat / literally, as if it were just another character in the file name.

The good news is that the standard library already has code to fix this. We can simply use components to normalize the path so it works as intended.

@rustbot
Copy link
Collaborator

rustbot commented May 17, 2024

r? @jieyouxu

rustbot has assigned @jieyouxu.
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-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 17, 2024
@rustbot
Copy link
Collaborator

rustbot commented May 17, 2024

Some changes occurred in run-make tests.

cc @jieyouxu

@ChrisDenton ChrisDenton added the T-lang Relevant to the language team, which will review and decide on the PR/issue. label May 17, 2024
@rust-log-analyzer

This comment has been minimized.

When using `concat!` to join paths, the Unix path separator (`/`) is often used. This breaks on Windows if the base path is a verbatim path (i.e. starts with `\\?\`).
@ChrisDenton
Copy link
Contributor Author

While I'd very much welcome a review from jieyouxu, this will need lang approval. I think it could just be considered a bug fix but it might also be considered a change in language.

cc @joshtriplett maybe?

@Nilstrieb
Copy link
Member

Given that I see most projects already using / as the separator, calling it a bug fix seems fair. Still, I agree that lang should see it.

@jieyouxu
Copy link
Contributor

Changes look reasonable from compiler side. Rolling a lang reviewer to decide if this behavior change is acceptable.

r? lang

@rustbot rustbot assigned joshtriplett and unassigned jieyouxu May 17, 2024
@ChrisDenton ChrisDenton added S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants