Skip to content

Implement error::Error and fmt::Display for string::ParseError #31124

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

Merged

Conversation

dirk
Copy link
Contributor

@dirk dirk commented Jan 22, 2016

Fixes #31106.

Couple of questions:
  • I wasn't sure of the correct #[stable(...)] definition to use here. Happy to fix it if it's incorrect.
  • ParseError is sort of an ephemeral non-error, but do let me know if the implementation of error::Error for it should return something more descriptive than "parse error".

@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @gankro (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@dirk dirk force-pushed the dirk/display-and-error-impls-for-string-parse-error branch from d5b4c2a to 992a7d3 Compare January 22, 2016 18:55
#[stable(feature = "str_parse_error2", since = "1.8.0")]
impl Error for string::ParseError {
fn description(&self) -> &str {
"parse error"
Copy link
Member

Choose a reason for hiding this comment

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

Ah here you can probably do the same match *self {} trick to avoid the need to return anything here at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alexcrichton
Copy link
Member

Looks good to me, thanks @dirk! The stability attributes are fine here (impls are insta-stable) and we picking any old name for the feature is fine

@alexcrichton
Copy link
Member

@bors: r+ 365deeb

Thanks @dirk!

@alexcrichton alexcrichton assigned alexcrichton and unassigned Gankra Jan 22, 2016
@dirk
Copy link
Contributor Author

dirk commented Jan 22, 2016

@alexcrichton: Thanks, glad to help out! 😄

bors added a commit that referenced this pull request Jan 23, 2016
…arse-error, r=alexcrichton

Fixes #31106.

- [ ] I wasn't sure of the correct `#[stable(...)]` definition to use here. Happy to fix it if it's incorrect.
- [ ] `ParseError` is sort of an ephemeral non-error, but do let me know if the implementation of `error::Error` for it should return something more descriptive than "parse error".
@bors
Copy link
Collaborator

bors commented Jan 23, 2016

⌛ Testing commit 365deeb with merge 93d03ed...

@bors bors merged commit 365deeb into rust-lang:master Jan 23, 2016
@dirk dirk deleted the dirk/display-and-error-impls-for-string-parse-error branch January 23, 2016 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

std::string::ParseError doesn't implement neither std::error::Error nor std::fmt::Display.
5 participants