Repository: rust
Issue: Bad Error Message: error[E0277]: the trait bound `T: Generator<ResumeTy>` is not satisfied
Labels: A-diagnostics,T-compiler,C-bug,A-async-await,AsyncAwait-Triaged

### error message
Hello! This is a bug report for a confusing/bad error message:

```rust
   Compiling bug v0.1.0 (E:\Users\keith\Documents\Projects\bug)
error[E0277]: the trait bound `T: Generator<ResumeTy>` is not satisfied

error[E0308]: mismatched types
  --> src\main.rs:76:25
   |
14 |             .filter_map(|r| async { r.ok() })
   |                                   ----------
   |                                   |
   |                                   the expected generator
   |                                   the found generator
...
76 |     let foobar_runner = tokio::spawn(async move {
   |                         ^^^^^^^^^^^^ one type is more general than the other
   |
   = note: expected opaque type `impl futures::Future`
              found opaque type `impl futures::Future`

error[E0308]: mismatched types
  --> src\main.rs:76:25
   |
15 |             .filter_map(|m| async move { Some(Foo::new(m)) })
   |                                        ---------------------
   |                                        |
   |                                        the expected generator
   |                                        the found generator
...
76 |     let foobar_runner = tokio::spawn(async move {
   |                         ^^^^^^^^^^^^ one type is more general than the other
   |
   = note: expected opaque type `impl futures::Future`
              found opaque type `impl futures::Future`

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `bug`

To learn more, run the command again with --verbose.
```

##  code
I apologize that the following probably isn't the easiest way to trigger it. I am relatively new to Rust and am just now working with Generics and Lifetimes now which is how I got here. The following is a very stripped down version of my code (it compiles without the commented line).

`main.rs`:
```rust
use core::future;
use futures::stream::{self, StreamExt};
use parking_lot::RwLock;
use std::borrow::Cow;
use std::sync::Arc;

struct Bar {}

impl Bar {
    async fn get_foo<'a>(&self) -> Vec<Foo<'a>> {
        let results: Vec<Result<String, ()>> =
            vec![Ok("shoutout to `impl Fox for Salix` for this vector".to_string()); 10];
        let foo: Vec<Foo<'a>> = stream::iter(results)
            .filter_map(|r| async { r.ok() })
            .filter_map(|m| async move { Some(Foo::new(m)) })
            .filter(|m| future::ready(test_foo(m.as_str()))) // Code compiles without this line
            .collect()
            .await;
        foo
    }

    async fn new() -> Arc<Self> {
        Arc::new(Self {})
    }
}

struct Foo<'a> {
    raw: Cow<'a, str>,
}

impl<'a> Foo<'a> {
    fn as_str(&self) -> &str {
        &self.raw
    }

    fn new<T>(raw: T) -> Foo<'a>
    where
        T: Into<Cow<'a, str>>,
    {
        Foo { raw: raw.into() }
    }
}

struct FooBar<'a> {
    bar: Arc<Bar>,
    foo: RwLock<Vec<Foo<'a>>>,
}

impl<'a> FooBar<'a> {
    async fn get_foo(&self) -> Vec<Foo<'a>> {
        let foo: Vec<Foo<'a>> = self.bar.get_foo().await;
        foo
    }

    async fn new(bar: Arc<Bar>) -> Arc<FooBar<'a>> {
        let foobar = FooBar {
            bar: bar.clone(),
            foo: RwLock::new(Vec::new()),
        };
        Arc::new(foobar)
    }

    async fn run(&self) {
        let new_foo: Vec<Foo<'a>> = self.get_foo().await;
        {
            let mut foo = self.foo.write();
            *foo = new_foo;
        }
    }
}

#[tokio::main]
async fn main() {
    let bar = Bar::new().await;
    let foobar = FooBar::new(bar).await;
    let foobar_runner = tokio::spawn(async move {
        foobar.run().await;
    })
    .await;
}

fn test_foo(foo: &str) -> bool {
    println!("{}", foo);
    true
}
```

### Meta
`rustc --version --verbose`:
```
PS E:\Users\keith\Documents\Projects\bug> rustc --version --verbose
rustc 1.48.0 (7eac88abb 2020-11-16)
binary: rustc
commit-hash: 7eac88abb2e57e752f3302f02be5f3ce3d7adfb4
commit-date: 2020-11-16
host: x86_64-pc-windows-msvc
release: 1.48.0
LLVM version: 11.0
```

`Cargo.toml`:
```toml
[package]
name = "bug"
version = "0.1.0"
authors = ["keith miller"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
futures           = "0.3.8"
parking_lot       = "0.11.1"
tokio = { version = "0.2.22", features = ["macros", "rt-threaded", "time"] }
```

This is my first bug report for a project of this size. Please let me know if you need me to modify anything. Thank you!