Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interesting error using format!() with reqwest 0.10 alpha and warp 0.2 alpha #319

Closed
nocduro opened this issue Nov 20, 2019 · 2 comments
Closed

Comments

@nocduro
Copy link

nocduro commented Nov 20, 2019

Hi, thought I'd report a weird error message I had trouble tracking down today, maybe it will help someone else with the same problem. Feel free to close this issue, as it may not be directly related to warp. It's also my first time using async/await so it might be a misunderstanding on my end.

TL;DR don't use &format!() to construct URLs for reqwest's .get(), post(), etc. functions. Make a temp variable let x = format!(); and then borrow it in those function calls.

The error occurs when making a request with reqwest from within a handler in warp and using format! in the get()/post() etc. function. Kinda hard to explain, but here is an example:

> rustc --version
rustc 1.39.0 (4560ea788 2019-11-04)

Cargo.toml dependencies:

[dependencies]
futures-util = "0.3"
reqwest = "0.10.0-alpha.2"
tokio = "0.2.0-alpha.6"
warp = { git = "https://github.com/seanmonstar/warp" }

Code that compiles and works normally:

use futures_util::future::TryFutureExt;
use warp::Filter;

#[derive(Debug)]
enum MyError {
    Http(reqwest::Error),
}

impl warp::reject::Reject for MyError {}
impl From<reqwest::Error> for MyError {
    fn from(err: reqwest::Error) -> Self {
        MyError::Http(err)
    }
}

#[tokio::main]
async fn main() {
    let http_client = reqwest::Client::new();
    let http_client = warp::any().map(move || http_client.clone());

    let call_route = warp::path::path("call")
        .and(http_client.clone())
        .and_then(call_wrapper);

    warp::serve(call_route).run(([127, 0, 0, 1], 9000)).await;
}

/// Wrap the actual function so we only have to call reject::custom once
async fn call_wrapper(http: reqwest::Client) -> Result<impl warp::Reply, warp::Rejection> {
    call_site(http).map_err(warp::reject::custom).await
}

async fn call_site(http: reqwest::Client) -> Result<String, MyError> {
    let url = format!("https://rust-lang.org/{}", 100);
    let resp = http
        .get(&url)
        .send()
        .await?
        .text()
        .await?;

    Ok(format!("Got a response with length: {}", resp.len()))
}

But if we change the call_site function to remove the url variable and move the format!() inline we get a hard to understand error.
edit: The error gets a bit worse when there are more routes, but this gives the picture.

Function that gives error:

async fn call_site(http: reqwest::Client) -> Result<String, MyError> {
    let resp = http
        .get(&format!("https://rust-lang.org/{}", 100)) // <-------
        .send()
        .await?
        .text()
        .await?;

    Ok(format!("Got a response with length: {}", resp.len()))
}

Error:

error[E0277]: `*mut (dyn std::ops::Fn() + 'static)` cannot be shared between threads safely
  --> src\main.rs:25:10
   |
