Closed
Description
I have been attempting to switch my Future / Stream lib to use associated types, however I have been hitting snags. Even though all the types (as far as I can tell) are bound by Send (and some by 'static too), I have been getting a lot of error messages:
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:85:43: 90:26 error: the associated type `<U as util::async::Async>::Value` may not live long enough
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:85 next.receive(move |res| {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:86 match res {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:87 Ok(u) => c.complete(u),
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:88 Err(_) => unimplemented!(),
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:89 }
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:90 });
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:85:43: 90:26 help: consider adding an explicit lifetime bound `<U as util::async::Async>::Value: 'static`...
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:85 next.receive(move |res| {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:86 match res {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:87 Ok(u) => c.complete(u),
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:88 Err(_) => unimplemented!(),
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:89 }
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:90 });
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:85:43: 90:26 note: ...so that captured variable `c` does not outlive the enclosing closure
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:85 next.receive(move |res| {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:86 match res {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:87 Ok(u) => c.complete(u),
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:88 Err(_) => unimplemented!(),
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:89 }
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:90 });
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:85:30: 90:27 error: the associated type `<U as util::async::Async>::Value` may not live long enough
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:85 next.receive(move |res| {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:86 match res {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:87 Ok(u) => c.complete(u),
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:88 Err(_) => unimplemented!(),
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:89 }
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:90 });
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:85:30: 90:27 help: consider adding an explicit lifetime bound `<U as util::async::Async>::Value: 'static`...
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:85 next.receive(move |res| {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:86 match res {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:87 Ok(u) => c.complete(u),
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:88 Err(_) => unimplemented!(),
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:89 }
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:90 });
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:85:30: 90:27 note: ...so that the declared lifetime parameter bounds are satisfied
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:85 next.receive(move |res| {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:86 match res {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:87 Ok(u) => c.complete(u),
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:88 Err(_) => unimplemented!(),
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:89 }
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:90 });
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:82:31: 94:14 error: the associated type `<U as util::async::Async>::Value` may not live long enough
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:82 self.receive(move |res| {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:83 match res {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:84 Ok(_) => {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:85 next.receive(move |res| {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:86 match res {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:87 Ok(u) => c.complete(u),
...
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:82:31: 94:14 help: consider adding an explicit lifetime bound `<U as util::async::Async>::Value: 'static`...
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:82 self.receive(move |res| {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:83 match res {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:84 Ok(_) => {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:85 next.receive(move |res| {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:86 match res {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:87 Ok(u) => c.complete(u),
...
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:82:31: 94:14 note: ...so that captured variable `c` does not outlive the enclosing closure
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:82 self.receive(move |res| {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:83 match res {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:84 Ok(_) => {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:85 next.receive(move |res| {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:86 match res {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:87 Ok(u) => c.complete(u),
...
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:82:18: 94:15 error: the associated type `<U as util::async::Async>::Value` may not live long enough
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:82 self.receive(move |res| {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:83 match res {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:84 Ok(_) => {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:85 next.receive(move |res| {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:86 match res {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:87 Ok(u) => c.complete(u),
...
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:82:18: 94:15 help: consider adding an explicit lifetime bound `<U as util::async::Async>::Value: 'static`...
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:82 self.receive(move |res| {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:83 match res {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:84 Ok(_) => {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:85 next.receive(move |res| {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:86 match res {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:87 Ok(u) => c.complete(u),
...
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:82:18: 94:15 note: ...so that the declared lifetime parameter bounds are satisfied
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:82 self.receive(move |res| {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:83 match res {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:84 Ok(_) => {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:85 next.receive(move |res| {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:86 match res {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:87 Ok(u) => c.complete(u),
...
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:82:18: 94:15 error: the associated type `<U as util::async::Async>::Value` may not live long enough
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:82 self.receive(move |res| {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:83 match res {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:84 Ok(_) => {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:85 next.receive(move |res| {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:86 match res {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:87 Ok(u) => c.complete(u),
...
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:82:18: 94:15 help: consider adding an explicit lifetime bound `<U as util::async::Async>::Value: 'static`...
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:82 self.receive(move |res| {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:83 match res {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:84 Ok(_) => {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:85 next.receive(move |res| {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:86 match res {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:87 Ok(u) => c.complete(u),
...
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:82:18: 94:15 note: ...so that the declared lifetime parameter bounds are satisfied
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:82 self.receive(move |res| {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:83 match res {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:84 Ok(_) => {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:85 next.receive(move |res| {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:86 match res {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:87 Ok(u) => c.complete(u),
...
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:82:18: 94:15 error: the associated type `<U as util::async::Async>::Value` may not live long enough
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:82 self.receive(move |res| {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:83 match res {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:84 Ok(_) => {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:85 next.receive(move |res| {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:86 match res {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:87 Ok(u) => c.complete(u),
...
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:82:18: 94:15 help: consider adding an explicit lifetime bound `<U as util::async::Async>::Value: 'static`...
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:82 self.receive(move |res| {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:83 match res {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:84 Ok(_) => {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:85 next.receive(move |res| {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:86 match res {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:87 Ok(u) => c.complete(u),
...
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:82:18: 94:15 note: ...so that the declared lifetime parameter bounds are satisfied
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:82 self.receive(move |res| {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:83 match res {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:84 Ok(_) => {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:85 next.receive(move |res| {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:86 match res {
/Users/carllerche/Code/mine/syncbox/src/util/async/future.rs:87 Ok(u) => c.complete(u),
The repro is trying to compile syncbox on the async-associated-type branch. Sorry for not reducing more 😢
https://github.com/carllerche/syncbox/tree/async-associated-type