Skip to content

Commit

Permalink
Use fully qualified path for futures_core::Stream in codegen (#591)
Browse files Browse the repository at this point in the history
  • Loading branch information
sd2k authored Mar 28, 2021
1 parent 2788628 commit 6c898a2
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]

15 changes: 15 additions & 0 deletions tests/stream_conflict/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "stream_conflict"
version = "0.1.0"
authors = ["Ben Sully <ben@bsull.io>"]
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" }
3 changes: 3 additions & 0 deletions tests/stream_conflict/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
tonic_build::compile_protos("proto/stream_conflict.proto").unwrap();
}
10 changes: 10 additions & 0 deletions tests/stream_conflict/proto/stream_conflict.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
syntax = "proto3";
package StreamConflict;

message Message {
bool ok = 1;
}

service Stream {
rpc RunStream(Message) returns (stream Message);
}
7 changes: 7 additions & 0 deletions tests/stream_conflict/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mod stream_conflict {
tonic::include_proto!("stream_conflict");
}

fn main() {
println!("Hello, world!");
}
4 changes: 2 additions & 2 deletions tonic-build/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ fn generate_trait_methods<T: Service>(

quote! {
#stream_doc
type #stream: Stream<Item = Result<#res_message, tonic::Status>> + Send + Sync + 'static;
type #stream: futures_core::Stream<Item = Result<#res_message, tonic::Status>> + Send + Sync + 'static;

#method_doc
async fn #name(&self, request: tonic::Request<#req_message>)
Expand All @@ -198,7 +198,7 @@ fn generate_trait_methods<T: Service>(

quote! {
#stream_doc
type #stream: Stream<Item = Result<#res_message, tonic::Status>> + Send + Sync + 'static;
type #stream: futures_core::Stream<Item = Result<#res_message, tonic::Status>> + Send + Sync + 'static;

#method_doc
async fn #name(&self, request: tonic::Request<tonic::Streaming<#req_message>>)
Expand Down
2 changes: 1 addition & 1 deletion tonic/src/codegen.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 6c898a2

Please sign in to comment.