25 |         .and_then(call_wrapper);
   |          ^^^^^^^^ `*mut (dyn std::ops::Fn() + 'static)` cannot be shared between threads safely
   |
   = help: within `core::fmt::Void`, the trait `std::marker::Sync` is not implemented for `*mut (dyn std::ops::Fn() + 'static)`
   = note: required because it appears within the type `std::marker::PhantomData<*mut (dyn std::ops::Fn() + 'static)>`
   = note: required because it appears within the type `core::fmt::Void`
   = note: required because of the requirements on the impl of `std::marker::Send` for `&core::fmt::Void`
   = note: required because it appears within the type `std::fmt::ArgumentV1<'_>`
   = note: required because it appears within the type `[std::fmt::ArgumentV1<'_>; 1]`
   = note: required because it appears within the type `for<'r, 's, 't0, 't1, 't2, 't3, 't4, 't5, 't6, 't7, 't8, 't9, 't10, 't11, 't12, 't13, 't14, 't15> {reqwest::async_impl::client::Client, fn(std::result::Result<std::string::String, reqwest::error::Error>) -> std::result::Result<<std::result::Result<std::string::String, reqwest::error::Error> as std::ops::Try>::Ok, <std::result::Result<std::string::String, reqwest::error::Error> as std::ops::Try>::Error> {<std::result::Result<std::string::String, reqwest::error::Error> as std::ops::Try>::into_result}, fn(std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error>) -> std::result::Result<<std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error> as std::ops::Try>::Ok, <std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error> as std::ops::Try>::Error> {<std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error> as std::ops::Try>::into_result}, &'r reqwest::async_impl::client::Client, reqwest::async_impl::client::Client, for<'t16> fn(std::fmt::Arguments<'t16>) -> std::string::String {std::fmt::format}, fn(&'s [&'s str], &'s [std::fmt::ArgumentV1<'s>]) -> std::fmt::Arguments<'s> {std::fmt::Arguments::<'s>::new_v1}, &'t0 str, &'t1 str, [&'t2 str; 1], &'t3 [&'t4 str], &'t5 [&'t6 str; 1], i32, &'t7 i32, (&'t8 i32,), [std::fmt::ArgumentV1<'t9>; 1], &'t10 [std::fmt::ArgumentV1<'t11>], &'t12 [std::fmt::ArgumentV1<'t13>; 1], std::fmt::Arguments<'t14>, std::string::String, &'t15 std::string::String, reqwest::async_impl::request::RequestBuilder, impl core::future::future::Future, impl core::future::future::Future, (), std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error>, std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error>, reqwest::async_impl::response::Response, impl core::future::future::Future, impl core::future::future::Future, ()}`
   = note: required because it appears within the type `[static generator@src\main.rs:35:70: 44:2 http:reqwest::async_impl::client::Client for<'r, 's, 't0, 't1, 't2, 't3, 't4, 't5, 't6, 't7, 't8, 't9, 
't10, 't11, 't12, 't13, 't14, 't15> {reqwest::async_impl::client::Client, fn(std::result::Result<std::string::String, reqwest::error::Error>) -> std::result::Result<<std::result::Result<std::string::String, reqwest::error::Error> as std::ops::Try>::Ok, <std::result::Result<std::string::String, reqwest::error::Error> as std::ops::Try>::Error> {<std::result::Result<std::string::String, reqwest::error::Error> as std::ops::Try>::into_result}, fn(std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error>) -> std::result::Result<<std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error> as std::ops::Try>::Ok, <std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error> as std::ops::Try>::Error> {<std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error> as std::ops::Try>::into_result}, &'r reqwest::async_impl::client::Client, reqwest::async_impl::client::Client, for<'t16> fn(std::fmt::Arguments<'t16>) -> std::string::String {std::fmt::format}, fn(&'s [&'s str], &'s [std::fmt::ArgumentV1<'s>]) -> std::fmt::Arguments<'s> {std::fmt::Arguments::<'s>::new_v1}, &'t0 str, &'t1 str, [&'t2 str; 1], &'t3 [&'t4 str], &'t5 [&'t6 str; 1], i32, &'t7 i32, (&'t8 i32,), [std::fmt::ArgumentV1<'t9>; 1], &'t10 [std::fmt::ArgumentV1<'t11>], &'t12 [std::fmt::ArgumentV1<'t13>; 1], std::fmt::Arguments<'t14>, std::string::String, &'t15 std::string::String, reqwest::async_impl::request::RequestBuilder, impl core::future::future::Future, impl core::future::future::Future, (), std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error>, std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error>, reqwest::async_impl::response::Response, impl core::future::future::Future, impl core::future::future::Future, ()}]`
   = note: required because it appears within the type `std::future::GenFuture<[static generator@src\main.rs:35:70: 44:2 http:reqwest::async_impl::client::Client for<'r, 's, 't0, 't1, 't2, 't3, 't4, 't5, 't6, 't7, 't8, 't9, 't10, 't11, 't12, 't13, 't14, 't15> {reqwest::async_impl::client::Client, fn(std::result::Result<std::string::String, reqwest::error::Error>) -> std::result::Result<<std::result::Result<std::string::String, reqwest::error::Error> as std::ops::Try>::Ok, <std::result::Result<std::string::String, reqwest::error::Error> as std::ops::Try>::Error> {<std::result::Result<std::string::String, reqwest::error::Error> as std::ops::Try>::into_result}, fn(std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error>) -> std::result::Result<<std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error> as std::ops::Try>::Ok, <std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error> as std::ops::Try>::Error> {<std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error> as std::ops::Try>::into_result}, &'r reqwest::async_impl::client::Client, reqwest::async_impl::client::Client, for<'t16> fn(std::fmt::Arguments<'t16>) -> std::string::String {std::fmt::format}, fn(&'s [&'s str], &'s [std::fmt::ArgumentV1<'s>]) -> std::fmt::Arguments<'s> {std::fmt::Arguments::<'s>::new_v1}, &'t0 str, &'t1 str, [&'t2 str; 1], &'t3 [&'t4 str], &'t5 [&'t6 str; 1], i32, &'t7 i32, (&'t8 i32,), [std::fmt::ArgumentV1<'t9>; 1], &'t10 [std::fmt::ArgumentV1<'t11>], &'t12 [std::fmt::ArgumentV1<'t13>; 1], std::fmt::Arguments<'t14>, std::string::String, &'t15 std::string::String, reqwest::async_impl::request::RequestBuilder, impl core::future::future::Future, impl core::future::future::Future, (), std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error>, std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error>, reqwest::async_impl::response::Response, impl core::future::future::Future, impl core::future::future::Future, ()}]>`
   = note: required because it appears within the type `impl core::future::future::Future`
   = note: required because it appears within the type `impl core::future::future::Future`
   = note: required because it appears within the type `{reqwest::async_impl::client::Client, fn(reqwest::async_impl::client::Client) -> impl core::future::future::Future {call_site}, reqwest::async_impl::client::Client, impl core::future::future::Future, fn(MyError) -> warp::reject::Rejection {warp::reject::custom::<MyError>}, futures_util::future::try_future::map_err::MapErr<impl core::future::future::Future, fn(MyError) -> warp::reject::Rejection {warp::reject::custom::<MyError>}>, futures_util::future::try_future::map_err::MapErr<impl core::future::future::Future, fn(MyError) -> warp::reject::Rejection {warp::reject::custom::<MyError>}>, ()}`
   = note: required because it appears within the type `[static generator@src\main.rs:31:91: 33:2 http:reqwest::async_impl::client::Client {reqwest::async_impl::client::Client, fn(reqwest::async_impl::client::Client) -> impl core::future::future::Future {call_site}, reqwest::async_impl::client::Client, impl core::future::future::Future, fn(MyError) -> warp::reject::Rejection {warp::reject::custom::<MyError>}, futures_util::future::try_future::map_err::MapErr<impl core::future::future::Future, fn(MyError) -> warp::reject::Rejection {warp::reject::custom::<MyError>}>, futures_util::future::try_future::map_err::MapErr<impl core::future::future::Future, fn(MyError) -> warp::reject::Rejection {warp::reject::custom::<MyError>}>, ()}]`
   = note: required because it appears within the type `std::future::GenFuture<[static generator@src\main.rs:31:91: 33:2 http:reqwest::async_impl::client::Client {reqwest::async_impl::client::Client, fn(reqwest::async_impl::client::Client) -> impl core::future::future::Future {call_site}, reqwest::async_impl::client::Client, impl core::future::future::Future, fn(MyError) -> warp::reject::Rejection {warp::reject::custom::<MyError>}, futures_util::future::try_future::map_err::MapErr<impl core::future::future::Future, fn(MyError) -> warp::reject::Rejection {warp::reject::custom::<MyError>}>, futures_util::future::try_future::map_err::MapErr<impl core::future::future::Future, fn(MyError) -> warp::reject::Rejection {warp::reject::custom::<MyError>}>, ()}]>`
   = note: required because it appears within the type `impl core::future::future::Future`
   = note: required because it appears within the type `impl core::future::future::Future`

error[E0277]: `*mut (dyn std::ops::Fn() + 'static)` cannot be shared between threads safely
  --> src\main.rs:27:5
   |
27 |     warp::serve(call_route).run(([127, 0, 0, 1], 9000)).await;
   |     ^^^^^^^^^^^ `*mut (dyn std::ops::Fn() + 'static)` cannot be shared between threads safely
   | 
  ::: C:\Users\Mackenzie\.cargo\git\checkouts\warp-4a034a455cef9a29\9bb5810\src\server.rs:26:8
   |
26 |     S: IntoWarpService + 'static,
   |        --------------- required by this bound in `warp::server::serve`
   |
   = help: within `core::fmt::Void`, the trait `std::marker::Sync` is not implemented for `*mut (dyn std::ops::Fn() + 'static)`
   = note: required because it appears within the type `std::marker::PhantomData<*mut (dyn std::ops::Fn() + 'static)>`
   = note: required because it appears within the type `core::fmt::Void`
   = note: required because of the requirements on the impl of `std::marker::Send` for `&core::fmt::Void`
   = note: required because it appears within the type `std::fmt::ArgumentV1<'_>`
   = note: required because it appears within the type `[std::fmt::ArgumentV1<'_>; 1]`
   = note: required because it appears within the type `for<'r, 's, 't0, 't1, 't2, 't3, 't4, 't5, 't6, 't7, 't8, 't9, 't10, 't11, 't12, 't13, 't14, 't15> {reqwest::async_impl::client::Client, fn(std::result::Result<std::string::String, reqwest::error::Error>) -> std::result::Result<<std::result::Result<std::string::String, reqwest::error::Error> as std::ops::Try>::Ok, <std::result::Result<std::string::String, reqwest::error::Error> as std::ops::Try>::Error> {<std::result::Result<std::string::String, reqwest::error::Error> as std::ops::Try>::into_result}, fn(std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error>) -> std::result::Result<<std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error> as std::ops::Try>::Ok, <std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error> as std::ops::Try>::Error> {<std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error> as std::ops::Try>::into_result}, &'r reqwest::async_impl::client::Client, reqwest::async_impl::client::Client, for<'t16> fn(std::fmt::Arguments<'t16>) -> std::string::String {std::fmt::format}, fn(&'s [&'s str], &'s [std::fmt::ArgumentV1<'s>]) -> std::fmt::Arguments<'s> {std::fmt::Arguments::<'s>::new_v1}, &'t0 str, &'t1 str, [&'t2 str; 1], &'t3 [&'t4 str], &'t5 [&'t6 str; 1], i32, &'t7 i32, (&'t8 i32,), [std::fmt::ArgumentV1<'t9>; 1], &'t10 [std::fmt::ArgumentV1<'t11>], &'t12 [std::fmt::ArgumentV1<'t13>; 1], std::fmt::Arguments<'t14>, std::string::String, &'t15 std::string::String, reqwest::async_impl::request::RequestBuilder, impl core::future::future::Future, impl core::future::future::Future, (), std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error>, std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error>, reqwest::async_impl::response::Response, impl core::future::future::Future, impl core::future::future::Future, ()}`
   = note: required because it appears within the type `[static generator@src\main.rs:35:70: 44:2 http:reqwest::async_impl::client::Client for<'r, 's, 't0, 't1, 't2, 't3, 't4, 't5, 't6, 't7, 't8, 't9, 
't10, 't11, 't12, 't13, 't14, 't15> {reqwest::async_impl::client::Client, fn(std::result::Result<std::string::String, reqwest::error::Error>) -> std::result::Result<<std::result::Result<std::string::String, reqwest::error::Error> as std::ops::Try>::Ok, <std::result::Result<std::string::String, reqwest::error::Error> as std::ops::Try>::Error> {<std::result::Result<std::string::String, reqwest::error::Error> as std::ops::Try>::into_result}, fn(std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error>) -> std::result::Result<<std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error> as std::ops::Try>::Ok, <std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error> as std::ops::Try>::Error> {<std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error> as std::ops::Try>::into_result}, &'r reqwest::async_impl::client::Client, reqwest::async_impl::client::Client, for<'t16> fn(std::fmt::Arguments<'t16>) -> std::string::String {std::fmt::format}, fn(&'s [&'s str], &'s [std::fmt::ArgumentV1<'s>]) -> std::fmt::Arguments<'s> {std::fmt::Arguments::<'s>::new_v1}, &'t0 str, &'t1 str, [&'t2 str; 1], &'t3 [&'t4 str], &'t5 [&'t6 str; 1], i32, &'t7 i32, (&'t8 i32,), [std::fmt::ArgumentV1<'t9>; 1], &'t10 [std::fmt::ArgumentV1<'t11>], &'t12 [std::fmt::ArgumentV1<'t13>; 1], std::fmt::Arguments<'t14>, std::string::String, &'t15 std::string::String, reqwest::async_impl::request::RequestBuilder, impl core::future::future::Future, impl core::future::future::Future, (), std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error>, std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error>, reqwest::async_impl::response::Response, impl core::future::future::Future, impl core::future::future::Future, ()}]`
   = note: required because it appears within the type `std::future::GenFuture<[static generator@src\main.rs:35:70: 44:2 http:reqwest::async_impl::client::Client for<'r, 's, 't0, 't1, 't2, 't3, 't4, 't5, 't6, 't7, 't8, 't9, 't10, 't11, 't12, 't13, 't14, 't15> {reqwest::async_impl::client::Client, fn(std::result::Result<std::string::String, reqwest::error::Error>) -> std::result::Result<<std::result::Result<std::string::String, reqwest::error::Error> as std::ops::Try>::Ok, <std::result::Result<std::string::String, reqwest::error::Error> as std::ops::Try>::Error> {<std::result::Result<std::string::String, reqwest::error::Error> as std::ops::Try>::into_result}, fn(std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error>) -> std::result::Result<<std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error> as std::ops::Try>::Ok, <std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error> as std::ops::Try>::Error> {<std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error> as std::ops::Try>::into_result}, &'r reqwest::async_impl::client::Client, reqwest::async_impl::client::Client, for<'t16> fn(std::fmt::Arguments<'t16>) -> std::string::String {std::fmt::format}, fn(&'s [&'s str], &'s [std::fmt::ArgumentV1<'s>]) -> std::fmt::Arguments<'s> {std::fmt::Arguments::<'s>::new_v1}, &'t0 str, &'t1 str, [&'t2 str; 1], &'t3 [&'t4 str], &'t5 [&'t6 str; 1], i32, &'t7 i32, (&'t8 i32,), [std::fmt::ArgumentV1<'t9>; 1], &'t10 [std::fmt::ArgumentV1<'t11>], &'t12 [std::fmt::ArgumentV1<'t13>; 1], std::fmt::Arguments<'t14>, std::string::String, &'t15 std::string::String, reqwest::async_impl::request::RequestBuilder, impl core::future::future::Future, impl core::future::future::Future, (), std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error>, std::result::Result<reqwest::async_impl::response::Response, reqwest::error::Error>, reqwest::async_impl::response::Response, impl core::future::future::Future, impl core::future::future::Future, ()}]>`
   = note: required because it appears within the type `impl core::future::future::Future`
   = note: required because it appears within the type `impl core::future::future::Future`
   = note: required because it appears within the type `{reqwest::async_impl::client::Client, fn(reqwest::async_impl::client::Client) -> impl core::future::future::Future {call_site}, reqwest::async_impl::client::Client, impl core::future::future::Future, fn(MyError) -> warp::reject::Rejection {warp::reject::custom::<MyError>}, futures_util::future::try_future::map_err::MapErr<impl core::future::future::Future, fn(MyError) -> warp::reject::Rejection {warp::reject::custom::<MyError>}>, futures_util::future::try_future::map_err::MapErr<impl core::future::future::Future, fn(MyError) -> warp::reject::Rejection {warp::reject::custom::<MyError>}>, ()}`
   = note: required because it appears within the type `[static generator@src\main.rs:31:91: 33:2 http:reqwest::async_impl::client::Client {reqwest::async_impl::client::Client, fn(reqwest::async_impl::client::Client) -> impl core::future::future::Future {call_site}, reqwest::async_impl::client::Client, impl core::future::future::Future, fn(MyError) -> warp::reject::Rejection {warp::reject::custom::<MyError>}, futures_util::future::try_future::map_err::MapErr<impl core::future::future::Future, fn(MyError) -> warp::reject::Rejection {warp::reject::custom::<MyError>}>, futures_util::future::try_future::map_err::MapErr<impl core::future::future::Future, fn(MyError) -> warp::reject::Rejection {warp::reject::custom::<MyError>}>, ()}]`
   = note: required because it appears within the type `std::future::GenFuture<[static generator@src\main.rs:31:91: 33:2 http:reqwest::async_impl::client::Client {reqwest::async_impl::client::Client, fn(reqwest::async_impl::client::Client) -> impl core::future::future::Future {call_site}, reqwest::async_impl::client::Client, impl core::future::future::Future, fn(MyError) -> warp::reject::Rejection {warp::reject::custom::<MyError>}, futures_util::future::try_future::map_err::MapErr<impl core::future::future::Future, fn(MyError) -> warp::reject::Rejection {warp::reject::custom::<MyError>}>, futures_util::future::try_future::map_err::MapErr<impl core::future::future::Future, fn(MyError) -> warp::reject::Rejection {warp::reject::custom::<MyError>}>, ()}]>`
   = note: required because it appears within the type `impl core::future::future::Future`
   = note: required because it appears within the type `impl core::future::future::Future`
   = note: required because of the requirements on the impl of `warp::filter::FilterBase` for `warp::filter::and_then::AndThen<warp::filter::and::And<impl warp::filter::Filter+std::marker::Copy, warp::filter::map::Map<impl warp::filter::Filter+std::marker::Copy, [closure@src\main.rs:21:39: 21:66 http_client:_]>>, fn(reqwest::async_impl::client::Client) -> impl core::future::future::Future {call_wrapper}>`
   = note: required because of the requirements on the impl of `warp::server::IntoWarpService` for `warp::filter::and_then::AndThen<warp::filter::and::And<impl warp::filter::Filter+std::marker::Copy, warp::filter::map::Map<impl warp::filter::Filter+std::marker::Copy, [closure@src\main.rs:21:39: 21:66 http_client:_]>>, fn(reqwest::async_impl::client::Client) -> impl core::future::future::Future {call_wrapper}>`

error[E0599]: no method named `run` found for type `warp::server::Server<warp::filter::and_then::AndThen<warp::filter::and::And<impl warp::filter::Filter+std::marker::Copy, warp::filter::map::Map<impl 
warp::filter::Filter+std::marker::Copy, [closure@src\main.rs:21:39: 21:66 http_client:_]>>, fn(reqwest::async_impl::client::Client) -> impl core::future::future::Future {call_wrapper}>>` in the current scope
  --> src\main.rs:27:29
   |
27 |     warp::serve(call_route).run(([127, 0, 0, 1], 9000)).await;
   |                             ^^^ method not found in `warp::server::Server<warp::filter::and_then::AndThen<warp::filter::and::And<impl warp::filter::Filter+std::marker::Copy, warp::filter::map::Map<impl warp::filter::Filter+std::marker::Copy, [closure@src\main.rs:21:39: 21:66 http_client:_]>>, fn(reqwest::async_impl::client::Client) -> impl core::future::future::Future {call_wrapper}>>`
   |
   = note: the method `run` exists but the following trait bounds were not satisfied:
           `impl core::future::future::Future : std::marker::Send`
           `warp::filter::and_then::AndThen<warp::filter::and::And<impl warp::filter::Filter+std::marker::Copy, warp::filter::map::Map<impl warp::filter::Filter+std::marker::Copy, [closure@src\main.rs:21:39: 21:66 http_client:_]>>, fn(reqwest::async_impl::client::Client) -> impl core::future::future::Future {call_wrapper}> : warp::filter::FilterBase`
           `warp::filter::and_then::AndThen<warp::filter::and::And<impl warp::filter::Filter+std::marker::Copy, warp::filter::map::Map<impl warp::filter::Filter+std::marker::Copy, [closure@src\main.rs:21:39: 21:66 http_client:_]>>, fn(reqwest::async_impl::client::Client) -> impl core::future::future::Future {call_wrapper}> : warp::filter::Filter`
           `warp::filter::and_then::AndThen<warp::filter::and::And<impl warp::filter::Filter+std::marker::Copy, warp::filter::map::Map<impl warp::filter::Filter+std::marker::Copy, [closure@src\main.rs:21:39: 21:66 http_client:_]>>, fn(reqwest::async_impl::client::Client) -> impl core::future::future::Future {call_wrapper}> : warp::server::IntoWarpService`
           `warp::filter::and_then::AndThenFuture<warp::filter::and::And<impl warp::filter::Filter+std::marker::Copy, warp::filter::map::Map<impl warp::filter::Filter+std::marker::Copy, [closure@src\main.rs:21:39: 21:66 http_client:_]>>, fn(reqwest::async_impl::client::Client) -> impl core::future::future::Future {call_wrapper}> : core::future::future::Future`
           `warp::filter::service::FilteredFuture<warp::filter::and_then::AndThenFuture<warp::filter::and::And<impl warp::filter::Filter+std::marker::Copy, warp::filter::map::Map<impl warp::filter::Filter+std::marker::Copy, [closure@src\main.rs:21:39: 21:66 http_client:_]>>, fn(reqwest::async_impl::client::Client) -> impl core::future::future::Future {call_wrapper}>> : core::future::future::Future` 
           `warp::filter::service::FilteredFuture<warp::filter::and_then::AndThenFuture<warp::filter::and::And<impl warp::filter::Filter+std::marker::Copy, warp::filter::map::Map<impl warp::filter::Filter+std::marker::Copy, [closure@src\main.rs:21:39: 21:66 http_client:_]>>, fn(reqwest::async_impl::client::Client) -> impl core::future::future::Future {call_wrapper}>> : futures_core::future::TryFuture`
           `warp::filter::service::FilteredService<warp::filter::and_then::AndThen<warp::filter::and::And<impl warp::filter::Filter+std::marker::Copy, warp::filter::map::Map<impl warp::filter::Filter+std::marker::Copy, [closure@src\main.rs:21:39: 21:66 http_client:_]>>, fn(reqwest::async_impl::client::Client) -> impl core::future::future::Future {call_wrapper}>> : warp::server::WarpService`

