Skip to content

Confusing error message on variables created on the fly and passed to an async fn #66440

New issue

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

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

Already on GitHub? # to your account

Closed
nappa85 opened this issue Nov 15, 2019 · 1 comment
Labels
A-async-await Area: Async & Await A-diagnostics Area: Messages for errors, warnings, and lints D-confusing Diagnostics: Confusing error or lint that should be reworked. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nappa85
Copy link

nappa85 commented Nov 15, 2019

Hello,
when passing variables created on the fly to async functions, I get a really confusing error like that:

error[E0277]: `*mut (dyn std::ops::Fn() + 'static)` cannot be shared between threads safely
   --> src/bot/message.rs:100:1
    |
100 | #[async_trait]
    | ^^^^^^^^^^^^^^ `*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, 't16, 't17, 't18, 't19, 't20, 't21, 't22, 't23, 't24, 't25, 't26, 't27, 't28, 't29, 't30, 't31, 't32, 't33, 't34, 't35, 't36, 't37, 't38, 't39, 't40, 't41, 't42, 't43, 't44, 't45, 't46, 't47, 't48, 't49, 't50, 't51, 't52, 't53, 't54> {&'r Self, &'s str, telegram::Image, &'t0 str, for<'_, '_, '_, '_> fn(&str, &str, telegram::Image, std::option::Option<&str>, std::option::Option<&str>, std::option::Option<bool>, std::option::Option<i64>, std::option::Option<serde_json::value::Value>) -> impl std::future::Future {telegram::send_photo}, config::Config, once_cell::sync::Lazy<config::Config>, config::Telegram, std::string::String, &'t1 str, &'t2 std::string::String, &'t3 str, &'t4 str, telegram::Image, fn(&'t5 str) -> std::option::Option<&'t5 str> {std::option::Option::<&'t5 str>::Some}, fn(std::result::Result<std::string::String, ()>) -> std::result::Result<<std::result::Result<std::string::String, ()> as std::ops::Try>::Ok, <std::result::Result<std::string::String, ()> as std::ops::Try>::Error> {<std::result::Result<std::string::String, ()> as std::ops::Try>::into_result}, &'t6 Self, &'t7 Self, std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = std::result::Result<std::string::String, ()>> + std::marker::Send + 't8)>>, std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = std::result::Result<std::string::String, ()>> + std::marker::Send + 't9)>>, (), std::result::Result<std::string::String, ()>, std::result::Result<std::string::String, ()>, std::string::String, &'t10 str, &'t11 std::string::String, std::option::Option<&'t12 str>, std::option::Option<&'t13 str>, std::option::Option<bool>, std::option::Option<i64>, fn(serde_json::value::Value) -> std::option::Option<serde_json::value::Value> {std::option::Option::<serde_json::value::Value>::Some}, fn(std::result::Result<serde_json::value::Value, ()>) -> std::result::Result<<std::result::Result<serde_json::value::Value, ()> as std::ops::Try>::Ok, <std::result::Result<serde_json::value::Value, ()> as std::ops::Try>::Error> {<std::result::Result<serde_json::value::Value, ()> as std::ops::Try>::into_result}, &'t14 Self, &'t15 Self, &'t16 str, &'t17 str, &'t18 str, &'t19 str, std::result::Result<serde_json::value::Value, ()>, std::result::Result<serde_json::value::Value, ()>, serde_json::value::Value, std::option::Option<serde_json::value::Value>, impl std::future::Future, impl std::future::Future, (), std::result::Result<std::string::String, telegram::CallResult>, fn(std::result::Result<mysql_async::conn::Conn, ()>) -> std::result::Result<<std::result::Result<mysql_async::conn::Conn, ()> as std::ops::Try>::Ok, <std::result::Result<mysql_async::conn::Conn, ()> as std::ops::Try>::Error> {<std::result::Result<mysql_async::conn::Conn, ()> as std::ops::Try>::into_result}, &'t28 mysql_async::conn::pool::Pool, once_cell::sync::Lazy<mysql_async::conn::pool::Pool>, mysql_async::conn::pool::futures::get_conn::GetConn, mysql_async::conn::pool::futures::get_conn::GetConn, (), mysql_async::conn::Conn, fn(std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, ()>) -> std::result::Result<<std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, ()> as std::ops::Try>::Ok, <std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, ()> as std::ops::Try>::Error> {<std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, ()> as std::ops::Try>::into_result}, mysql_async::conn::Conn, for<'t55> fn(std::fmt::Arguments<'t55>) -> std::string::String {std::fmt::format}, fn(&'t29 [&'t29 str], &'t29 [std::fmt::ArgumentV1<'t29>]) -> std::fmt::Arguments<'t29> {std::fmt::Arguments::<'t29>::new_v1}, &'t30 str, &'t31 str, [&'t32 str; 1], &'t33 [&'t34 str], &'t35 [&'t36 str; 1], &'t37 str, &'t38 &'t39 str, (&'t40 &'t41 str,), [std::fmt::ArgumentV1<'t42>; 1], &'t43 [std::fmt::ArgumentV1<'t44>], &'t45 [std::fmt::ArgumentV1<'t46>; 1], std::fmt::Arguments<'t47>, std::string::String, std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, mysql_async::error::Error>> + std::marker::Send + 't48)>>, std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, mysql_async::error::Error>> + std::marker::Send + 't49)>>, (), std::string::String, serde_json::value::Value, bool, bool, fn(std::result::Result<mysql_async::conn::Conn, ()>) -> std::result::Result<<std::result::Result<mysql_async::conn::Conn, ()> as std::ops::Try>::Ok, <std::result::Result<mysql_async::conn::Conn, ()> as std::ops::Try>::Error> {<std::result::Result<mysql_async::conn::Conn, ()> as std::ops::Try>::into_result}, &'t50 mysql_async::conn::pool::Pool, once_cell::sync::Lazy<mysql_async::conn::pool::Pool>, mysql_async::conn::pool::futures::get_conn::GetConn, mysql_async::conn::pool::futures::get_conn::GetConn, (), mysql_async::conn::Conn, std::string::String, fn(std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, ()>) -> std::result::Result<<std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, ()> as std::ops::Try>::Ok, <std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, ()> as std::ops::Try>::Error> {<std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, ()> as std::ops::Try>::into_result}, mysql_async::conn::Conn, std::string::String, std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, mysql_async::error::Error>> + std::marker::Send + 't51)>>, std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, mysql_async::error::Error>> + std::marker::Send + 't52)>>, (), fn(std::vec::Vec<std::string::String>) -> impl std::future::Future {bot::BotConfigs::reload}, fn(std::boxed::Box<[std::string::String]>) -> std::vec::Vec<std::string::String> {std::slice::<impl [std::string::String]>::into_vec}, &'t53 str, &'t54 str, std::string::String, [std::string::String; 1], std::boxed::Box<[std::string::String]>, std::boxed::Box<[std::string::String; 1]>, std::vec::Vec<std::string::String>, impl std::future::Future, impl std::future::Future, ()}`
    = note: required because it appears within the type `[static generator@src/bot/message.rs:102:89: 127:6 _self:&Self, chat_id:&str, image:telegram::Image, map_type:&str for<'r, 's, 't0, 't1, 't2, 't3, 't4, 't5, 't6, 't7, 't8, 't9, 't10, 't11, 't12, 't13, 't14, 't15, 't16, 't17, 't18, 't19, 't20, 't21, 't22, 't23, 't24, 't25, 't26, 't27, 't28, 't29, 't30, 't31, 't32, 't33, 't34, 't35, 't36, 't37, 't38, 't39, 't40, 't41, 't42, 't43, 't44, 't45, 't46, 't47, 't48, 't49, 't50, 't51, 't52, 't53, 't54> {&'r Self, &'s str, telegram::Image, &'t0 str, for<'_, '_, '_, '_> fn(&str, &str, telegram::Image, std::option::Option<&str>, std::option::Option<&str>, std::option::Option<bool>, std::option::Option<i64>, std::option::Option<serde_json::value::Value>) -> impl std::future::Future {telegram::send_photo}, config::Config, once_cell::sync::Lazy<config::Config>, config::Telegram, std::string::String, &'t1 str, &'t2 std::string::String, &'t3 str, &'t4 str, telegram::Image, fn(&'t5 str) -> std::option::Option<&'t5 str> {std::option::Option::<&'t5 str>::Some}, fn(std::result::Result<std::string::String, ()>) -> std::result::Result<<std::result::Result<std::string::String, ()> as std::ops::Try>::Ok, <std::result::Result<std::string::String, ()> as std::ops::Try>::Error> {<std::result::Result<std::string::String, ()> as std::ops::Try>::into_result}, &'t6 Self, &'t7 Self, std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = std::result::Result<std::string::String, ()>> + std::marker::Send + 't8)>>, std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = std::result::Result<std::string::String, ()>> + std::marker::Send + 't9)>>, (), std::result::Result<std::string::String, ()>, std::result::Result<std::string::String, ()>, std::string::String, &'t10 str, &'t11 std::string::String, std::option::Option<&'t12 str>, std::option::Option<&'t13 str>, std::option::Option<bool>, std::option::Option<i64>, fn(serde_json::value::Value) -> std::option::Option<serde_json::value::Value> {std::option::Option::<serde_json::value::Value>::Some}, fn(std::result::Result<serde_json::value::Value, ()>) -> std::result::Result<<std::result::Result<serde_json::value::Value, ()> as std::ops::Try>::Ok, <std::result::Result<serde_json::value::Value, ()> as std::ops::Try>::Error> {<std::result::Result<serde_json::value::Value, ()> as std::ops::Try>::into_result}, &'t14 Self, &'t15 Self, &'t16 str, &'t17 str, &'t18 str, &'t19 str, std::result::Result<serde_json::value::Value, ()>, std::result::Result<serde_json::value::Value, ()>, serde_json::value::Value, std::option::Option<serde_json::value::Value>, impl std::future::Future, impl std::future::Future, (), std::result::Result<std::string::String, telegram::CallResult>, fn(std::result::Result<mysql_async::conn::Conn, ()>) -> std::result::Result<<std::result::Result<mysql_async::conn::Conn, ()> as std::ops::Try>::Ok, <std::result::Result<mysql_async::conn::Conn, ()> as std::ops::Try>::Error> {<std::result::Result<mysql_async::conn::Conn, ()> as std::ops::Try>::into_result}, &'t28 mysql_async::conn::pool::Pool, once_cell::sync::Lazy<mysql_async::conn::pool::Pool>, mysql_async::conn::pool::futures::get_conn::GetConn, mysql_async::conn::pool::futures::get_conn::GetConn, (), mysql_async::conn::Conn, fn(std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, ()>) -> std::result::Result<<std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, ()> as std::ops::Try>::Ok, <std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, ()> as std::ops::Try>::Error> {<std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, ()> as std::ops::Try>::into_result}, mysql_async::conn::Conn, for<'t55> fn(std::fmt::Arguments<'t55>) -> std::string::String {std::fmt::format}, fn(&'t29 [&'t29 str], &'t29 [std::fmt::ArgumentV1<'t29>]) -> std::fmt::Arguments<'t29> {std::fmt::Arguments::<'t29>::new_v1}, &'t30 str, &'t31 str, [&'t32 str; 1], &'t33 [&'t34 str], &'t35 [&'t36 str; 1], &'t37 str, &'t38 &'t39 str, (&'t40 &'t41 str,), [std::fmt::ArgumentV1<'t42>; 1], &'t43 [std::fmt::ArgumentV1<'t44>], &'t45 [std::fmt::ArgumentV1<'t46>; 1], std::fmt::Arguments<'t47>, std::string::String, std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, mysql_async::error::Error>> + std::marker::Send + 't48)>>, std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, mysql_async::error::Error>> + std::marker::Send + 't49)>>, (), std::string::String, serde_json::value::Value, bool, bool, fn(std::result::Result<mysql_async::conn::Conn, ()>) -> std::result::Result<<std::result::Result<mysql_async::conn::Conn, ()> as std::ops::Try>::Ok, <std::result::Result<mysql_async::conn::Conn, ()> as std::ops::Try>::Error> {<std::result::Result<mysql_async::conn::Conn, ()> as std::ops::Try>::into_result}, &'t50 mysql_async::conn::pool::Pool, once_cell::sync::Lazy<mysql_async::conn::pool::Pool>, mysql_async::conn::pool::futures::get_conn::GetConn, mysql_async::conn::pool::futures::get_conn::GetConn, (), mysql_async::conn::Conn, std::string::String, fn(std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, ()>) -> std::result::Result<<std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, ()> as std::ops::Try>::Ok, <std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, ()> as std::ops::Try>::Error> {<std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, ()> as std::ops::Try>::into_result}, mysql_async::conn::Conn, std::string::String, std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, mysql_async::error::Error>> + std::marker::Send + 't51)>>, std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, mysql_async::error::Error>> + std::marker::Send + 't52)>>, (), fn(std::vec::Vec<std::string::String>) -> impl std::future::Future {bot::BotConfigs::reload}, fn(std::boxed::Box<[std::string::String]>) -> std::vec::Vec<std::string::String> {std::slice::<impl [std::string::String]>::into_vec}, &'t53 str, &'t54 str, std::string::String, [std::string::String; 1], std::boxed::Box<[std::string::String]>, std::boxed::Box<[std::string::String; 1]>, std::vec::Vec<std::string::String>, impl std::future::Future, impl std::future::Future, ()}]`
    = note: required because it appears within the type `std::future::GenFuture<[static generator@src/bot/message.rs:102:89: 127:6 _self:&Self, chat_id:&str, image:telegram::Image, map_type:&str for<'r, 's, 't0, 't1, 't2, 't3, 't4, 't5, 't6, 't7, 't8, 't9, 't10, 't11, 't12, 't13, 't14, 't15, 't16, 't17, 't18, 't19, 't20, 't21, 't22, 't23, 't24, 't25, 't26, 't27, 't28, 't29, 't30, 't31, 't32, 't33, 't34, 't35, 't36, 't37, 't38, 't39, 't40, 't41, 't42, 't43, 't44, 't45, 't46, 't47, 't48, 't49, 't50, 't51, 't52, 't53, 't54> {&'r Self, &'s str, telegram::Image, &'t0 str, for<'_, '_, '_, '_> fn(&str, &str, telegram::Image, std::option::Option<&str>, std::option::Option<&str>, std::option::Option<bool>, std::option::Option<i64>, std::option::Option<serde_json::value::Value>) -> impl std::future::Future {telegram::send_photo}, config::Config, once_cell::sync::Lazy<config::Config>, config::Telegram, std::string::String, &'t1 str, &'t2 std::string::String, &'t3 str, &'t4 str, telegram::Image, fn(&'t5 str) -> std::option::Option<&'t5 str> {std::option::Option::<&'t5 str>::Some}, fn(std::result::Result<std::string::String, ()>) -> std::result::Result<<std::result::Result<std::string::String, ()> as std::ops::Try>::Ok, <std::result::Result<std::string::String, ()> as std::ops::Try>::Error> {<std::result::Result<std::string::String, ()> as std::ops::Try>::into_result}, &'t6 Self, &'t7 Self, std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = std::result::Result<std::string::String, ()>> + std::marker::Send + 't8)>>, std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = std::result::Result<std::string::String, ()>> + std::marker::Send + 't9)>>, (), std::result::Result<std::string::String, ()>, std::result::Result<std::string::String, ()>, std::string::String, &'t10 str, &'t11 std::string::String, std::option::Option<&'t12 str>, std::option::Option<&'t13 str>, std::option::Option<bool>, std::option::Option<i64>, fn(serde_json::value::Value) -> std::option::Option<serde_json::value::Value> {std::option::Option::<serde_json::value::Value>::Some}, fn(std::result::Result<serde_json::value::Value, ()>) -> std::result::Result<<std::result::Result<serde_json::value::Value, ()> as std::ops::Try>::Ok, <std::result::Result<serde_json::value::Value, ()> as std::ops::Try>::Error> {<std::result::Result<serde_json::value::Value, ()> as std::ops::Try>::into_result}, &'t14 Self, &'t15 Self, &'t16 str, &'t17 str, &'t18 str, &'t19 str, std::result::Result<serde_json::value::Value, ()>, std::result::Result<serde_json::value::Value, ()>, serde_json::value::Value, std::option::Option<serde_json::value::Value>, impl std::future::Future, impl std::future::Future, (), std::result::Result<std::string::String, telegram::CallResult>, fn(std::result::Result<mysql_async::conn::Conn, ()>) -> std::result::Result<<std::result::Result<mysql_async::conn::Conn, ()> as std::ops::Try>::Ok, <std::result::Result<mysql_async::conn::Conn, ()> as std::ops::Try>::Error> {<std::result::Result<mysql_async::conn::Conn, ()> as std::ops::Try>::into_result}, &'t28 mysql_async::conn::pool::Pool, once_cell::sync::Lazy<mysql_async::conn::pool::Pool>, mysql_async::conn::pool::futures::get_conn::GetConn, mysql_async::conn::pool::futures::get_conn::GetConn, (), mysql_async::conn::Conn, fn(std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, ()>) -> std::result::Result<<std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, ()> as std::ops::Try>::Ok, <std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, ()> as std::ops::Try>::Error> {<std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, ()> as std::ops::Try>::into_result}, mysql_async::conn::Conn, for<'t55> fn(std::fmt::Arguments<'t55>) -> std::string::String {std::fmt::format}, fn(&'t29 [&'t29 str], &'t29 [std::fmt::ArgumentV1<'t29>]) -> std::fmt::Arguments<'t29> {std::fmt::Arguments::<'t29>::new_v1}, &'t30 str, &'t31 str, [&'t32 str; 1], &'t33 [&'t34 str], &'t35 [&'t36 str; 1], &'t37 str, &'t38 &'t39 str, (&'t40 &'t41 str,), [std::fmt::ArgumentV1<'t42>; 1], &'t43 [std::fmt::ArgumentV1<'t44>], &'t45 [std::fmt::ArgumentV1<'t46>; 1], std::fmt::Arguments<'t47>, std::string::String, std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, mysql_async::error::Error>> + std::marker::Send + 't48)>>, std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, mysql_async::error::Error>> + std::marker::Send + 't49)>>, (), std::string::String, serde_json::value::Value, bool, bool, fn(std::result::Result<mysql_async::conn::Conn, ()>) -> std::result::Result<<std::result::Result<mysql_async::conn::Conn, ()> as std::ops::Try>::Ok, <std::result::Result<mysql_async::conn::Conn, ()> as std::ops::Try>::Error> {<std::result::Result<mysql_async::conn::Conn, ()> as std::ops::Try>::into_result}, &'t50 mysql_async::conn::pool::Pool, once_cell::sync::Lazy<mysql_async::conn::pool::Pool>, mysql_async::conn::pool::futures::get_conn::GetConn, mysql_async::conn::pool::futures::get_conn::GetConn, (), mysql_async::conn::Conn, std::string::String, fn(std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, ()>) -> std::result::Result<<std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, ()> as std::ops::Try>::Ok, <std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, ()> as std::ops::Try>::Error> {<std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, ()> as std::ops::Try>::into_result}, mysql_async::conn::Conn, std::string::String, std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, mysql_async::error::Error>> + std::marker::Send + 't51)>>, std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = std::result::Result<mysql_async::queryable::query_result::QueryResult<mysql_async::conn::Conn, mysql_async::queryable::TextProtocol>, mysql_async::error::Error>> + std::marker::Send + 't52)>>, (), fn(std::vec::Vec<std::string::String>) -> impl std::future::Future {bot::BotConfigs::reload}, fn(std::boxed::Box<[std::string::String]>) -> std::vec::Vec<std::string::String> {std::slice::<impl [std::string::String]>::into_vec}, &'t53 str, &'t54 str, std::string::String, [std::string::String; 1], std::boxed::Box<[std::string::String]>, std::boxed::Box<[std::string::String; 1]>, std::vec::Vec<std::string::String>, impl std::future::Future, impl std::future::Future, ()}]>`
    = note: required because it appears within the type `impl std::future::Future`
    = note: required because it appears within the type `impl std::future::Future`
    = note: required for the cast to the object type `dyn std::future::Future<Output = std::result::Result<(), ()>> + std::marker::Send`

