<p dir="auto">I'm trying to write an <code class="notranslate">Error</code> implementation which supports a set of "important" error, plus a catch-all for various minor errors caused by low-level subsystems. The code looks something like this:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="use std::error::Error;

pub enum DecodingError {
    EncodingUnknown,
    //...several named errors here...
    /// Other errors, the details of which are probably unimportant.
    Unexpected(Box&lt;Error+Send&gt;)
}

impl Error for DecodingError {
    fn description(&amp;self) -&gt; &amp;str { &quot;decoding error&quot; }
    fn detail(&amp;self) -&gt; Option&lt;String&gt; { None }
    fn cause(&amp;self) -&gt; Option&lt;&amp;Error&gt; {
        match self {
            &amp;DecodingError::Unexpected(cause) =&gt; Some(&amp;*cause),
            _ =&gt; None
        }
    }
}"><pre class="notranslate"><span class="pl-k">use</span> std<span class="pl-kos">::</span>error<span class="pl-kos">::</span><span class="pl-v">Error</span><span class="pl-kos">;</span>

<span class="pl-k">pub</span> <span class="pl-k">enum</span> <span class="pl-smi">DecodingError</span> <span class="pl-kos">{</span>
    <span class="pl-v">EncodingUnknown</span><span class="pl-kos">,</span>
    <span class="pl-c">//...several named errors here...</span>
    <span class="pl-c">/// Other errors, the details of which are probably unimportant.</span>
    <span class="pl-v">Unexpected</span><span class="pl-kos">(</span><span class="pl-smi">Box</span><span class="pl-kos">&lt;</span><span class="pl-smi">Error</span>+<span class="pl-smi">Send</span><span class="pl-kos">&gt;</span><span class="pl-kos">)</span>
<span class="pl-kos">}</span>

<span class="pl-k">impl</span> <span class="pl-smi">Error</span> <span class="pl-k">for</span> <span class="pl-smi">DecodingError</span> <span class="pl-kos">{</span>
    <span class="pl-k">fn</span> <span class="pl-en">description</span><span class="pl-kos">(</span><span class="pl-c1">&amp;</span><span class="pl-smi">self</span><span class="pl-kos">)</span> -&gt; <span class="pl-c1">&amp;</span><span class="pl-smi">str</span> <span class="pl-kos">{</span> <span class="pl-s">"decoding error"</span> <span class="pl-kos">}</span>
    <span class="pl-k">fn</span> <span class="pl-en">detail</span><span class="pl-kos">(</span><span class="pl-c1">&amp;</span><span class="pl-smi">self</span><span class="pl-kos">)</span> -&gt; <span class="pl-smi">Option</span><span class="pl-kos">&lt;</span><span class="pl-smi">String</span><span class="pl-kos">&gt;</span> <span class="pl-kos">{</span> <span class="pl-v">None</span> <span class="pl-kos">}</span>
    <span class="pl-k">fn</span> <span class="pl-en">cause</span><span class="pl-kos">(</span><span class="pl-c1">&amp;</span><span class="pl-smi">self</span><span class="pl-kos">)</span> -&gt; <span class="pl-smi">Option</span><span class="pl-kos">&lt;</span><span class="pl-c1">&amp;</span><span class="pl-smi">Error</span><span class="pl-kos">&gt;</span> <span class="pl-kos">{</span>
        <span class="pl-k">match</span> <span class="pl-smi">self</span> <span class="pl-kos">{</span>
            <span class="pl-c1">&amp;</span><span class="pl-smi">DecodingError</span><span class="pl-kos">::</span><span class="pl-v">Unexpected</span><span class="pl-kos">(</span>cause<span class="pl-kos">)</span> =&gt; <span class="pl-v">Some</span><span class="pl-kos">(</span><span class="pl-c1">&amp;</span><span class="pl-c1">*</span>cause<span class="pl-kos">)</span><span class="pl-kos">,</span>
            _ =&gt; <span class="pl-v">None</span>
        <span class="pl-kos">}</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">This yields the following error in <code class="notranslate">cause</code>:</p>
<blockquote>
<p dir="auto">:14:9: 17:10 error: mismatched types: expected <code class="notranslate">core::option::Option&lt;&amp;std::error::Error+'static&gt;</code>, found <code class="notranslate">core::option::Option&lt;&amp;std::error::Error+Send&gt;</code> (expected no bounds, found <code class="notranslate">Send</code>)</p>
</blockquote>
<p dir="auto">I should presumably be able to convert a <code class="notranslate">Box&lt;Error+Send&gt;</code> to an <code class="notranslate">&amp;Error</code> safely, but I can't figure out a way to do it.</p>
<p dir="auto">There is currently <em>no way</em> to get a <code class="notranslate">Box&lt;Reader&gt;</code> (or anything else that impls <code class="notranslate">Reader</code>) out of a <code class="notranslate">Box&lt;Reader + Constraint&gt;</code>, for instance <code class="notranslate">Box&lt;Reader + Send&gt;</code>. This is a significant ergonomic problem.</p>
<p dir="auto">Additionally, <code class="notranslate">Box&lt;Reader + Constraint&gt;</code> should impl <code class="notranslate">Reader</code> since <code class="notranslate">Box&lt;Reader&gt;</code> impls <code class="notranslate">Reader</code>.</p>