error[E0698]: type inside `async` object must be known in this context
  --> src\main.rs:27:35
   |
27 |     warp::serve(call_route).run(([127, 0, 0, 1], 9000)).await;
   |                                   ^^^ cannot infer type for `{integer}`
   |
note: the type is part of the `async` object because of this `await`
  --> src\main.rs:27:5
   |
27 |     warp::serve(call_route).run(([127, 0, 0, 1], 9000)).await;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0698]: type inside `async` object must be known in this context
  --> src\main.rs:27:40
   |
27 |     warp::serve(call_route).run(([127, 0, 0, 1], 9000)).await;
   |                                        ^ cannot infer type for `{integer}`
   |
note: the type is part of the `async` object because of this `await`
  --> src\main.rs:27:5
   |
27 |     warp::serve(call_route).run(([127, 0, 0, 1], 9000)).await;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0698]: type inside `async` object must be known in this context
  --> src\main.rs:27:43
   |
27 |     warp::serve(call_route).run(([127, 0, 0, 1], 9000)).await;
   |                                           ^ cannot infer type for `{integer}`
   |
note: the type is part of the `async` object because of this `await`
  --> src\main.rs:27:5
   |
27 |     warp::serve(call_route).run(([127, 0, 0, 1], 9000)).await;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0698]: type inside `async` object must be known in this context
  --> src\main.rs:27:46
   |