error: aborting due to previous error

You can replicate this error by compiling my project https://github.com/nappa85/Pokifications/tree/mysql_async, editing file https://github.com/nappa85/Pokifications/blob/mysql_async/src/bot/message.rs on line 106, putting the query String directly on the query method, like that:

conn.query(format!("UPDATE utenti_config_bot SET sent = sent + 1 WHERE user_id = {}", chat_id)).await.map_err(|e| error!("MySQL query error: {}", e))?;

Creating the String and then passing it to the method, it works:

let query = format!("UPDATE utenti_config_bot SET sent = sent + 1 WHERE user_id = {}", chat_id);
conn.query(query).await.map_err(|e| error!("MySQL query error: {}", e))?;

I'm aware that this is a complex case, probably given by the a combination of elements, between the others the async_trait crate.
In facts I haven't been able to replicate the problem on a code snippet, probably because I haven't reached the level of complexity my project has.

I'm available for any clarification or test.

@Centril Centril added E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. D-confusing Diagnostics: Confusing error or lint that should be reworked. A-async-await Area: Async & Await labels Nov 15, 2019
@sfackler
Copy link
Member

Duplicate of #64960.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-async-await Area: Async & Await A-diagnostics Area: Messages for errors, warnings, and lints D-confusing Diagnostics: Confusing error or lint that should be reworked. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants