Hey @rustlang twitter: any particular reason that there isn't an instance of std::error::Error for Arc<dyn std::error::Error>?
Would be quite useful when you want a cloneable dyn error for just exploring things without being bogged down in error handling intricacies...
-
-
Arc<dyn Error> and Box<dyn Error> cannot impl Error due to the overlap rule which says currently in rust you cannot have two generic trait impls both be valid for the same type. From<T> for Arc<T> and From<T> for T would overlap if Arc<dyn Error> itself could coerce to dyn Error
2 replies 0 retweets 5 likes -
This would be true if there was `impl<E: Error> From<E> for Arc<dyn Error>`, but there is no such impl. Only for Box.
1 reply 0 retweets 1 like -
Oh yea you need a concrete impl don't you, I forgot the From<T> doesn't work as a coersion site for dyn Error.
1 reply 0 retweets 0 likes -
Either way, you can't meaningfully get what
@klaehnr wants which is presumably a catch all error type via Arc that itself impls Error. Side question, Sian do you know if specialization is planned to allow overlap?2 replies 0 retweets 0 likes -
You definitely could write `impl<E: Error + ?Sized> Error for Arc<E>`.There's nothing incoherent about it.
1 reply 0 retweets 1 like -
Yaah 🦀 Retweeted Yaah 🦀
Yaah 🦀 added,
1 reply 0 retweets 0 likes -
The `Sized` bound doesn't need to be there
1 reply 0 retweets 1 like -
Or rather could be `?Sized`
2 replies 0 retweets 0 likes -
But it will match `dyn Error`, resulting in same conflict again.
1 reply 0 retweets 1 like
Match `dyn Error` for what?
-
-
Ingvar Stepanyan Retweeted Yaah 🦀
Ingvar Stepanyan added,
Yaah 🦀 @yaahc_Replying to @klaehnr @rustlangArc<dyn Error> and Box<dyn Error> cannot impl Error due to the overlap rule which says currently in rust you cannot have two generic trait impls both be valid for the same type. From<T> for Arc<T> and From<T> for T would overlap if Arc<dyn Error> itself could coerce to dyn Error1 reply 0 retweets 1 like -
Replying to @RReverser @yaahc_ and
Those don't overlap and wouldn't ever though. The issue with Box is `impl<E: Error + ?Sized> From<E> for Box<dyn Error>`. There is no such impl for Arc. https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=36eb504e655f8b8a8bf9ffa80fee98cb …
2 replies 0 retweets 1 like - 1 more reply
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.