Repository: rust
Issue: Generic const expressions bug: expected constant Self::SIZE found constant Self::SIZE 
Labels: C-bug,requires-nightly,F-generic_const_exprs,requires-incomplete-features

<!--
Thank you for filing a bug report! 🐛 Please provide a short summary of the bug,
along with any information you feel relevant to replicating the bug.
-->

I tried this code:
```rust
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]

pub trait AsBytes: Sized
where
    [u8; size_of::<Self>()]: Sized,
{
    fn to_bytes(self) -> [u8; size_of::<Self>()];

    fn from_bytes(arr: [u8; size_of::<Self>()]) -> Self;
}

impl<A: AsBytes> AsBytes for (A,)
where
    [(); size_of::<Self>()]: Sized,
    [(); size_of::<A>()]: Sized,
{
    fn to_bytes(self) -> [u8; size_of::<Self>()] {
        self.0.to_bytes()
    }

    fn from_bytes(arr: [u8; size_of::<Self>()]) -> Self {
        (A::from_bytes(arr),)
    }
}
```

And I expected it to work just fine, since the compiler should know that `A` and `(A,)` have the same size. 
But I got this error:
```
error[E0308]: mismatched types
  --> src/lib.rs:18:9
   |
18 |         self.0.to_bytes()
   |         ^^^^^^^^^^^^^^^^^ expected `size_of::<Self>()`, found `size_of::<Self>()`
   |
   = note: expected constant `size_of::<Self>()`
              found constant `size_of::<Self>()`

error[E0308]: mismatched types
  --> src/lib.rs:22:24
   |
22 |         (A::from_bytes(arr),)
   |                        ^^^ expected `size_of::<Self>()`, found `size_of::<Self>()`
   |
   = note: expected constant `size_of::<Self>()`
              found constant `size_of::<Self>()`
```

This made me think, maybe the compiler needs an additional explicit guarantee that `size_of::<A>()` and `size_of::<(A,)>()` are the same. _After all those `where [u8; size_of::<T>()]: Sized` I'm not sure in anything anymore._ So I tried to add a little bit more certainty for the compiler by modifying the code like this: 

```rust
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]

pub trait SuperSized: Sized {
    const SIZE: usize;

    fn super_size() -> usize {
        Self::SIZE
    }
}

impl<A: SuperSized> SuperSized for (A,) {
    const SIZE: usize = A::SIZE;   // <--------- I expected this line to do the trick
}

pub trait AsBytes: SuperSized
where
    [u8; Self::SIZE]: Sized,
{
    fn to_bytes(self) -> [u8; Self::SIZE];

    fn from_bytes(arr: [u8; Self::SIZE]) -> Self;
}

impl<A: AsBytes> AsBytes for (A,)
where
    [(); Self::SIZE]: Sized,
    [(); A::SIZE]: Sized,
{
    fn to_bytes(self) -> [u8; Self::SIZE] {
        self.0.to_bytes()
    }

    fn from_bytes(arr: [u8; Self::SIZE]) -> Self {
        (A::from_bytes(arr),)
    }
}
```

But the compiler threw out a very similar error:
```
error[[E0308]](https://doc.rust-lang.org/nightly/error-index.html#E0308): mismatched types
  --> src/lib.rs:32:9
   |
32 |         self.0.to_bytes()
   |         ^^^^^^^^^^^^^^^^^ expected `Self::SIZE`, found `Self::SIZE`
   |
   = note: expected constant `Self::SIZE`
              found constant `Self::SIZE`

error[[E0308]](https://doc.rust-lang.org/nightly/error-index.html#E0308): mismatched types
  --> src/lib.rs:36:24
   |
36 |         (A::from_bytes(arr),)
   |                        ^^^ expected `Self::SIZE`, found `Self::SIZE`
   |
   = note: expected constant `Self::SIZE`
              found constant `Self::SIZE`
```

Here is a [link to playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=a8cd70e86710f47f427e35e251a072f3).

I understand that generic consts are in a very early stage and the team probably familiar with this issue, but anyway.
Is there a safe generic workaround?

### Meta
<!--
If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions.
-->

`rustc --version --verbose`:
```
rustc 1.66.0-nightly (57f097ea2 2022-10-01)
binary: rustc
commit-hash: 57f097ea25f2c05f424fc9b9dc50dbd6d399845c
commit-date: 2022-10-01
host: x86_64-unknown-linux-gnu
release: 1.66.0-nightly
LLVM version: 15.0.2
```