Repository: rust
Issue: this "cannot infer an appropriate lifetime" diagnostic doesn't communicate anything
Labels: A-diagnostics,A-lifetimes,T-compiler,E-needs-mcve,D-confusing,D-verbose

Given the following code: [:crab: playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=08a1749e6882de4441e9dca1e0ac94e2)

```rust
use async_lock::{Semaphore, SemaphoreGuardArc};
use futures_lite::{ready, Stream};
use pin_project_lite::pin_project;
use std::{
    future::Future,
    pin::Pin,
    sync::Arc,
    task::{Context, Poll},
};

pin_project! {
    pub struct SemaphoreLimitedStream<'a, S> {
        #[pin]
        stream: S,
        semaphore: Arc<Semaphore>,
        future: Option<Pin<Box<dyn Future<Output = SemaphoreGuardArc> + Send + 'a>>>
    }
}

impl<S> Stream for SemaphoreLimitedStream<'_, S>
where
    S: Stream,
{
    type Item = (S::Item, SemaphoreGuardArc);

    fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
        let this = self.project();

        let guard = loop {
            if let Some(waiting_for_semaphore) = *this.future {
                break ready!(waiting_for_semaphore.as_mut().poll(cx));
            } else {
                self.future = Some(Box::pin(this.semaphore.acquire_arc()));
            };
        };

        this.stream
            .poll_next(cx)
            .map(|item| item.map(|item| (item, guard)))
    }
}

```

The current output is:

```
   Compiling trillium-server-common v0.1.2 (/Users/jbr/code/trillium/server-common)
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter '__pin in function call due to conflicting requirements
  --> server-common/src/semaphore_limited_stream.rs:27:25
   |
27 |         let this = self.project();
   |                         ^^^^^^^
   |
note: first, the lifetime cannot outlive the anonymous lifetime defined on the method body at 26:28...
  --> server-common/src/semaphore_limited_stream.rs:26:28
   |
26 |     fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
   |                            ^^^^^^^^^
note: ...so that the types are compatible
  --> server-common/src/semaphore_limited_stream.rs:27:25
   |
27 |         let this = self.project();
   |                         ^^^^^^^
   = note: expected `Pin<&mut SemaphoreLimitedStream<'_, S>>`
              found `Pin<&mut SemaphoreLimitedStream<'_, S>>`
note: but, the lifetime must be valid for the lifetime `'_` as defined on the impl at 20:43...
  --> server-common/src/semaphore_limited_stream.rs:20:43
   |
20 | impl<S> Stream for SemaphoreLimitedStream<'_, S>
   |                                           ^^
note: ...so that the expression is assignable
  --> server-common/src/semaphore_limited_stream.rs:33:31
   |
33 |                 self.future = Some(Box::pin(this.semaphore.acquire_arc()));
   |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   = note: expected `Option<Pin<Box<dyn Future<Output = SemaphoreGuardArc> + Send>>>`
              found `Option<Pin<Box<dyn Future<Output = SemaphoreGuardArc> + Send>>>`

For more information about this error, try `rustc --explain E0495`.
error: could not compile `trillium-server-common` due to previous error
```

---

I'm trying to report more of these when I run into them, so here's one! In this case, the error happily makes sense and this was an interim state, but if I were learning rust this would be very confusing because the "expected" and "found" are identical.