Repository: rust
Issue: `impl` blocks of recursive types causes lifetime coercion errors to be incorrect
Labels: A-diagnostics,T-compiler

<!--
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.

If you cannot produce a minimal reproduction case (something that would work in
isolation), please provide the steps or even link to a repository that causes
the problematic output to occur.
-->

Given the following code: <!-- Please provide a link to play.rust-lang.org --> <https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=e2b94b7c2f548a0bcd9cc3f63263644a>

```rust
pub struct CowFoo<'outer> {
    pub outer: Option<Cow<'outer, CowFoo<'outer>>>,
}

impl<'outer> Clone for CowFoo<'outer> {
    fn clone(&self) -> Self {
        todo!()
    }
}

// commenting out this `impl` block shows the correct error
impl<'me> CowFoo<'me> {
    pub fn new<'outer: 'me>(other: Option<&'outer CowFoo<'outer>>) -> Self {
        let other: Option<&'me CowFoo<'me>> = other;
        Self {
            outer: other.map(Cow::Borrowed)
        }
    }
}
```

The current output is:

```
error: lifetime may not live long enough
  --> src/lib.rs:28:20
   |
26 | impl<'me> CowFoo<'me> {
   |      --- lifetime `'me` defined here
27 |     pub fn new<'outer: 'me>(other: Option<&'outer CowFoo<'outer>>) -> Self {
   |                ------ lifetime `'outer` defined here
28 |         let other: Option<&'me CowFoo<'me>> = other;
   |                    ^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'me` must outlive `'outer`
   |
   = help: consider adding the following bound: `'me: 'outer`
   = note: requirement occurs because of the type `CowFoo<'_>`, which makes the generic argument `'_` invariant
   = note: the struct `CowFoo<'outer>` is invariant over the parameter `'outer`
   = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
```

<!-- The following is not always necessary. -->
Ideally the output should look like:

```
error[[E0391]](https://doc.rust-lang.org/stable/error-index.html#E0391): cycle detected when computing layout of `CowFoo`
   |
   = note: ...which requires computing layout of `core::option::Option<alloc::borrow::Cow<CowFoo>>`...
   = note: ...which requires computing layout of `alloc::borrow::Cow<CowFoo>`...
   = note: ...which requires computing layout of `<CowFoo as alloc::borrow::ToOwned>::Owned`...
   = note: ...which again requires computing layout of `CowFoo`, completing the cycle
note: cycle used when elaborating drops for `<impl at src/lib.rs:19:1: 23:2>::clone`
  --> src/lib.rs:20:5
   |
20 |     fn clone(&self) -> Self {
   |     ^^^^^^^^^^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0391`.
```

<!--
If the problem is not self-explanatory, please provide a rationale for the
change.
-->

In the playground link, I include a compiling version of the above code, but instead of `Cow` I use a reference to the recursive type. Indeed, the same exact lifetime coercion is used in the compiling example, indicating that the lifetime coercion is valid. However, the inclusion of `Cow` in the field `outer`'s type triggers the lifetime coercion error, which is wrong - the lifetime coercion *is* valid, but the recursive type isn't.

<!--
If dramatically different output is caused by small changes, consider also
adding them here.

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. The output might also be
different depending on the Edition.
-->