title: Why do these impls conflict?
body: <p>I have a trait representing a storage type, with a method to take out that storage as either a boxed value or unboxed value.</p>
  <p>I have a second trait to allow conversion from a container using that storage trait into an arbitrary but specific type. I want to do blanket implementations from the container type either boxed or unboxed types.</p>
  <p>Here is a simplified example. In my actual code, I'm not actually working with box, but rather with memory allocated in slightly complicated ways, but box demonstrates the issue I've run into:</p>
  <pre class="lang-rust prettyprint-override"><code>enum MaybeBoxed&lt;T&gt; {
      Boxed(Box&lt;T&gt;),
      Unboxed(T),
  }
  
  trait Storage {
      type Stored;
      
      fn into_inner(self) -&gt; MaybeBoxed&lt;T&gt; where Self: Sized;
  }
  
  struct BoxedStorage&lt;T&gt;(Box&lt;T&gt;);
  
  impl&lt;T&gt; Storage for BoxedStorage&lt;T&gt; {
      type Stored = T;
      
      fn into_inner(self) -&gt; MaybeBoxed&lt;T&gt; {
          MaybeBoxed::Boxed(self.0)
      }
  }
  
  struct UnboxedStorage&lt;T&gt;(T);
  
  impl&lt;T&gt; Storage for UnboxedStorage&lt;T&gt; {
      type Stored = T;
      
      fn into_inner(self) -&gt; MaybeBoxed&lt;T&gt; {
          MaybeBoxed::Unboxed(self.0)
      }
  }
  
  struct Container&lt;S: Storage&gt;(S);
  
  trait MakeInto&lt;T&gt; {
      fn make_into(self) -&gt; T;
  }
  
  impl&lt;S: Storage&gt; MakeInto&lt;S::Stored&gt; for Container&lt;S&gt; {
      fn make_into(self) -&gt; S::Stored {
          match self.0.into_inner() {
              MaybeBoxed::Boxed(boxed) =&gt; *boxed,
              MaybeBoxed::Unboxed(unboxed) =&gt; unboxed,
          }
      }
  }
  
  impl&lt;S: Storage&gt; MakeInto&lt;Box&lt;S::Stored&gt;&gt; for Container&lt;S&gt; {
      fn make_into(self) -&gt; Box&lt;S::Stored&gt; {
          match self.0.into_inner() {
              MaybeBoxed::Boxed(boxed) =&gt; boxed,
              MaybeBoxed::Unboxed(unboxed) =&gt; Box::new(unboxed),
          }
      }
  }
  </code></pre>
  <p>Now, it seems like these last two impls should be exclusive, because <code>S::Storage</code> is an associated type, so it seems like <code>&lt;Container&lt;S&gt; as MakeInto&lt;S::Stored&gt;&gt;</code> ought to be provably a different type from <code>&lt;Container&lt;S&gt; as MakeInto&lt;Box&lt;S::Stored&gt;&gt;&gt;</code>, since even if <code>S::Stored</code> is <code>Box&lt;U&gt;</code>, the former becomes <code>MakeInto&lt;Box&lt;U&gt;&gt;</code> and the latter becomes <code>MakeInto&lt;Box&lt;Box&lt;U&gt;&gt;</code>.</p>
  <p>However, the compiler doesn't agree:</p>
  <pre><code>error[E0119]: conflicting implementations of trait `MakeInto&lt;std::boxed::Box&lt;_&gt;&gt;` for type `Container&lt;_&gt;`
    --&gt; src/main.rs:47:1
     |
  38 | impl&lt;S: Storage&gt; MakeInto&lt;S::Stored&gt; for Container&lt;S&gt; {
     | ----------------------------------------------------- first implementation here
  ...
  47 | impl&lt;S: Storage&gt; MakeInto&lt;Box&lt;S::Stored&gt;&gt; for Container&lt;S&gt; {
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Container&lt;_&gt;`
  </code></pre>
  <p><a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2021&amp;gist=36cbf51426b3c1ecdf013736fae649d7" rel="nofollow noreferrer">playground link</a></p>
  <p>In a previous iteration of this codebase, before I made <code>Storage</code> a generic type, I used a fixed set of storages and defined separate impls for each of them. At that time, I <em>was</em> able to separately define <code>MakeInto&lt;T&gt;</code> and <code>MakeInto&lt;Box&lt;T&gt;&gt;</code> for the same <code>Container&lt;S&gt;</code> with impls like <code>impl&lt;T&gt; MakeInto&lt;T&gt; for Container&lt;BoxedStorage&lt;T&gt;&gt;</code> and <code>impl&lt;T&gt; MakeInto&lt;Box&lt;T&gt;&gt; for Container&lt;BoxedStorage&lt;T&gt;&gt;</code> without running into conflicting impls. <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2021&amp;gist=95e1af40435a5e317b823448176f56f6" rel="nofollow noreferrer">playground link</a>.</p>
  <p>In current stable rust, is there any way to convince the compiler that these impls are in fact disjoint? Or are they really not disjoint and there's some case where they overlap that I've missed?</p>