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

Fix compiler errors about lifetime #83

Conversation

markus-becker-tridonic-com

With

rustc --version
rustc 1.68.2 (9eb3afe9e 2023-03-27)
cargo --version
cargo 1.68.2 (6feb7c9cf 2023-03-26)

I was getting the following errors:

   Compiling rs-matter v0.1.0 (/Users/markusbecker/src/matter-rs/rs-matter)
error[E0310]: the parameter type `D` may not live long enough
   --> rs-matter/src/mdns/builtin.rs:131:5
    |
131 | /     {
132 | |         let mut udp = crate::transport::udp::UdpListener::new(
133 | |             stack,
134 | |             crate::transport::network::SocketAddr::new(IpAddr::V6(Ipv6Addr::UNSPECIFIED), PORT),
...   |
201 | |             .unwrap()
202 | |     }
    | |_____^ ...so that the type `D` will meet its required lifetime bounds
    |
help: consider adding an explicit lifetime bound...
    |
130 |         D: crate::transport::network::NetworkStackDriver + 'static,
    |                                                          +++++++++

error[E0310]: the parameter type `D` may not live long enough
   --> rs-matter/src/transport/core.rs:134:5
    |
134 | /     {
135 | |         let udp = crate::transport::udp::UdpListener::new(
136 | |             stack,
137 | |             crate::transport::network::SocketAddr::new(
...   |
200 | |             .unwrap()
201 | |     }
    | |_____^ ...so that the type `D` will meet its required lifetime bounds
    |
help: consider adding an explicit lifetime bound...
    |
132 |         D: crate::transport::network::NetworkStackDriver + 'static,
    |                                                          +++++++++

For more information about this error, try `rustc --explain E0310`.

This commit applies those recommendations.

With
```
rustc --version
rustc 1.68.2 (9eb3afe9e 2023-03-27)
cargo --version
cargo 1.68.2 (6feb7c9cf 2023-03-26)
```
I was getting the following errors:
```
   Compiling rs-matter v0.1.0 (/Users/markusbecker/src/matter-rs/rs-matter)
error[E0310]: the parameter type `D` may not live long enough
   --> rs-matter/src/mdns/builtin.rs:131:5
    |
131 | /     {
132 | |         let mut udp = crate::transport::udp::UdpListener::new(
133 | |             stack,
134 | |             crate::transport::network::SocketAddr::new(IpAddr::V6(Ipv6Addr::UNSPECIFIED), PORT),
...   |
201 | |             .unwrap()
202 | |     }
    | |_____^ ...so that the type `D` will meet its required lifetime bounds
    |
help: consider adding an explicit lifetime bound...
    |
130 |         D: crate::transport::network::NetworkStackDriver + 'static,
    |                                                          +++++++++

error[E0310]: the parameter type `D` may not live long enough
   --> rs-matter/src/transport/core.rs:134:5
    |
134 | /     {
135 | |         let udp = crate::transport::udp::UdpListener::new(
136 | |             stack,
137 | |             crate::transport::network::SocketAddr::new(
...   |
200 | |             .unwrap()
201 | |     }
    | |_____^ ...so that the type `D` will meet its required lifetime bounds
    |
help: consider adding an explicit lifetime bound...
    |
132 |         D: crate::transport::network::NetworkStackDriver + 'static,
    |                                                          +++++++++

For more information about this error, try `rustc --explain E0310`.
```

This commit applies those recommendations.
@ivmarkov
Copy link
Contributor

ivmarkov commented Aug 3, 2023

@markus-becker-tridonic-com:

I don't see these errors. (I've tried latest stable - 1.71 and latest nightly - 1.73).

What compiler version are you using?

@ivmarkov
Copy link
Contributor

ivmarkov commented Aug 3, 2023

Ah, it is 1.68.2 - I should read more carefully!

How about upgrading to 1.71?

@markus-becker-tridonic-com
Copy link
Author

Ah, it is 1.68.2 - I should read more carefully!

How about upgrading to 1.71?

Ah, right. Interesting that lifetimes are not required anymore on 1.71.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants