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

Reduce type errors in async fns #67025

Open
birkenfeld opened this issue Dec 4, 2019 · 7 comments · May be fixed by #67116
Open

Reduce type errors in async fns #67025

birkenfeld opened this issue Dec 4, 2019 · 7 comments · May be fixed by #67116

Comments

@birkenfeld
Copy link
Contributor

@birkenfeld birkenfeld commented Dec 4, 2019

I will admit that this specific async fn is a bit long, but I'd like the compiler to tell me in a different way. (Actual reason is addition of one line borrowing the wrong type across an .await boundary, of course)

Like this, we're coming out ahead of C++ 😄

    = help: the trait `std::marker::Sync` is not implemented for `dyn jobs::Job`
    = note: required because of the requirements on the impl of `std::marker::Send` for `&dyn jobs::Job`
    = 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, 't55, 't56, 't57, 't58, 't59, 't60, 't61, 't62, 't63, 
't64, 't65, 't66, 't67, 't68, 't69, 't70, 't71, 't72, 't73, 't74, 't75, 't76, 't77, 
't78, 't79, 't80, 't81, 't82, 't83, 't84, 't85, 't86, 't87, 't88, 't89, 't90, 't91, 
't92, 't93, 't94, 't95, 't96, 't97, 't98, 't99, 't100, 't101, 't102, 't103, 't104, 
't105, 't106, 't107, 't108, 't109, 't110, 't111, 't112, 't113, 't114, 't115, 't116, 
't117, 't118, 't119, 't120, 't121, 't122, 't123, 't124, 't125, 't126, 't127, 't128, 
't129, 't130, 't131, 't132, 't133, 't134, 't135, 't136, 't137, 't138, 't139, 't140, 
't141, 't142, 't143, 't144, 't145, 't146, 't147, 't148, 't149, 't150, 't151, 't152, 
't153, 't154, 't155, 't156, 't157, 't158, 't159, 't160, 't161, 't162, 't163, 't164, 
't165, 't166, 't167, 't168, 't169, 't170, 't171, 't172, 't173, 't174, 't175, 't176, 
't177, 't178, 't179, 't180, 't181, 't182, 't183, 't184, 't185, 't186, 't187, 't188, 
't189, 't190, 't191, 't192, 't193, 't194, 't195, 't196, 't197, 't198, 't199, 't200, 
't201, 't202, 't203, 't204, 't205, 't206, 't207, 't208, 't209, 't210, 't211, 't212, 
't213, 't214, 't215, 't216, 't217, 't218, 't219, 't220, 't221, 't222, 't223, 't224, 
't225, 't226, 't227, 't228, 't229, 't230, 't231, 't232, 't233, 't234, 't235, 't236, 
't237, 't238, 't239, 't240, 't241, 't242, 't243, 't244, 't245, 't246, 't247, 't248> 
{handler::Handler, handler::Handler, handler::Handler, &'r mut 
tokio_sync::mpsc::bounded::Receiver<handler::Action>, 
tokio_sync::mpsc::bounded::Receiver<handler::Action>, 
futures_util::stream::next::Next<'s, 
tokio_sync::mpsc::bounded::Receiver<handler::Action>>, 
futures_util::stream::next::Next<'t0, 
tokio_sync::mpsc::bounded::Receiver<handler::Action>>, (), 
std::option::Option<handler::Action>, handler::Action, handler::Action, 
handler::Request, auth::ClientInfo, tokio_sync::oneshot::Sender<handler::Response>, 
handler::Request, std::collections::HashMap<std::string::String, handler::ServiceInfo>, 
handler::Handler, &'t1 std::collections::HashMap<std::string::String, (jobs::Service, 
usize)>, std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::collections::hash_map::Values<'t2, std::string::String, (jobs::Service, usize)>, 
std::collections::hash_map::Values<'t3, std::string::String, (jobs::Service, usize)>, 
std::collections::hash_map::Values<'t4, std::string::String, (jobs::Service, usize)>, 
&'t5 (jobs::Service, usize), &'t6 jobs::Service, &'t7 usize, handler::Handler, &'t8 
std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't9)>>, 
std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't10)>>, std::boxed::Box<(dyn jobs::Job + 
't11)>, (dyn jobs::Job + 't12), &'t13 (dyn jobs::Job + 't14), bool, bool, &'t15 mut 
handler::ServiceInfo, &'t16 mut (dyn jobs::Job + 't17), &'t18 (dyn jobs::Job + 't19), 
&'t20 jobs::Service, &'t21 jobs::Service, std::pin::Pin<std::boxed::Box<(dyn 
core::future::future::Future<Output = jobs::ExtStatus> + std::marker::Send + 't22)>>, 
std::pin::Pin<std::boxed::Box<(dyn core::future::future::Future<Output = 
jobs::ExtStatus> + std::marker::Send + 't23)>>, (), std::string::String, 
handler::Handler, &'t24 std::collections::HashMap<std::string::String, (jobs::Service, 
usize)>, std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::string::String, &'t25 std::string::String, &'t26 std::string::String, 
std::option::Option<&'t27 (jobs::Service, usize)>, &'t28 jobs::Service, &'t29 usize, 
handler::Handler, &'t30 mut std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't31)>>, 
std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't32)>>, std::boxed::Box<(dyn jobs::Job + 
't33)>, (dyn jobs::Job + 't34), &'t35 mut (dyn jobs::Job + 't36), &'t37 mut (dyn 
jobs::Job + 't38), &'t39 mut (dyn jobs::Job + 't40), &'t41 jobs::Service, &'t42 
jobs::Service, auth::ClientInfo, impl core::future::future::Future, impl 
core::future::future::Future, impl core::future::future::Future, (), 
std::string::String, handler::Handler, &'t49 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::string::String, &'t50 std::string::String, &'t51 std::string::String, 
std::option::Option<&'t52 (jobs::Service, usize)>, &'t53 jobs::Service, &'t54 usize, 
handler::Handler, &'t55 mut std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't56)>>, 
std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't57)>>, std::boxed::Box<(dyn jobs::Job + 
't58)>, (dyn jobs::Job + 't59), &'t60 mut (dyn jobs::Job + 't61), &'t62 mut (dyn 
jobs::Job + 't63), &'t64 mut (dyn jobs::Job + 't65), &'t66 jobs::Service, &'t67 
jobs::Service, auth::ClientInfo, impl core::future::future::Future, impl 
core::future::future::Future, impl core::future::future::Future, (), 
std::string::String, handler::Handler, &'t74 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::string::String, &'t75 std::string::String, &'t76 std::string::String, 
std::option::Option<&'t77 (jobs::Service, usize)>, &'t78 jobs::Service, &'t79 usize, 
handler::Handler, &'t80 mut std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't81)>>, 
std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't82)>>, std::boxed::Box<(dyn jobs::Job + 
't83)>, (dyn jobs::Job + 't84), &'t85 mut (dyn jobs::Job + 't86), &'t87 mut (dyn 
jobs::Job + 't88), &'t89 mut (dyn jobs::Job + 't90), &'t91 jobs::Service, &'t92 
jobs::Service, auth::ClientInfo, impl core::future::future::Future, impl 
core::future::future::Future, impl core::future::future::Future, (), 
std::string::String, handler::Handler, &'t99 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::string::String, &'t100 std::string::String, &'t101 std::string::String, 
std::option::Option<&'t102 (jobs::Service, usize)>, &'t103 jobs::Service, &'t104 usize, 
handler::Handler, &'t105 mut std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't106)>>, 
std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't107)>>, std::boxed::Box<(dyn jobs::Job 
+ 't108)>, (dyn jobs::Job + 't109), &'t110 mut (dyn jobs::Job + 't111), &'t112 mut (dyn 
jobs::Job + 't113), &'t114 mut (dyn jobs::Job + 't115), &'t116 jobs::Service, &'t117 
jobs::Service, auth::ClientInfo, impl core::future::future::Future, impl 
core::future::future::Future, impl core::future::future::Future, (), 
std::string::String, handler::Handler, &'t124 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::string::String, &'t125 std::string::String, &'t126 std::string::String, 
std::option::Option<&'t127 (jobs::Service, usize)>, &'t128 jobs::Service, &'t129 usize, 
handler::Handler, &'t130 mut std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't131)>>, 
std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't132)>>, std::boxed::Box<(dyn jobs::Job 
+ 't133)>, (dyn jobs::Job + 't134), &'t135 mut (dyn jobs::Job + 't136), &'t137 mut (dyn 
jobs::Job + 't138), &'t139 mut (dyn jobs::Job + 't140), &'t141 jobs::Service, &'t142 
jobs::Service, auth::ClientInfo, impl core::future::future::Future, impl 
core::future::future::Future, impl core::future::future::Future, (), 
std::string::String, std::string::String, std::string::String, handler::Handler, &'t149 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::string::String, &'t150 std::string::String, &'t151 std::string::String, 
std::option::Option<&'t152 (jobs::Service, usize)>, &'t153 jobs::Service, &'t154 usize, 
handler::Handler, &'t155 mut std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't156)>>, 
std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't157)>>, std::boxed::Box<(dyn jobs::Job 
+ 't158)>, (dyn jobs::Job + 't159), &'t160 mut (dyn jobs::Job + 't161), &'t162 mut (dyn 
jobs::Job + 't163), &'t164 mut (dyn jobs::Job + 't165), &'t166 jobs::Service, &'t167 
jobs::Service, auth::ClientInfo, std::string::String, std::string::String, impl 
core::future::future::Future, impl core::future::future::Future, impl 
core::future::future::Future, (), std::string::String, handler::Handler, &'t174 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::string::String, &'t175 std::string::String, &'t176 std::string::String, 
std::option::Option<&'t177 (jobs::Service, usize)>, &'t178 jobs::Service, &'t179 usize, 
handler::Handler, &'t180 mut std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't181)>>, 
std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't182)>>, std::boxed::Box<(dyn jobs::Job 
+ 't183)>, (dyn jobs::Job + 't184), &'t185 mut (dyn jobs::Job + 't186), &'t187 mut (dyn 
jobs::Job + 't188), &'t189 mut (dyn jobs::Job + 't190), &'t191 jobs::Service, &'t192 
jobs::Service, auth::ClientInfo, impl core::future::future::Future, impl 
core::future::future::Future, impl core::future::future::Future, (), 
std::string::String, handler::Handler, &'t199 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::string::String, &'t200 std::string::String, &'t201 std::string::String, 
std::option::Option<&'t202 (jobs::Service, usize)>, &'t203 jobs::Service, &'t204 usize, 
handler::Handler, &'t205 mut std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't206)>>, 
std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't207)>>, std::boxed::Box<(dyn jobs::Job 
+ 't208)>, (dyn jobs::Job + 't209), &'t210 mut (dyn jobs::Job + 't211), &'t212 mut (dyn 
jobs::Job + 't213), &'t214 mut (dyn jobs::Job + 't215), &'t216 jobs::Service, &'t217 
jobs::Service, auth::ClientInfo, impl core::future::future::Future, impl 
core::future::future::Future, impl core::future::future::Future, (), 
std::string::String, handler::Handler, &'t224 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::string::String, &'t225 std::string::String, &'t226 std::string::String, 
std::option::Option<&'t227 (jobs::Service, usize)>, &'t228 jobs::Service, &'t229 usize, 
handler::Handler, &'t230 mut std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't231)>>, 
std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't232)>>, std::boxed::Box<(dyn jobs::Job 
+ 't233)>, (dyn jobs::Job + 't234), &'t235 mut (dyn jobs::Job + 't236), &'t237 mut (dyn 
jobs::Job + 't238), &'t239 mut (dyn jobs::Job + 't240), &'t241 jobs::Service, &'t242 
jobs::Service, auth::ClientInfo, impl core::future::future::Future, impl 
core::future::future::Future, impl core::future::future::Future, ()}`
    = note: required because it appears within the type `[static 
generator@src/handler.rs:137:32: 198:6 __arg0:handler::Handler 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, 't55, 't56, 't57, 't58, 't59, 
't60, 't61, 't62, 't63, 't64, 't65, 't66, 't67, 't68, 't69, 't70, 't71, 't72, 't73, 
't74, 't75, 't76, 't77, 't78, 't79, 't80, 't81, 't82, 't83, 't84, 't85, 't86, 't87, 
't88, 't89, 't90, 't91, 't92, 't93, 't94, 't95, 't96, 't97, 't98, 't99, 't100, 't101, 
't102, 't103, 't104, 't105, 't106, 't107, 't108, 't109, 't110, 't111, 't112, 't113, 
't114, 't115, 't116, 't117, 't118, 't119, 't120, 't121, 't122, 't123, 't124, 't125, 
't126, 't127, 't128, 't129, 't130, 't131, 't132, 't133, 't134, 't135, 't136, 't137, 
't138, 't139, 't140, 't141, 't142, 't143, 't144, 't145, 't146, 't147, 't148, 't149, 
't150, 't151, 't152, 't153, 't154, 't155, 't156, 't157, 't158, 't159, 't160, 't161, 
't162, 't163, 't164, 't165, 't166, 't167, 't168, 't169, 't170, 't171, 't172, 't173, 
't174, 't175, 't176, 't177, 't178, 't179, 't180, 't181, 't182, 't183, 't184, 't185, 
't186, 't187, 't188, 't189, 't190, 't191, 't192, 't193, 't194, 't195, 't196, 't197, 
't198, 't199, 't200, 't201, 't202, 't203, 't204, 't205, 't206, 't207, 't208, 't209, 
't210, 't211, 't212, 't213, 't214, 't215, 't216, 't217, 't218, 't219, 't220, 't221, 
't222, 't223, 't224, 't225, 't226, 't227, 't228, 't229, 't230, 't231, 't232, 't233, 
't234, 't235, 't236, 't237, 't238, 't239, 't240, 't241, 't242, 't243, 't244, 't245, 
't246, 't247, 't248> {handler::Handler, handler::Handler, handler::Handler, &'r mut 
tokio_sync::mpsc::bounded::Receiver<handler::Action>, 
tokio_sync::mpsc::bounded::Receiver<handler::Action>, 
futures_util::stream::next::Next<'s, 
tokio_sync::mpsc::bounded::Receiver<handler::Action>>, 
futures_util::stream::next::Next<'t0, 
tokio_sync::mpsc::bounded::Receiver<handler::Action>>, (), 
std::option::Option<handler::Action>, handler::Action, handler::Action, 
handler::Request, auth::ClientInfo, tokio_sync::oneshot::Sender<handler::Response>, 
handler::Request, std::collections::HashMap<std::string::String, handler::ServiceInfo>, 
handler::Handler, &'t1 std::collections::HashMap<std::string::String, (jobs::Service, 
usize)>, std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::collections::hash_map::Values<'t2, std::string::String, (jobs::Service, usize)>, 
std::collections::hash_map::Values<'t3, std::string::String, (jobs::Service, usize)>, 
std::collections::hash_map::Values<'t4, std::string::String, (jobs::Service, usize)>, 
&'t5 (jobs::Service, usize), &'t6 jobs::Service, &'t7 usize, handler::Handler, &'t8 
std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't9)>>, 
std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't10)>>, std::boxed::Box<(dyn jobs::Job + 
't11)>, (dyn jobs::Job + 't12), &'t13 (dyn jobs::Job + 't14), bool, bool, &'t15 mut 
handler::ServiceInfo, &'t16 mut (dyn jobs::Job + 't17), &'t18 (dyn jobs::Job + 't19), 
&'t20 jobs::Service, &'t21 jobs::Service, std::pin::Pin<std::boxed::Box<(dyn 
core::future::future::Future<Output = jobs::ExtStatus> + std::marker::Send + 't22)>>, 
std::pin::Pin<std::boxed::Box<(dyn core::future::future::Future<Output = 
jobs::ExtStatus> + std::marker::Send + 't23)>>, (), std::string::String, 
handler::Handler, &'t24 std::collections::HashMap<std::string::String, (jobs::Service, 
usize)>, std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::string::String, &'t25 std::string::String, &'t26 std::string::String, 
std::option::Option<&'t27 (jobs::Service, usize)>, &'t28 jobs::Service, &'t29 usize, 
handler::Handler, &'t30 mut std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't31)>>, 
std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't32)>>, std::boxed::Box<(dyn jobs::Job + 
't33)>, (dyn jobs::Job + 't34), &'t35 mut (dyn jobs::Job + 't36), &'t37 mut (dyn 
jobs::Job + 't38), &'t39 mut (dyn jobs::Job + 't40), &'t41 jobs::Service, &'t42 
jobs::Service, auth::ClientInfo, impl core::future::future::Future, impl 
core::future::future::Future, impl core::future::future::Future, (), 
std::string::String, handler::Handler, &'t49 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::string::String, &'t50 std::string::String, &'t51 std::string::String, 
std::option::Option<&'t52 (jobs::Service, usize)>, &'t53 jobs::Service, &'t54 usize, 
handler::Handler, &'t55 mut std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't56)>>, 
std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't57)>>, std::boxed::Box<(dyn jobs::Job + 
't58)>, (dyn jobs::Job + 't59), &'t60 mut (dyn jobs::Job + 't61), &'t62 mut (dyn 
jobs::Job + 't63), &'t64 mut (dyn jobs::Job + 't65), &'t66 jobs::Service, &'t67 
jobs::Service, auth::ClientInfo, impl core::future::future::Future, impl 
core::future::future::Future, impl core::future::future::Future, (), 
std::string::String, handler::Handler, &'t74 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::string::String, &'t75 std::string::String, &'t76 std::string::String, 
std::option::Option<&'t77 (jobs::Service, usize)>, &'t78 jobs::Service, &'t79 usize, 
handler::Handler, &'t80 mut std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't81)>>, 
std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't82)>>, std::boxed::Box<(dyn jobs::Job + 
't83)>, (dyn jobs::Job + 't84), &'t85 mut (dyn jobs::Job + 't86), &'t87 mut (dyn 
jobs::Job + 't88), &'t89 mut (dyn jobs::Job + 't90), &'t91 jobs::Service, &'t92 
jobs::Service, auth::ClientInfo, impl core::future::future::Future, impl 
core::future::future::Future, impl core::future::future::Future, (), 
std::string::String, handler::Handler, &'t99 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::string::String, &'t100 std::string::String, &'t101 std::string::String, 
std::option::Option<&'t102 (jobs::Service, usize)>, &'t103 jobs::Service, &'t104 usize, 
handler::Handler, &'t105 mut std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't106)>>, 
std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't107)>>, std::boxed::Box<(dyn jobs::Job 
+ 't108)>, (dyn jobs::Job + 't109), &'t110 mut (dyn jobs::Job + 't111), &'t112 mut (dyn 
jobs::Job + 't113), &'t114 mut (dyn jobs::Job + 't115), &'t116 jobs::Service, &'t117 
jobs::Service, auth::ClientInfo, impl core::future::future::Future, impl 
core::future::future::Future, impl core::future::future::Future, (), 
std::string::String, handler::Handler, &'t124 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::string::String, &'t125 std::string::String, &'t126 std::string::String, 
std::option::Option<&'t127 (jobs::Service, usize)>, &'t128 jobs::Service, &'t129 usize, 
handler::Handler, &'t130 mut std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't131)>>, 
std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't132)>>, std::boxed::Box<(dyn jobs::Job 
+ 't133)>, (dyn jobs::Job + 't134), &'t135 mut (dyn jobs::Job + 't136), &'t137 mut (dyn 
jobs::Job + 't138), &'t139 mut (dyn jobs::Job + 't140), &'t141 jobs::Service, &'t142 
jobs::Service, auth::ClientInfo, impl core::future::future::Future, impl 
core::future::future::Future, impl core::future::future::Future, (), 
std::string::String, std::string::String, std::string::String, handler::Handler, &'t149 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::string::String, &'t150 std::string::String, &'t151 std::string::String, 
std::option::Option<&'t152 (jobs::Service, usize)>, &'t153 jobs::Service, &'t154 usize, 
handler::Handler, &'t155 mut std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't156)>>, 
std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't157)>>, std::boxed::Box<(dyn jobs::Job 
+ 't158)>, (dyn jobs::Job + 't159), &'t160 mut (dyn jobs::Job + 't161), &'t162 mut (dyn 
jobs::Job + 't163), &'t164 mut (dyn jobs::Job + 't165), &'t166 jobs::Service, &'t167 
jobs::Service, auth::ClientInfo, std::string::String, std::string::String, impl 
core::future::future::Future, impl core::future::future::Future, impl 
core::future::future::Future, (), std::string::String, handler::Handler, &'t174 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::string::String, &'t175 std::string::String, &'t176 std::string::String, 
std::option::Option<&'t177 (jobs::Service, usize)>, &'t178 jobs::Service, &'t179 usize, 
handler::Handler, &'t180 mut std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't181)>>, 
std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't182)>>, std::boxed::Box<(dyn jobs::Job 
+ 't183)>, (dyn jobs::Job + 't184), &'t185 mut (dyn jobs::Job + 't186), &'t187 mut (dyn 
jobs::Job + 't188), &'t189 mut (dyn jobs::Job + 't190), &'t191 jobs::Service, &'t192 
jobs::Service, auth::ClientInfo, impl core::future::future::Future, impl 
core::future::future::Future, impl core::future::future::Future, (), 
std::string::String, handler::Handler, &'t199 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::string::String, &'t200 std::string::String, &'t201 std::string::String, 
std::option::Option<&'t202 (jobs::Service, usize)>, &'t203 jobs::Service, &'t204 usize, 
handler::Handler, &'t205 mut std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't206)>>, 
std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't207)>>, std::boxed::Box<(dyn jobs::Job 
+ 't208)>, (dyn jobs::Job + 't209), &'t210 mut (dyn jobs::Job + 't211), &'t212 mut (dyn 
jobs::Job + 't213), &'t214 mut (dyn jobs::Job + 't215), &'t216 jobs::Service, &'t217 
jobs::Service, auth::ClientInfo, impl core::future::future::Future, impl 
core::future::future::Future, impl core::future::future::Future, (), 
std::string::String, handler::Handler, &'t224 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::collections::HashMap<std::string::String, (jobs::Service, usize)>, 
std::string::String, &'t225 std::string::String, &'t226 std::string::String, 
std::option::Option<&'t227 (jobs::Service, usize)>, &'t228 jobs::Service, &'t229 usize, 
handler::Handler, &'t230 mut std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't231)>>, 
std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't232)>>, std::boxed::Box<(dyn jobs::Job 
+ 't233)>, (dyn jobs::Job + 't234), &'t235 mut (dyn jobs::Job + 't236), &'t237 mut (dyn 
jobs::Job + 't238), &'t239 mut (dyn jobs::Job + 't240), &'t241 jobs::Service, &'t242 
jobs::Service, auth::ClientInfo, impl core::future::future::Future, impl 
core::future::future::Future, impl core::future::future::Future, ()}]`

    = note: required because it appears within the type `std::future::GenFuture<[static generator@src/handler.rs:137:32: 198:6 __arg0:handler::Handler 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, 't55, 't56, 't57, 't58, 't59, 't60, 't61, 't62, 't63, 't64, 't65, 't66, 't67, 't68, 't69, 't70, 't71, 't72, 't73, 't74, 't75, 't76, 't77, 't78, 't79, 't80, 't81, 't82, 't83, 't84, 't85, 't86, 't87, 't88, 't89, 't90, 't91, 't92, 't93, 't94, 't95, 't96, 't97, 't98, 't99, 't100, 't101, 't102, 't103, 't104, 't105, 't106, 't107, 't108, 't109, 't110, 't111, 't112, 't113, 't114, 't115, 't116, 't117, 't118, 't119, 't120, 't121, 't122, 't123, 't124, 't125, 't126, 't127, 't128, 't129, 't130, 't131, 't132, 't133, 't134, 't135, 't136, 't137, 't138, 't139, 't140, 't141, 't142, 't143, 't144, 't145, 't146, 't147, 't148, 't149, 't150, 't151, 't152, 't153, 't154, 't155, 't156, 't157, 't158, 't159, 't160, 't161, 't162, 't163, 't164, 't165, 't166, 't167, 't168, 't169, 't170, 't171, 't172, 't173, 't174, 't175, 't176, 't177, 't178, 't179, 't180, 't181, 't182, 't183, 't184, 't185, 't186, 't187, 't188, 't189, 't190, 't191, 't192, 't193, 't194, 't195, 't196, 't197, 't198, 't199, 't200, 't201, 't202, 't203, 't204, 't205, 't206, 't207, 't208, 't209, 't210, 't211, 't212, 't213, 't214, 't215, 't216, 't217, 't218, 't219, 't220, 't221, 't222, 't223, 't224, 't225, 't226, 't227, 't228, 't229, 't230, 't231, 't232, 't233, 't234, 't235, 't236, 't237, 't238, 't239, 't240, 't241, 't242, 't243, 't244, 't245, 't246, 't247, 't248> {handler::Handler, handler::Handler, handler::Handler, &'r mut tokio_sync::mpsc::bounded::Receiver<handler::Action>, tokio_sync::mpsc::bounded::Receiver<handler::Action>, futures_util::stream::next::Next<'s, tokio_sync::mpsc::bounded::Receiver<handler::Action>>, futures_util::stream::next::Next<'t0, tokio_sync::mpsc::bounded::Receiver<handler::Action>>, (), std::option::Option<handler::Action>, handler::Action, handler::Action, handler::Request, auth::ClientInfo, tokio_sync::oneshot::Sender<handler::Response>, handler::Request, std::collections::HashMap<std::string::String, handler::ServiceInfo>, handler::Handler, &'t1 std::collections::HashMap<std::string::String, (jobs::Service, usize)>, std::collections::HashMap<std::string::String, (jobs::Service, usize)>, std::collections::hash_map::Values<'t2, std::string::String, (jobs::Service, usize)>, std::collections::hash_map::Values<'t3, std::string::String, (jobs::Service, usize)>, std::collections::hash_map::Values<'t4, std::string::String, (jobs::Service, usize)>, &'t5 (jobs::Service, usize), &'t6 jobs::Service, &'t7 usize, handler::Handler, &'t8 std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't9)>>, std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't10)>>, std::boxed::Box<(dyn jobs::Job + 't11)>, (dyn jobs::Job + 't12), &'t13 (dyn jobs::Job + 't14), bool, bool, &'t15 mut handler::ServiceInfo, &'t16 mut (dyn jobs::Job + 't17), &'t18 (dyn jobs::Job + 't19), &'t20 jobs::Service, &'t21 jobs::Service, std::pin::Pin<std::boxed::Box<(dyn core::future::future::Future<Output = jobs::ExtStatus> + std::marker::Send + 't22)>>, std::pin::Pin<std::boxed::Box<(dyn core::future::future::Future<Output = jobs::ExtStatus> + std::marker::Send + 't23)>>, (), std::string::String, handler::Handler, &'t24 std::collections::HashMap<std::string::String, (jobs::Service, usize)>, std::collections::HashMap<std::string::String, (jobs::Service, usize)>, std::string::String, &'t25 std::string::String, &'t26 std::string::String, std::option::Option<&'t27 (jobs::Service, usize)>, &'t28 jobs::Service, &'t29 usize, handler::Handler, &'t30 mut std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't31)>>, std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't32)>>, std::boxed::Box<(dyn jobs::Job + 't33)>, (dyn jobs::Job + 't34), &'t35 mut (dyn jobs::Job + 't36), &'t37 mut (dyn jobs::Job + 't38), &'t39 mut (dyn jobs::Job + 't40), &'t41 jobs::Service, &'t42 jobs::Service, auth::ClientInfo, impl core::future::future::Future, impl core::future::future::Future, impl core::future::future::Future, (), std::string::String, handler::Handler, &'t49 std::collections::HashMap<std::string::String, (jobs::Service, usize)>, std::collections::HashMap<std::string::String, (jobs::Service, usize)>, std::string::String, &'t50 std::string::String, &'t51 std::string::String, std::option::Option<&'t52 (jobs::Service, usize)>, &'t53 jobs::Service, &'t54 usize, handler::Handler, &'t55 mut std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't56)>>, std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't57)>>, std::boxed::Box<(dyn jobs::Job + 't58)>, (dyn jobs::Job + 't59), &'t60 mut (dyn jobs::Job + 't61), &'t62 mut (dyn jobs::Job + 't63), &'t64 mut (dyn jobs::Job + 't65), &'t66 jobs::Service, &'t67 jobs::Service, auth::ClientInfo, impl core::future::future::Future, impl core::future::future::Future, impl core::future::future::Future, (), std::string::String, handler::Handler, &'t74 std::collections::HashMap<std::string::String, (jobs::Service, usize)>, std::collections::HashMap<std::string::String, (jobs::Service, usize)>, std::string::String, &'t75 std::string::String, &'t76 std::string::String, std::option::Option<&'t77 (jobs::Service, usize)>, &'t78 jobs::Service, &'t79 usize, handler::Handler, &'t80 mut std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't81)>>, std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't82)>>, std::boxed::Box<(dyn jobs::Job + 't83)>, (dyn jobs::Job + 't84), &'t85 mut (dyn jobs::Job + 't86), &'t87 mut (dyn jobs::Job + 't88), &'t89 mut (dyn jobs::Job + 't90), &'t91 jobs::Service, &'t92 jobs::Service, auth::ClientInfo, impl core::future::future::Future, impl core::future::future::Future, impl core::future::future::Future, (), std::string::String, handler::Handler, &'t99 std::collections::HashMap<std::string::String, (jobs::Service, usize)>, std::collections::HashMap<std::string::String, (jobs::Service, usize)>, std::string::String, &'t100 std::string::String, &'t101 std::string::String, std::option::Option<&'t102 (jobs::Service, usize)>, &'t103 jobs::Service, &'t104 usize, handler::Handler, &'t105 mut std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't106)>>, std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't107)>>, std::boxed::Box<(dyn jobs::Job + 't108)>, (dyn jobs::Job + 't109), &'t110 mut (dyn jobs::Job + 't111), &'t112 mut (dyn jobs::Job + 't113), &'t114 mut (dyn jobs::Job + 't115), &'t116 jobs::Service, &'t117 jobs::Service, auth::ClientInfo, impl core::future::future::Future, impl core::future::future::Future, impl core::future::future::Future, (), std::string::String, handler::Handler, &'t124 std::collections::HashMap<std::string::String, (jobs::Service, usize)>, std::collections::HashMap<std::string::String, (jobs::Service, usize)>, std::string::String, &'t125 std::string::String, &'t126 std::string::String, std::option::Option<&'t127 (jobs::Service, usize)>, &'t128 jobs::Service, &'t129 usize, handler::Handler, &'t130 mut std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't131)>>, std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't132)>>, std::boxed::Box<(dyn jobs::Job + 't133)>, (dyn jobs::Job + 't134), &'t135 mut (dyn jobs::Job + 't136), &'t137 mut (dyn jobs::Job + 't138), &'t139 mut (dyn jobs::Job + 't140), &'t141 jobs::Service, &'t142 jobs::Service, auth::ClientInfo, impl core::future::future::Future, impl core::future::future::Future, impl core::future::future::Future, (), std::string::String, std::string::String, std::string::String, handler::Handler, &'t149 std::collections::HashMap<std::string::String, (jobs::Service, usize)>, std::collections::HashMap<std::string::String, (jobs::Service, usize)>, std::string::String, &'t150 std::string::String, &'t151 std::string::String, std::option::Option<&'t152 (jobs::Service, usize)>, &'t153 jobs::Service, &'t154 usize, handler::Handler, &'t155 mut std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't156)>>, std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't157)>>, std::boxed::Box<(dyn jobs::Job + 't158)>, (dyn jobs::Job + 't159), &'t160 mut (dyn jobs::Job + 't161), &'t162 mut (dyn jobs::Job + 't163), &'t164 mut (dyn jobs::Job + 't165), &'t166 jobs::Service, &'t167 jobs::Service, auth::ClientInfo, std::string::String, std::string::String, impl core::future::future::Future, impl core::future::future::Future, impl core::future::future::Future, (), std::string::String, handler::Handler, &'t174 std::collections::HashMap<std::string::String, (jobs::Service, usize)>, std::collections::HashMap<std::string::String, (jobs::Service, usize)>, std::string::String, &'t175 std::string::String, &'t176 std::string::String, std::option::Option<&'t177 (jobs::Service, usize)>, &'t178 jobs::Service, &'t179 usize, handler::Handler, &'t180 mut std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't181)>>, std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't182)>>, std::boxed::Box<(dyn jobs::Job + 't183)>, (dyn jobs::Job + 't184), &'t185 mut (dyn jobs::Job + 't186), &'t187 mut (dyn jobs::Job + 't188), &'t189 mut (dyn jobs::Job + 't190), &'t191 jobs::Service, &'t192 jobs::Service, auth::ClientInfo, impl core::future::future::Future, impl core::future::future::Future, impl core::future::future::Future, (), std::string::String, handler::Handler, &'t199 std::collections::HashMap<std::string::String, (jobs::Service, usize)>, std::collections::HashMap<std::string::String, (jobs::Service, usize)>, std::string::String, &'t200 std::string::String, &'t201 std::string::String, std::option::Option<&'t202 (jobs::Service, usize)>, &'t203 jobs::Service, &'t204 usize, handler::Handler, &'t205 mut std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't206)>>, std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't207)>>, std::boxed::Box<(dyn jobs::Job + 't208)>, (dyn jobs::Job + 't209), &'t210 mut (dyn jobs::Job + 't211), &'t212 mut (dyn jobs::Job + 't213), &'t214 mut (dyn jobs::Job + 't215), &'t216 jobs::Service, &'t217 jobs::Service, auth::ClientInfo, impl core::future::future::Future, impl core::future::future::Future, impl core::future::future::Future, (), std::string::String, handler::Handler, &'t224 std::collections::HashMap<std::string::String, (jobs::Service, usize)>, std::collections::HashMap<std::string::String, (jobs::Service, usize)>, std::string::String, &'t225 std::string::String, &'t226 std::string::String, std::option::Option<&'t227 (jobs::Service, usize)>, &'t228 jobs::Service, &'t229 usize, handler::Handler, &'t230 mut std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't231)>>, std::vec::Vec<std::boxed::Box<(dyn jobs::Job + 't232)>>, std::boxed::Box<(dyn jobs::Job + 't233)>, (dyn jobs::Job + 't234), &'t235 mut (dyn jobs::Job + 't236), &'t237 mut (dyn jobs::Job + 't238), &'t239 mut (dyn jobs::Job + 't240), &'t241 jobs::Service, &'t242 jobs::Service, auth::ClientInfo, impl core::future::future::Future, impl core::future::future::Future, impl core::future::future::Future, ()}]>`
@Aaron1011

This comment has been minimized.

Copy link
Contributor

@Aaron1011 Aaron1011 commented Dec 5, 2019

@birkenfeld: Can you link to your repository, and re-fry on the latest nightly? I think more recent builds of rustc have improved errors inside async fns

@estebank estebank added the D-verbose label Dec 6, 2019
@birkenfeld

This comment has been minimized.

Copy link
Contributor Author

@birkenfeld birkenfeld commented Dec 6, 2019

Didn't see a change with latest nightly (7afe6d9 2019-12-03).

Unfortunately I can't link to the repo, but if needed I can try to extract a minimal example which produces similar results.

@TannerRogalsky

This comment has been minimized.

Copy link

@TannerRogalsky TannerRogalsky commented Dec 6, 2019

This looks very similar to an error that I'm getting around async code using mpsc. I can provide a minimal example:

use futures::executor::ThreadPool;
use std::sync::mpsc;
use std::time::Duration;

async fn wait(d: Duration) -> f32 {
    d.as_secs_f32()
}

async fn add_task(sender: mpsc::Sender<f32>, i: u64) {
//    let v = wait(Duration::from_millis(i)).await;
//    sender.send(v).unwrap();
    sender.send(wait(Duration::from_millis(i)).await).unwrap();
}

fn main() {
    let (sender, receiver) = mpsc::channel();
    let thread_pool = ThreadPool::new().unwrap();
    for i in (0..10).rev() {
        thread_pool.spawn_ok(add_task(sender.clone(), i * 100));
    }
    drop(sender);
    for v in receiver {
        println!("{}", v);
    }
}

While using these dependencies:

[dependencies]
futures = { version = "0.3", features = [ "thread-pool" ] }

results in this error:

error[E0277]: `std::sync::mpsc::Sender<f32>` cannot be shared between threads safely
  --> src/bin/thead_pool_mpsc.rs:19:21
   |
19 |         thread_pool.spawn_ok(add_task(sender.clone(), i * 100));
   |                     ^^^^^^^^ `std::sync::mpsc::Sender<f32>` cannot be shared between threads safely
   |
   = help: the trait `std::marker::Sync` is not implemented for `std::sync::mpsc::Sender<f32>`
   = note: required because of the requirements on the impl of `std::marker::Send` for `&std::sync::mpsc::Sender<f32>`
   = note: required because it appears within the type `for<'r> {std::sync::mpsc::Sender<f32>, u64, &'r std::sync::mpsc::Sender<f32>, std::sync::mpsc::Sender<f32>, u64, std::time::Duration, impl core::future::future::Future, impl core::future::future::Future, ()}`
   = note: required because it appears within the type `[static generator@src/bin/thead_pool_mpsc.rs:9:54: 13:2 sender:std::sync::mpsc::Sender<f32>, i:u64 for<'r> {std::sync::mpsc::Sender<f32>, u64, &'r std::sync::mpsc::Sender<f32>, std::sync::mpsc::Sender<f32>, u64, std::time::Duration, impl core::future::future::Future, impl core::future::future::Future, ()}]`
   = note: required because it appears within the type `std::future::GenFuture<[static generator@src/bin/thead_pool_mpsc.rs:9:54: 13:2 sender:std::sync::mpsc::Sender<f32>, i:u64 for<'r> {std::sync::mpsc::Sender<f32>, u64, &'r std::sync::mpsc::Sender<f32>, std::sync::mpsc::Sender<f32>, u64, std::time::Duration, 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`

It's worth noting the the commented version works. Using await inline as an expression is the only failure case I've encountered. This is using nightly-x86_64-apple-darwin - rustc 1.41.0-nightly (710a362dc 2019-12-05).

@Aaron1011

This comment has been minimized.

Copy link
Contributor

@Aaron1011 Aaron1011 commented Dec 6, 2019

Minimized:

struct NotSync(*const ());

async fn async_not_sync() {
    let a = NotSync(0 as *const ());
    // Uncomment this line to see a better error
    //let b: *const ();
    
    // Force 'a' to be live across a yield point
    async fn dummy() {}
    dummy().await;
}

fn require_sync<T: Sync>(val: T) {}

fn main() {
    require_sync(async_not_sync());
}

It seems that the better error message is only being triggered by certain !Send/!Sync type, and falling back to the old behavior for others.

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

@nikomatsakis nikomatsakis commented Dec 10, 2019

Possibly helped by #65345 as well

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

@nikomatsakis nikomatsakis commented Dec 10, 2019

Marking as "triaged". Not promoting to "on deck" for now -- it seems likely though that existing PRs cover it. We should land those already!

@davidtwco

This comment has been minimized.

Copy link
Member

@davidtwco davidtwco commented Dec 10, 2019

#65345 produces the following error for @Aaron1011's minimized example:

error: future cannot be shared between threads safely
  --> /home/david/projects/rust/rust4/src/test/ui/async-await/issue-64130-foo.rs:18:5
   |
LL | fn require_sync<T: Sync>(val: T) {}
   |    ------------    ---- required by this bound in `require_sync`
...
LL |     require_sync(async_not_sync());
   |     ^^^^^^^^^^^^ future returned by `async_not_sync` is not `Sync`
   |
   = help: within `impl std::future::Future`, the trait `std::marker::Sync` is not implemented for `*const ()`
note: future is not `Sync` as this value is used across an await
  --> /home/david/projects/rust/rust4/src/test/ui/async-await/issue-64130-foo.rs:12:5
   |
LL |     let a = NotSync(0 as *const ());
   |         - has type `NotSync`
...
LL |     dummy().await;
   |     ^^^^^^^^^^^^^ await occurs here, with `a` maybe used later
LL | }
   | - `a` is later dropped here

error: aborting due to previous error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.