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

error: the parameter type `T` may not live long enough [E0310] #22

Closed
viperscape opened this issue Feb 19, 2015 · 6 comments
Closed

error: the parameter type `T` may not live long enough [E0310] #22

viperscape opened this issue Feb 19, 2015 · 6 comments

Comments

@viperscape
Copy link

@viperscape viperscape commented Feb 19, 2015

New rust version makes a breaking change:

error: the parameter type `T` may not live long enough [E0310]
help: consider adding an explicit lifetime bound `T: 'static`...

I didn't see this on the breaking changes list, but I ended up having to modify my code as well, though wasn't thrilled with using static. Anyways, just giving you a heads up! Thanks for your support :D

@TyOverby
Copy link
Collaborator

@TyOverby TyOverby commented Feb 19, 2015

Is that an error coming from the inside of the library or while using the library?

I'm confused because T: 'static should be required for 100% of all deserializations. (It is impossible to deserialize a type that has a lifetime-based reference to another object).

I actually just wrote added a struct called RefBox that fixes this problem. The docs for it do a good example of explaining how and why it is used.

@viperscape
Copy link
Author

@viperscape viperscape commented Feb 19, 2015

it occurred while cargo was compiling bincode, since I had included wire in
my project. if you want I can post the compiler errors, sorry for the
vagueness! I'll check out refbox. I couldn't find the reason for this
change in rust, but I suspect Send on T might be the culprit.

On Thu, Feb 19, 2015, 3:21 PM Ty notifications@github.com wrote:

Is that an error coming from the inside of the library or while using the
library?

I'm confused because T: 'static should be required for 100% of all
deserializations. (It is impossible to deserialize a type that has a
lifetime-based reference to another object).

I actually just wrote added a struct called RefBox that fixes this
problem. The docs for it do a good example of explaining how and why it is
used.


Reply to this email directly or view it on GitHub
#22 (comment).

@TyOverby
Copy link
Collaborator

@TyOverby TyOverby commented Feb 20, 2015

I just compiled master with the most recent rustc version and bincode compiled just fine. Could you check to see if the problem is actually with Wire or in your own code?

@TyOverby
Copy link
Collaborator

@TyOverby TyOverby commented Feb 20, 2015

I just compiled Wire too... No errors there either.

@viperscape
Copy link
Author

@viperscape viperscape commented Feb 20, 2015

I had to update my rust version with a date flag, rust itself wasn't updating due to an invalid hash. I had originally tested this on windows, but this is again from newest nightly:

cargo run
...

Compiling bchannel v0.0.4
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:59:20: 59:33 error: the parameter type `T` may not live long enough [E0310]
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:59     let (tx, rx) = mpsc::channel();
                                                                                                            ^~~~~~~~~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:59:20: 59:33 help: consider adding an explicit lifetime bound `T: 'static`...
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:59     let (tx, rx) = mpsc::channel();
                                                                                                            ^~~~~~~~~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:59:20: 59:33 note: ...so that the type `CommMsg<T, E>` will meet its required lifetime bounds
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:59     let (tx, rx) = mpsc::channel();
                                                                                                            ^~~~~~~~~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:59:20: 59:33 error: the parameter type `E` may not live long enough [E0310]
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:59     let (tx, rx) = mpsc::channel();
                                                                                                            ^~~~~~~~~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:59:20: 59:33 help: consider adding an explicit lifetime bound `E: 'static`...
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:59     let (tx, rx) = mpsc::channel();
                                                                                                            ^~~~~~~~~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:59:20: 59:33 note: ...so that the type `CommMsg<T, E>` will meet its required lifetime bounds
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:59     let (tx, rx) = mpsc::channel();
                                                                                                            ^~~~~~~~~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:81:26: 81:51 error: the parameter type `T` may not live long enough [E0310]
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:81         match self.inner.send(CommMsg::Message(t)) {
                                                                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:81:26: 81:51 help: consider adding an explicit lifetime bound `T: 'static`...
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:81         match self.inner.send(CommMsg::Message(t)) {
                                                                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:81:26: 81:51 note: ...so that the type `CommMsg<T, E>` will meet its required lifetime bounds
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:81         match self.inner.send(CommMsg::Message(t)) {
                                                                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:81:26: 81:51 error: the parameter type `E` may not live long enough [E0310]
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:81         match self.inner.send(CommMsg::Message(t)) {
                                                                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:81:26: 81:51 help: consider adding an explicit lifetime bound `E: 'static`...
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:81         match self.inner.send(CommMsg::Message(t)) {
                                                                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:81:26: 81:51 note: ...so that the type `CommMsg<T, E>` will meet its required lifetime bounds
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:81         match self.inner.send(CommMsg::Message(t)) {
                                                                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:114:26: 114:49 error: the parameter type `T` may not live long enough [E0310]
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:114         match self.inner.send(CommMsg::Error(e)) {
                                                                                                                   ^~~~~~~~~~~~~~~~~~~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:114:26: 114:49 help: consider adding an explicit lifetime bound `T: 'static`...
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:114         match self.inner.send(CommMsg::Error(e)) {
                                                                                                                   ^~~~~~~~~~~~~~~~~~~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:114:26: 114:49 note: ...so that the type `CommMsg<T, E>` will meet its required lifetime bounds
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:114         match self.inner.send(CommMsg::Error(e)) {
                                                                                                                   ^~~~~~~~~~~~~~~~~~~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:114:26: 114:49 error: the parameter type `E` may not live long enough [E0310]
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:114         match self.inner.send(CommMsg::Error(e)) {
                                                                                                                   ^~~~~~~~~~~~~~~~~~~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:114:26: 114:49 help: consider adding an explicit lifetime bound `E: 'static`...
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:114         match self.inner.send(CommMsg::Error(e)) {
                                                                                                                   ^~~~~~~~~~~~~~~~~~~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:114:26: 114:49 note: ...so that the type `CommMsg<T, E>` will meet its required lifetime bounds
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:114         match self.inner.send(CommMsg::Error(e)) {
                                                                                                                   ^~~~~~~~~~~~~~~~~~~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:133:31: 133:38 error: the parameter type `T` may not live long enough [E0310]
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:133             inner: self.inner.clone(),
                                                                                                                        ^~~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:133:31: 133:38 help: consider adding an explicit lifetime bound `T: 'static`...
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:133             inner: self.inner.clone(),
                                                                                                                        ^~~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:133:31: 133:38 note: ...so that the type `CommMsg<T, E>` will meet its required lifetime bounds
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:133             inner: self.inner.clone(),
                                                                                                                        ^~~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:133:31: 133:38 error: the parameter type `E` may not live long enough [E0310]
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:133             inner: self.inner.clone(),
                                                                                                                        ^~~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:133:31: 133:38 help: consider adding an explicit lifetime bound `E: 'static`...
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:133             inner: self.inner.clone(),
                                                                                                                        ^~~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:133:31: 133:38 note: ...so that the type `CommMsg<T, E>` will meet its required lifetime bounds
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:133             inner: self.inner.clone(),
                                                                                                                        ^~~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:167:26: 167:36 error: the parameter type `T` may not live long enough [E0310]
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:167         match self.inner.try_recv() {
                                                                                                                   ^~~~~~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:167:26: 167:36 help: consider adding an explicit lifetime bound `T: 'static`...
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:167         match self.inner.try_recv() {
                                                                                                                   ^~~~~~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:167:26: 167:36 note: ...so that the type `CommMsg<T, E>` will meet its required lifetime bounds
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:167         match self.inner.try_recv() {
                                                                                                                   ^~~~~~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:167:26: 167:36 error: the parameter type `E` may not live long enough [E0310]
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:167         match self.inner.try_recv() {
                                                                                                                   ^~~~~~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:167:26: 167:36 help: consider adding an explicit lifetime bound `E: 'static`...
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:167         match self.inner.try_recv() {
                                                                                                                   ^~~~~~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:167:26: 167:36 note: ...so that the type `CommMsg<T, E>` will meet its required lifetime bounds
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:167         match self.inner.try_recv() {
                                                                                                                   ^~~~~~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:194:26: 194:32 error: the parameter type `T` may not live long enough [E0310]
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:194         match self.inner.recv() {
                                                                                                                   ^~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:194:26: 194:32 help: consider adding an explicit lifetime bound `T: 'static`...
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:194         match self.inner.recv() {
                                                                                                                   ^~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:194:26: 194:32 note: ...so that the type `CommMsg<T, E>` will meet its required lifetime bounds
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:194         match self.inner.recv() {
                                                                                                                   ^~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:194:26: 194:32 error: the parameter type `E` may not live long enough [E0310]
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:194         match self.inner.recv() {
                                                                                                                   ^~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:194:26: 194:32 help: consider adding an explicit lifetime bound `E: 'static`...
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:194         match self.inner.recv() {
                                                                                                                   ^~~~~~
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:194:26: 194:32 note: ...so that the type `CommMsg<T, E>` will meet its required lifetime bounds
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:194         match self.inner.recv() {
                                                                                                                   ^~~~~~
error: aborting due to 12 previous errors
Build failed, waiting for other jobs to finish...
Could not compile `bchannel`.

To learn more, run the command again with --verbose.

Compilation exited abnormally with code 101 at Fri Feb 20 03:34:27
@viperscape
Copy link
Author

@viperscape viperscape commented Feb 20, 2015

Edit: I just realized it said bchannel and not bincode, so I should move this issue over to there; could have sworn it also included bincode, sorry for the confusion!

Just to double check, I tried it again:

$ rustc --version
rustc 1.0.0-nightly (dfc5c0f1e 2015-02-18) (built 2015-02-19)
$ cargo clean
$ cargo update
    Updating registry `https://github.com/rust-lang/crates.io-index`
    Updating git repository `https://github.com/viperscape/cubby`
    Updating git repository `https://github.com/TyOverby/wire`
$ cargo build
   Compiling bchannel v0.0.4
   Compiling rustc-serialize v0.2.14
   Compiling bitflags v0.1.1
   Compiling clock_ticks v0.0.2
   Compiling quack v0.0.10
   Compiling cubby v0.0.1 (https://github.com/viperscape/cubby#1fb4ae6a)
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:59:20: 59:33 error: the parameter type `T` may not live long enough [E0310]
/home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/bchannel-0.0.4/src/lib.rs:59     let (tx, rx) = mpsc::channel();
...
error: aborting due to 12 previous errors
Build failed, waiting for other jobs to finish...
Could not compile `bchannel`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.