From 6c898a239fd5e0000ec8120ef29a0444f3680f2e Mon Sep 17 00:00:00 2001 From: Ben Sully Date: Sun, 28 Mar 2021 18:31:20 +0100 Subject: [PATCH] Use fully qualified path for futures_core::Stream in codegen (#591) --- Cargo.toml | 3 ++- tests/stream_conflict/Cargo.toml | 15 +++++++++++++++ tests/stream_conflict/build.rs | 3 +++ tests/stream_conflict/proto/stream_conflict.proto | 10 ++++++++++ tests/stream_conflict/src/main.rs | 7 +++++++ tonic-build/src/server.rs | 4 ++-- tonic/src/codegen.rs | 2 +- 7 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 tests/stream_conflict/Cargo.toml create mode 100644 tests/stream_conflict/build.rs create mode 100644 tests/stream_conflict/proto/stream_conflict.proto create mode 100644 tests/stream_conflict/src/main.rs diff --git a/Cargo.toml b/Cargo.toml index 433ba9bd9..4d6f9c408 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,6 +18,7 @@ members = [ "tests/extern_path/uuid", "tests/ambiguous_methods", "tests/extern_path/my_application", - "tests/integration_tests" + "tests/integration_tests", + "tests/stream_conflict", ] diff --git a/tests/stream_conflict/Cargo.toml b/tests/stream_conflict/Cargo.toml new file mode 100644 index 000000000..b1c39c5a4 --- /dev/null +++ b/tests/stream_conflict/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "stream_conflict" +version = "0.1.0" +authors = ["Ben Sully "] +publish = false +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +tonic = { path = "../../tonic" } +prost = "0.7" + +[build-dependencies] +tonic-build = { path = "../../tonic-build" } diff --git a/tests/stream_conflict/build.rs b/tests/stream_conflict/build.rs new file mode 100644 index 000000000..c284edada --- /dev/null +++ b/tests/stream_conflict/build.rs @@ -0,0 +1,3 @@ +fn main() { + tonic_build::compile_protos("proto/stream_conflict.proto").unwrap(); +} diff --git a/tests/stream_conflict/proto/stream_conflict.proto b/tests/stream_conflict/proto/stream_conflict.proto new file mode 100644 index 000000000..a9be8746a --- /dev/null +++ b/tests/stream_conflict/proto/stream_conflict.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; +package StreamConflict; + +message Message { + bool ok = 1; +} + +service Stream { + rpc RunStream(Message) returns (stream Message); +} diff --git a/tests/stream_conflict/src/main.rs b/tests/stream_conflict/src/main.rs new file mode 100644 index 000000000..ab96cfdee --- /dev/null +++ b/tests/stream_conflict/src/main.rs @@ -0,0 +1,7 @@ +mod stream_conflict { + tonic::include_proto!("stream_conflict"); +} + +fn main() { + println!("Hello, world!"); +} diff --git a/tonic-build/src/server.rs b/tonic-build/src/server.rs index e0b491528..8cb4866cc 100644 --- a/tonic-build/src/server.rs +++ b/tonic-build/src/server.rs @@ -182,7 +182,7 @@ fn generate_trait_methods( quote! { #stream_doc - type #stream: Stream> + Send + Sync + 'static; + type #stream: futures_core::Stream> + Send + Sync + 'static; #method_doc async fn #name(&self, request: tonic::Request<#req_message>) @@ -198,7 +198,7 @@ fn generate_trait_methods( quote! { #stream_doc - type #stream: Stream> + Send + Sync + 'static; + type #stream: futures_core::Stream> + Send + Sync + 'static; #method_doc async fn #name(&self, request: tonic::Request>) diff --git a/tonic/src/codegen.rs b/tonic/src/codegen.rs index 4f0509ad0..cb146929c 100644 --- a/tonic/src/codegen.rs +++ b/tonic/src/codegen.rs @@ -1,7 +1,7 @@ //! Codegen exports used by `tonic-build`. pub use async_trait::async_trait; -pub use futures_core::Stream; +pub use futures_core; pub use futures_util::future::{ok, poll_fn, Ready}; pub use http_body::Body as HttpBody;