-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
the following function, added to tower-grpc hello world client example, to wrap the service connection setup, when used, the compiler fails to identify the type mismatch, () in the return type should be BoxBody
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:
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
thanks
brunoczim and gugahoa
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.