Skip to content

Refactor how we convert from T: Error to dyn CargoError #1516

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
merged 2 commits into from
Oct 13, 2018

Conversation

sgrif
Copy link
Contributor

@sgrif sgrif commented Oct 12, 2018

The way we handled this before with a Shim struct breaks any later
downcasting we may try to do, and can lead to errors slipping through in
a hard to debug way. It's much easier if we just directly implement
CargoError on those types (and lets us get rid of some trivial impls).

This new impl conflicts with impl<T: CargoError> CargoError for Box<T>. It's fine to remove that impl. It means that
Box<ConcreteType> no longer implements CargoError, but we wouldn't
have boxed the error in the first place unless we needed dyn CargoError.

The way we handled this before with a `Shim` struct breaks any later
downcasting we may try to do, and can lead to errors slipping through in
a hard to debug way. It's much easier if we just directly implement
`CargoError` on those types (and lets us get rid of some trivial impls).

This new impl conflicts with `impl<T: CargoError> CargoError for
Box<T>`. It's fine to remove that impl. It means that
`Box<ConcreteType>` no longer implements `CargoError`, but we wouldn't
have boxed the error in the first place unless we needed `dyn
CargoError`.
@jtgeibel
Copy link
Member

LGTM!

bors: r+

bors-voyager bot added a commit that referenced this pull request Oct 13, 2018
1516: Refactor how we convert from `T: Error` to `dyn CargoError` r=jtgeibel a=sgrif

The way we handled this before with a `Shim` struct breaks any later
downcasting we may try to do, and can lead to errors slipping through in
a hard to debug way. It's much easier if we just directly implement
`CargoError` on those types (and lets us get rid of some trivial impls).

This new impl conflicts with `impl<T: CargoError> CargoError for
Box<T>`. It's fine to remove that impl. It means that
`Box<ConcreteType>` no longer implements `CargoError`, but we wouldn't
have boxed the error in the first place unless we needed `dyn
CargoError`.

Co-authored-by: Sean Griffin <[email protected]>
Co-authored-by: Justin Geibel <[email protected]>
@bors-voyager
Copy link
Contributor

bors-voyager bot commented Oct 13, 2018

Build succeeded

@bors-voyager bors-voyager bot merged commit 869bbb5 into rust-lang:master Oct 13, 2018
@sgrif sgrif deleted the sg-refactor-error branch October 23, 2018 19:26
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.

2 participants