Repository: rust
Issue: Compiler fails to identify type mismatch on function that returns impl Trait
Labels: C-enhancement,A-diagnostics,T-compiler,A-impl-trait,D-confusing

the following function, added to  [tower-grpc](https://github.com/tower-rs/tower-grpc/) hello world client [example,](https://github.com/tower-rs/tower-grpc/blob/master/tower-grpc-examples/src/helloworld/client.rs) to wrap the service connection setup, when used, the compiler fails to identify the type mismatch, `()` in the return type should be `BoxBody` 
```rust
pub fn get_service() -> impl Future<
    Item = hello_world::client::Greeter<
        RequestModifier<Connection<TcpStream, DefaultExecutor, BoxBody>, ()>,
    >,
    Error = ConnectError<std::io::Error>,
> {
    let uri: http::Uri = format!("http://localhost:50051")
        .parse()
        .expect("could not parse grpc address as uri");
    let h2_settings = Default::default();
    let mut make_client = Connect::new(Dst, h2_settings, DefaultExecutor::current());

    make_client.make_service(()).map(|conn| {
        let conn = tower_request_modifier::Builder::new()
            .set_origin(uri)
            .build(conn)
            .unwrap();

        hello_world::client::Greeter::new(conn)
    })
}

```

and gives the following error:
```
error[E0599]: no method named `say_hello` found for type `hello_world::client::Greeter<tower_request_modifier::RequestModifier<tower_h2::client::connection::Connection<tokio_tcp::stream::TcpStream, tokio_executor::global::DefaultExecutor, tower_grpc::body::BoxBody>, ()>>` in the current scope
  --> src/main.rs:22:18
   |
22 |                 .say_hello(Request::new(HelloRequest {
   |                  ^^^^^^^^^
   |
  ::: /Volumes/data/dev/jxs/tower-error-example/target/debug/build/tower-error-example-5d3017ffe78d8a92/out/helloworld.rs:19:5
   |
19 |     pub struct Greeter<T> {
   |     --------------------- method `say_hello` not found for this
   |
   = help: items from traits can only be used if the trait is implemented and in scope
   = note: the following trait defines an item `say_hello`, perhaps you need to implement it:
           candidate #1: `hello_world::server::Greeter`

```

but if the following code is added just before the function return: 
```rust
        let hello = hello_world::client::Greeter::new(conn).say_hello(Request::new(HelloRequest {
            name: "What is in a name?".to_string(),
        }));
```
the error given by the compiler becomes a lot more useful:
```
error[E0271]: type mismatch resolving `<[closure@src/main.rs:67:38: 78:6 uri:_] as std::ops::FnOnce<(tower_h2::client::connection::Connection<tokio_tcp::stream::TcpStream, tokio_executor::global::DefaultExecutor, tower_grpc::body::BoxBody>,)>>::Output == hello_world::client::Greeter<tower_request_modifier::RequestModifier<tower_h2::client::connection::Connection<tokio_tcp::stream::TcpStream, tokio_executor::global::DefaultExecutor, tower_grpc::body::BoxBody>, ()>>`
  --> src/main.rs:55:25
   |
55 |   pub fn get_service() -> impl Future<
   |  _________________________^
56 | |     Item = hello_world::client::Greeter<
57 | |         RequestModifier<Connection<TcpStream, DefaultExecutor, BoxBody>, ()>,
58 | |     >,
59 | |     Error = ConnectError<std::io::Error>,
60 | | > {
   | |_^ expected struct `tower_grpc::body::BoxBody`, found ()
```

pushed the whole example [here](https://github.com/jxs/tower-error-example/blob/master/src/main.rs)

thanks