Skip to content

Update path separators to be available in const context#153196

Open
MikkelPaulson wants to merge 2 commits intorust-lang:mainfrom
MikkelPaulson:const-path-separators
Open

Update path separators to be available in const context#153196
MikkelPaulson wants to merge 2 commits intorust-lang:mainfrom
MikkelPaulson:const-path-separators

Conversation

@MikkelPaulson
Copy link

@MikkelPaulson MikkelPaulson commented Feb 27, 2026

Tracking issue: #153106

This makes platform-dependent secondary path separators available in const context (ie. at compile time). The platform definitions have also been consolidated behind a common macro to prevent transcription errors, whereas previously they were defined 3-4 times per platform.

Questions

I've manually verified that this compiles against each platform. It seems like no unit tests should be required for this change; is that correct?

Change reference to imported MAIN_SEP_STR to local MAIN_SEPARATOR_STR,
removing an unnecessary import.
* consolidate various representations of separators in std::sys::path
  into a single macro_rules invocation per platform to save
  transcription errors
* make `std::path::is_separator()` const
* new constants `std::path::{SEPARATORS, SEPARATORS_STR}`
@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 Feb 27, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 27, 2026

r? @joboet

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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ChrisDenton, libs
  • @ChrisDenton, libs expanded to 8 candidates
  • Random selection from Mark-Simulacrum, joboet

Copy link
Member

@joboet joboet left a comment

Choose a reason for hiding this comment

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

I'm not sure the FIXME is necessary, but everything else looks very good!

View changes since this review

Comment on lines +4 to +5
// FIXME(const_array): this can be done much more cleanly at compile time without a macro once
// array::from_fn and/or array::map are stabilized
Copy link
Member

Choose a reason for hiding this comment

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

I think we'd still want the macro in this case because it makes the item definitions simpler.

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. 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.

3 participants