-
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
Fixup Windows verbatim paths when used with the include!
macro
#125205
Conversation
Some changes occurred in run-make tests. cc @jieyouxu |
This comment has been minimized.
This comment has been minimized.
f9bf99b
to
2b7a45c
Compare
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? |
Given that I see most projects already using |
Changes look reasonable from compiler side. Rolling a lang reviewer to decide if this behavior change is acceptable. r? lang |
☔ The latest upstream changes (presumably #125443) made this pull request unmergeable. Please resolve the merge conflicts. |
2b7a45c
to
9d52111
Compare
This comment has been minimized.
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 `\\?\`).
9d52111
to
edc97a0
Compare
It looks like this is limited to verbatim paths, which seems completely safe. This wouldn't be safe to do for arbitrary Windows driver-interpreted paths, but it seems entirely safe for Windows verbatim paths. |
Thanks! So I'm going to go out on a limb and say jieyouxu's positive review still stands. @bors r=jieyouxu |
I mean you can't use |
@rustbot labels -I-lang-easy-decision This one turned out to not be an easy call for us. One question that came up is: @ChrisDenton: Is there any way that someone could have used the behavior that exists today correctly with forward slashes in the string? I.e., is there any plausibly valid use case that we might be breaking? (h/t @tmandry) |
I cannot think of one. I can think of an implausible scenario. Like someone could create a named pipe, containing |
But I would note that if they're doing something that's not only platform specific but requires a fair amount of hacks (and would break when using normal The scenario for supporting this is a lot more plausible: someone sets an environment variable in a build script using |
@rfcbot reviewed Based on the responses here, what's proposed seems like at least the best worst option. |
@rfcbot reviewed |
1 similar comment
@rfcbot reviewed |
This isn't I just think that we should do it for all compiler paths if we're doing it here. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
@rustbot labels -I-lang-nominated We discussed this in the meeting today... and it's now in FCP. |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
Oh, it turns out we do something kind of similar for rust/compiler/rustc_expand/src/module.rs Lines 195 to 200 in f225713
|
This has passed lang FCP and was earlier approved by @jieyouxu so I'll merge this now. I'll look more at rust/compiler/rustc_expand/src/module.rs Line 202 in f225713
@bors r=jieyouxu |
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#125205 (Fixup Windows verbatim paths when used with the `include!` macro) - rust-lang#131049 (Validate args are correct for `UnevaluatedConst`, `ExistentialTraitRef`/`ExistentialProjection`) - rust-lang#131549 (Add a note for `?` on a `impl Future<Output = Result<..>>` in sync function) - rust-lang#131731 (add `TestFloatParse` to `tools.rs` for bootstrap) - rust-lang#131732 (Add doc(plugins), doc(passes), etc. to INVALID_DOC_ATTRIBUTES) - rust-lang#132006 (don't stage-off to previous compiler when CI rustc is available) - rust-lang#132022 (Move `cmp_in_dominator_order` out of graph dominator computation) - rust-lang#132033 (compiletest: Make `line_directive` return a `DirectiveLine`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#125205 - ChrisDenton:verbatim-include, r=jieyouxu Fixup Windows verbatim paths when used with the `include!` macro On Windows, the following code can fail if the `OUT_DIR` environment variable is a [verbatim path](https://doc.rust-lang.org/std/path/enum.Prefix.html) (i.e. begins with `\\?\`): ```rust 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.
On Windows, the following code can fail if the
OUT_DIR
environment variable is a verbatim path (i.e. begins with\\?\
):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.