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

Implement Error::source on IntoStringError + Remove superfluous cause impls #65366

Merged
merged 2 commits into from
Oct 13, 2019

Conversation

faern
Copy link
Contributor

@faern faern commented Oct 13, 2019

IntoStringError only implemented Error::cause, which is deprecated. This implemements Error::source instead.
Error::cause will still work as before, thanks to the default implementation.

I think this was the only/last Error impl in the standard library to have a cause, but not a source.

IntoStringError only implemented Error::cause, which is
deprecated. This implemements Error::source instead.
Error::cause will still work as before, thanks to the default
implementation.
@rust-highfive
Copy link
Collaborator

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 13, 2019
@faern
Copy link
Contributor Author

faern commented Oct 13, 2019

I think this was the only/last Error impl in the standard library to have a cause, but not a source.

This guess was wrong. TryLockError also implements cause but no source. In this case it's harder to fix, because it has a generic parameter T which does not have the 'static bound. So just implementing source does not work. And adding the bound breaks a lot of places where it's used.

@faern faern changed the title Implement Error::source on IntoStringError Implement Error::source on IntoStringError + Remove superfluous cause impls Oct 13, 2019
@faern
Copy link
Contributor Author

faern commented Oct 13, 2019

Pushed two more commits. Removing cause implementations that are not needed any more. Because they will be covered by cause forwarding to source by default.

Repr::Os(..) => None,
Repr::Simple(..) => None,
Repr::Custom(ref c) => c.error.cause(),
}
Copy link
Member

Choose a reason for hiding this comment

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

This risks being a noticeable change since we are calling out to a user-supplied .cause() vs .source() here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! I almost expected there was some aspect of this I missed 😅
I removed the last commit.

@faern faern force-pushed the source-on-intostringerror branch from 9c00e07 to b8e7f76 Compare October 13, 2019 12:15
@bluss
Copy link
Member

bluss commented Oct 13, 2019

@bors r+ rollup

Thanks!

@bors
Copy link
Contributor

bors commented Oct 13, 2019

📌 Commit b8e7f76 has been approved by bluss

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 13, 2019
Centril added a commit to Centril/rust that referenced this pull request Oct 13, 2019
…bluss

Implement Error::source on IntoStringError + Remove superfluous cause impls

IntoStringError only implemented `Error::cause`, which is deprecated. This implemements `Error::source` instead.
`Error::cause` will still work as before, thanks to the default implementation.

I think this was the only/last `Error` impl in the standard library to have a cause, but not a source.
Centril added a commit to Centril/rust that referenced this pull request Oct 13, 2019
…bluss

Implement Error::source on IntoStringError + Remove superfluous cause impls

IntoStringError only implemented `Error::cause`, which is deprecated. This implemements `Error::source` instead.
`Error::cause` will still work as before, thanks to the default implementation.

I think this was the only/last `Error` impl in the standard library to have a cause, but not a source.
bors added a commit that referenced this pull request Oct 13, 2019
Rollup of 10 pull requests

Successful merges:

 - #65214 (Split non-CAS atomic support off into target_has_atomic_load_store)
 - #65246 (vxWorks: implement get_path() and get_mode() for File fmt::Debug)
 - #65312 (improve performance of signed saturating_mul)
 - #65336 (Fix typo in task::Waker)
 - #65346 (nounwind tests and cleanup)
 - #65347 (Fix #[unwind(abort)] with Rust ABI)
 - #65366 (Implement Error::source on IntoStringError + Remove superfluous cause impls)
 - #65369 (Don't discard value names when using address or memory sanitizer)
 - #65370 (Add `dyn` to `Any` documentation)
 - #65373 (Fix typo in docs for `Rc`)

Failed merges:

r? @ghost
@bors bors merged commit b8e7f76 into rust-lang:master Oct 13, 2019
@faern faern deleted the source-on-intostringerror branch October 25, 2019 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants