Description
The rust nightly build cc19e3380 2014-12-20 introduced the warning reproduced below.
This drew my attention to the fact this conflicting lifetime name wasn't even used in the function !
So after resolving the name conflict, I changed the signature parameter to actually use that named lifetime but this had the effect of breaking almost all unit tests !!! 💥
With this modification, it becomes impossible to retrieve the endpoint and then to send or receive a message. For example you can use test_bind
alone, but not test_bind
and then test_write
.
Calling directly bind
without storing the result in variable and then write
works fine.
Storing the NanoResult or the Endpoint will cause a compilation error.
cannot borrow
push_socket
as mutable more than once at a time.
It looks like constraining the lifetime of the Endpoint to the one of the Socket makes the Endpoint a 'borrower' of the Socket.
I will post something on reddit and add the link here when done.
Signature before and after the change:
fn bind<'b, 'a: 'b>(&mut self, addr: &str) -> NanoResult<Endpoint<'b>>
fn bind<'b, 'x: 'b>(&'x mut self, addr: &str) -> NanoResult<Endpoint<'b>>
Warning:
Compiling nanomsg v0.3.0 (file:///home/travis/build/thehydroimpulse/nanomsg.rs)
/home/travis/build/thehydroimpulse/nanomsg.rs/src/lib.rs:203:21: 203:23 warning: lifetime name `'a` shadows another lifetime name that is already in scope
/home/travis/build/thehydroimpulse/nanomsg.rs/src/lib.rs:203 pub fn bind<'b, 'a: 'b>(&mut self, addr: &str) -> NanoResult<Endpoint<'b>> {
^~
/home/travis/build/thehydroimpulse/nanomsg.rs/src/lib.rs:123:6: 123:8 help: shadowed lifetime `'a` declared here
/home/travis/build/thehydroimpulse/nanomsg.rs/src/lib.rs:123 impl<'a> Socket<'a> {
^~
/home/travis/build/thehydroimpulse/nanomsg.rs/src/lib.rs:203:21: 203:23 help: shadowed lifetimes are deprecated and will become a hard error before 1.0