-
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
Implement FromStr for PathBuf #48292
Implement FromStr for PathBuf #48292
Conversation
r? @kennytm (rust_highfive has picked a reviewer for you, use r? to override) |
74984b3
to
5cfbda9
Compare
Implementing
|
@topecongiro try to implement it for |
@kennytm Thank you for the review! I added a commit to implement |
@topecongiro Oh sorry, looks like it is not possible to implement cc @rust-lang/libs — This PR introduces |
src/libstd/path.rs
Outdated
/// An error returned when parsing `Path` or `PathBuf` using `from_str` fails. | ||
#[derive(Debug, Clone, PartialEq, Eq)] | ||
#[stable(feature = "rust1", since = "1.0.0")] | ||
pub struct ParsePathError { _priv: () } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since parsing a Path will never fail, please make it an empty enum:
pub enum ParsePathError {}
Alternatively, simply return std::string::ParseError
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't reuse an existing type.
src/libstd/path.rs
Outdated
} | ||
} | ||
|
||
#[stable(feature = "rust1", since = "1.0.0")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The feature should not be rust1
. Please create a feature name e.g. path_from_str
and set the since
to be 1.26.0
.
f6c289c
to
a9b935f
Compare
src/libstd/path.rs
Outdated
#[stable(feature = "path_from_str", since = "1.26.0")] | ||
impl fmt::Display for ParsePathError { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
"provided string was not a valid path".fmt(f) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should just be match *self {}
.
Yeah following the implementation of (cc @topecongiro) |
Ping from triage, @topecongiro ! Will you have time soon to address the feedback above? |
a9b935f
to
05a9acc
Compare
I am sorry for the late response. I have updated the PR to use |
@rfcbot fcp merge |
Team member @alexcrichton has proposed to merge this. The next step is review by the rest of the tagged teams: Concerns:
Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
|
Both ParsePathError and string::ParseError are going to turn into typedefs for |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
My point was that we may not have to stabilize |
@bors: r+ |
📌 Commit 05a9acc has been approved by |
⌛ Testing commit 05a9acc with merge 38c616009116c7e770eb16020c6beba55dd46403... |
💔 Test failed - status-appveyor |
@bors retry rollup 3 hour timeout in It took 43 minutes to compile stage1-rustc 🙄. Timing breakdown
Relevant logs
For comparison, the build timings of the all jobs in this build:
|
…athbuf, r=alexcrichton Implement FromStr for PathBuf Closes rust-lang#44431.
…r=sfackler Revert "Implement FromStr for PathBuf" This reverts commit 05a9acc. The libs team was discussing rust-lang#44431 today and the changes originally added in rust-lang#48292 and the conclusion was that we'd like to revert this for now until `!` is stable. This'll provide us maximal flexibility to tweak the error type here in the future, and it looks like `!` is close-ish to stabilization so hopefully this won't be delayed for too long.
Initially landed in rust-lang#48292 and reverted in rust-lang#50401. This time, use `std::string::ParseError` as suggested in rust-lang#44431 (comment)
Implement FromStr for PathBuf Initially landed in rust-lang#48292 and reverted in rust-lang#50401. This time, use `std::string::ParseError` as suggested in rust-lang#44431 (comment)
Implement FromStr for PathBuf Initially landed in rust-lang#48292 and reverted in rust-lang#50401. This time, use `std::string::ParseError` as suggested in rust-lang#44431 (comment)
Initially landed in rust-lang#48292 and reverted in rust-lang#50401. This time, use `std::string::ParseError` as suggested in rust-lang#44431 (comment)
Closes #44431.