Why is there an `E: Sized` bound for `Box<E>: Error`

There's no Sized bound for &impl Error:

Or for Arc<impl Error>:

But there is for Box<impl Error>:


Just checking that there's a reason, else I assume I can create ACP

This is a known quirk of the Box API:

I don't know if there is a language feature around today that wasn't back then that would allow adding the ?Sized bound without any conflicts, might be worth looking into.

You need specialization due to the existing implementations

impl<T> From<T> for T { ... }
impl<'e, E: Error + 'e> From<E> for Box<dyn Error + 'e> { ... }

overlapping if Box<dyn Error + '_>: Error.

1 Like