27 |     warp::serve(call_route).run(([127, 0, 0, 1], 9000)).await;
   |                                              ^ cannot infer type for `{integer}`
   |
note: the type is part of the `async` object because of this `await`
  --> src\main.rs:27:5
   |
27 |     warp::serve(call_route).run(([127, 0, 0, 1], 9000)).await;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0698]: type inside `async` object must be known in this context
  --> src\main.rs:27:34
   |
27 |     warp::serve(call_route).run(([127, 0, 0, 1], 9000)).await;
   |                                  ^^^^^^^^^^^^^^ cannot infer type for `{integer}`
   |
note: the type is part of the `async` object because of this `await`
  --> src\main.rs:27:5
   |
27 |     warp::serve(call_route).run(([127, 0, 0, 1], 9000)).await;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0698]: type inside `async` object must be known in this context
  --> src\main.rs:27:50
   |
27 |     warp::serve(call_route).run(([127, 0, 0, 1], 9000)).await;
   |                                                  ^^^^ cannot infer type for `{integer}`
   |
note: the type is part of the `async` object because of this `await`
  --> src\main.rs:27:5
   |
27 |     warp::serve(call_route).run(([127, 0, 0, 1], 9000)).await;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0698]: type inside `async` object must be known in this context
  --> src\main.rs:27:33
   |
27 |     warp::serve(call_route).run(([127, 0, 0, 1], 9000)).await;
   |                                 ^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for `{integer}`
   |
note: the type is part of the `async` object because of this `await`
  --> src\main.rs:27:5
   |
27 |     warp::serve(call_route).run(([127, 0, 0, 1], 9000)).await;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 10 previous errors

Some errors have detailed explanations: E0277, E0599, E0698.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `warp-async`.

To learn more, run the command again with --verbose.
@KamilaBorowska
Copy link
Contributor

KamilaBorowska commented Nov 22, 2019

This is essentially rust-lang/rust#64960, a compiler bug, rather than warp bug.

@nocduro
Copy link
Author

nocduro commented Nov 22, 2019

Thanks for the link! Yeah, I thought this was out of warp's domain since the compiler gave a cryptic error, I was just hesitant to blame something on the compiler haha

@nocduro nocduro closed this as completed Nov 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants