Repository: rust
Issue: Compiler asks for already present bound
Labels: A-trait-system,A-associated-items,T-compiler,C-bug,E-needs-mcve

While working on RustCrypto/stream-ciphers#195. I got roughly the following code:

```rust
use generic_array::{GenericArray, ArrayLength, typenum::{Unsigned, Quot, U16}};
use core::ops::Div;

pub trait Foo: Copy + Default {
    type Size: Unsigned;

    fn load<N>(block: &GenericArray<u8, N>) -> GenericArray<Self, Quot<N, Self::Size>>
    where
        N: ArrayLength<u8> + Div<Self::Size>,
        Quot<N, Self::Size>: ArrayLength<Self>
    {
        Default::default()
    }
}

#[derive(Copy, Clone, Default)]
#[repr(transparent)]
struct Bar(u128);

impl Foo for Bar {
    type Size = U16;
}
```
It compiles without issues. The default method impl will not be present in the final code, I just use it to show that the bounds are correct.

But if we are to overwrite the `load` method in the `Bar` impl by simply copying the default impl:
```rust
impl Foo for Bar {
    type Size = U16;

    fn load<N>(block: &GenericArray<u8, N>) -> GenericArray<Self, Quot<N, Self::Size>>
    where
        N: ArrayLength<u8> + Div<Self::Size>,
        Quot<N, Self::Size>: ArrayLength<Self>
    {
        Default::default()
    }
}
```

[Playground](https://play.rust-lang.org/?edition=2018&gist=5e383c4922a38832f51512778a0def31)

Compiler will return the following compilation errors:
<details>

```
error[E0277]: cannot divide `N` by `UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>`
  --> src/lib.rs:23:5
   |
23 | /     fn load<N>(block: &GenericArray<u8, N>) -> GenericArray<Self, Quot<N, Self::Size>>
24 | |     where
25 | |         N: ArrayLength<u8> + Div<Self::Size>,
26 | |         Quot<N, Self::Size>: ArrayLength<Self>
   | |______________________________________________^ no implementation for `N / UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>`
   |
help: consider further restricting this bound
   |
25 |         N: ArrayLength<u8> + Div<Self::Size> + Div<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>>,
   |                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0277]: cannot divide `N` by `UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>`
  --> src/lib.rs:23:5
   |
23 | /     fn load<N>(block: &GenericArray<u8, N>) -> GenericArray<Self, Quot<N, Self::Size>>
24 | |     where
25 | |         N: ArrayLength<u8> + Div<Self::Size>,
26 | |         Quot<N, Self::Size>: ArrayLength<Self>
27 | |     {
28 | |         Default::default()
29 | |     }
   | |_____^ no implementation for `N / UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>`
   |
help: consider further restricting this bound
   |
25 |         N: ArrayLength<u8> + Div<Self::Size> + Div<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>>,
   |                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0277]: cannot divide `N` by `UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>`
  --> src/lib.rs:23:8
   |
23 |     fn load<N>(block: &GenericArray<u8, N>) -> GenericArray<Self, Quot<N, Self::Size>>
   |        ^^^^ no implementation for `N / UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>`
   |
help: consider further restricting this bound
   |
25 |         N: ArrayLength<u8> + Div<Self::Size> + Div<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>>,
   |                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 3 previous errors
```
</details>

Replacing `Div<Self::Size>` with `Div<U16>` or even with explicit `Div<Uint<..>>` does not fix the error.