Skip to content

Unexpected error: the associated type <U as util::async::Async>::Value may not live long enough #21150

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

Closed
carllerche opened this issue Jan 14, 2015 · 1 comment · Fixed by #21252
Labels
A-associated-items Area: Associated items (types, constants & functions)

Comments

@carllerche
Copy link
Member

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

cc @nikomatsakis

@nikomatsakis nikomatsakis added the A-associated-items Area: Associated items (types, constants & functions) label Jan 14, 2015
@chris-morgan
Copy link
Member

Duplicate of #20890.

alexcrichton added a commit to alexcrichton/rust that referenced this issue Jan 21, 2015
Project region bounds out of the trait when deciding whether a projection type outlives a given regions.

Fixes rust-lang#20890.
Fixes rust-lang#21150.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants