Repository: rust
Issue: False positive cycle detection with `generic_const_exprs`
Labels: C-bug,requires-nightly,F-generic_const_exprs,requires-incomplete-features,I-cycle

<!--
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
#![feature(generic_const_exprs)]

use core::marker::PhantomData;

trait Cool{
    const SIZE: usize;
    // Function does not have to have default to cause error, but non-overrided default does not error
    fn test(array: [u8; Self::SIZE]){}
    fn okay(){}
}

struct WithWhere<T>(PhantomData<T>);
// Causes error
impl<T> Cool for WithWhere<T> where T: Cool, [(); T::SIZE]:{
    const SIZE: usize = T::SIZE + 1;
    fn test(array: [u8; Self::SIZE]){}
}

struct NonDependantSize<T>(PhantomData<T>);
// Causes error
impl<T> Cool for NonDependantSize<T> where T: Cool, [(); T::SIZE]:{
    const SIZE: usize = 2;
    fn test(array: [u8; Self::SIZE]){}
}

struct WithNonDependantWhere;
// Causes error
impl Cool for WithNonDependantWhere where [(); Self::SIZE]:{
    const SIZE: usize = 2;
    fn test(array: [u8; Self::SIZE]){}
}

struct NoWhere<T>(PhantomData<T>);
// No Error
impl<T> Cool for NoWhere<T> where T: Cool{
    const SIZE: usize = T::SIZE + 1;
    fn test(array: [u8; Self::SIZE]){}
} 

struct NoFunctionOverride<T>(PhantomData<T>);
// No Error
impl<T> Cool for NoFunctionOverride<T> where T: Cool, [(); T::SIZE]:{
    const SIZE: usize = 3;
    fn okay(){}
} 
```
[Playground Link](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=292873be78119de9537d605722dd912f)

I expected to see this happen: There to be no cycle error added with the extra where item.

Instead, this happened: A cycle error was emitted when adding a where clause bound that is not dependent
### 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.60.0-nightly (ec4bcaac4 2022-01-15)
binary: rustc
commit-hash: ec4bcaac450279b029f3480b8b8f1b82ab36a5eb
commit-date: 2022-01-15
host: x86_64-unknown-linux-gnu
release: 1.60.0-nightly
LLVM version: 13.0.0
```

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
<details><summary>Backtrace</summary>
<p>

```
warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
 --> src/lib.rs:1:12
  |
1 | #![feature(generic_const_exprs)]
  |            ^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(incomplete_features)]` on by default
  = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information

error[E0391]: cycle detected when building an abstract representation for <impl at src/lib.rs:14:1: 17:2>::test::{constant#0}
  --> src/lib.rs:16:25
   |
16 |     fn test(array: [u8; Self::SIZE]){}
   |                         ^^^^^^^^^^
   |
note: ...which requires building THIR for `<impl at src/lib.rs:14:1: 17:2>::test::{constant#0}`...
  --> src/lib.rs:16:25
   |
16 |     fn test(array: [u8; Self::SIZE]){}
   |                         ^^^^^^^^^^
note: ...which requires type-checking `<impl at src/lib.rs:14:1: 17:2>::test::{constant#0}`...
  --> src/lib.rs:16:25
   |
16 |     fn test(array: [u8; Self::SIZE]){}
   |                         ^^^^^^^^^^
   = note: ...which requires evaluating trait selection obligation `WithWhere<T>: Cool`...
   = note: ...which again requires building an abstract representation for <impl at src/lib.rs:14:1: 17:2>::test::{constant#0}, completing the cycle
note: cycle used when checking that `<impl at src/lib.rs:14:1: 17:2>::test` is well-formed
  --> src/lib.rs:16:5
   |
16 |     fn test(array: [u8; Self::SIZE]){}
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0391]: cycle detected when building an abstract representation for <impl at src/lib.rs:21:1: 24:2>::test::{constant#0}
  --> src/lib.rs:23:25
   |
23 |     fn test(array: [u8; Self::SIZE]){}
   |                         ^^^^^^^^^^
   |
note: ...which requires building THIR for `<impl at src/lib.rs:21:1: 24:2>::test::{constant#0}`...
  --> src/lib.rs:23:25
   |
23 |     fn test(array: [u8; Self::SIZE]){}
   |                         ^^^^^^^^^^
note: ...which requires type-checking `<impl at src/lib.rs:21:1: 24:2>::test::{constant#0}`...
  --> src/lib.rs:23:25
   |
23 |     fn test(array: [u8; Self::SIZE]){}
   |                         ^^^^^^^^^^
   = note: ...which requires evaluating trait selection obligation `NonDependantSize<T>: Cool`...
   = note: ...which again requires building an abstract representation for <impl at src/lib.rs:21:1: 24:2>::test::{constant#0}, completing the cycle
note: cycle used when checking that `<impl at src/lib.rs:21:1: 24:2>::test` is well-formed
  --> src/lib.rs:23:5
   |
23 |     fn test(array: [u8; Self::SIZE]){}
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0391]: cycle detected when building an abstract representation for <impl at src/lib.rs:28:1: 31:2>::{constant#0}
  --> src/lib.rs:28:48
   |
28 | impl Cool for WithNonDependantWhere where [(); Self::SIZE]:{
   |                                                ^^^^^^^^^^
   |
note: ...which requires building THIR for `<impl at src/lib.rs:28:1: 31:2>::{constant#0}`...
  --> src/lib.rs:28:48
   |
28 | impl Cool for WithNonDependantWhere where [(); Self::SIZE]:{
   |                                                ^^^^^^^^^^
note: ...which requires type-checking `<impl at src/lib.rs:28:1: 31:2>::{constant#0}`...
  --> src/lib.rs:28:48
   |
28 | impl Cool for WithNonDependantWhere where [(); Self::SIZE]:{
   |                                                ^^^^^^^^^^
   = note: ...which requires evaluating trait selection obligation `WithNonDependantWhere: Cool`...
   = note: ...which again requires building an abstract representation for <impl at src/lib.rs:28:1: 31:2>::{constant#0}, completing the cycle
note: cycle used when checking that `<impl at src/lib.rs:28:1: 31:2>` is well-formed
  --> src/lib.rs:28:1
   |
28 | impl Cool for WithNonDependantWhere where [(); Self::SIZE]:{
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0391`.
warning: `playground` (lib) generated 1 warning
error: could not compile `playground` due to 3 previous errors; 1 warning emitted
```

</p>
</details>