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

xot v0.22.0 fails to compile on Rust 1.77.0 #23

Closed
kawadakk opened this issue Mar 22, 2024 · 2 comments
Closed

xot v0.22.0 fails to compile on Rust 1.77.0 #23

kawadakk opened this issue Mar 22, 2024 · 2 comments

Comments

@kawadakk
Copy link

kawadakk commented Mar 22, 2024

error[E0309]: the parameter type `V` may not live long enough
   --> /home/$USER/.cargo/registry/src/index.crates.io-6f17d22bba15001f/xot-0.22.0/src/nodemap/core.rs:100:9
    |
37  |   impl<'a, K, V, A: ValueAdapter<K, V>> NodeMap<'a, K, V, A>
    |        -- the parameter type `V` must be valid for the lifetime `'a` as defined here...
...
100 | /         self.iter_value()
101 | |             .map(|value| (A::key(value), A::value(value)))
    | |__________________________________________________________^ ...so that the type `V` will meet its required lifetime bounds
    |
help: consider adding an explicit lifetime bound
    |
40  |     V: Clone + 'a,
    |              ++++

error[E0309]: the parameter type `V` may not live long enough
   --> /home/$USER/.cargo/registry/src/index.crates.io-6f17d22bba15001f/xot-0.22.0/src/nodemap/core.rs:116:9
    |
37  | impl<'a, K, V, A: ValueAdapter<K, V>> NodeMap<'a, K, V, A>
    |      -- the parameter type `V` must be valid for the lifetime `'a` as defined here...
...
116 |         self.iter_value().map(move |value| A::value(value))
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `V` will meet its required lifetime bounds
    |
help: consider adding an explicit lifetime bound
    |
40  |     V: Clone + 'a,
    |              ++++

For more information about this error, try `rustc --explain E0309`.
error: could not compile `xot` (lib) due to 2 previous errors

xot/src/nodemap/core.rs

Lines 99 to 102 in 6fbd052

pub fn iter(&self) -> impl Iterator<Item = (K, &'a V)> + '_ {
self.iter_value()
.map(|value| (A::key(value), A::value(value)))
}

xot/src/nodemap/core.rs

Lines 115 to 117 in 6fbd052

pub fn values(&self) -> impl Iterator<Item = &'a V> + '_ {
self.iter_value().map(move |value| A::value(value))
}

@kawadakk
Copy link
Author

kawadakk commented Mar 22, 2024

This probably has been caused by rust-lang/rust#120019 (a soundness fix).

&'a V in -> impl Iterator<Item = &'a V> doesn't create implied lifetime bounds or have its WF-ness checked (rust-lang/rust#110925). Since &'a V appears in the function body and the concrete return type anyway, V: 'a has to be verified to prove its WF-ness, which didn't happen until rust-lang/rust#120019.

MutableNodeMap::{iter,values} don't need V: 'a because the parameters &'a self (self: &'a MutableNodeMap<'a, K, V, A>) already imply V: 'a.

@faassen
Copy link
Owner

faassen commented Mar 22, 2024

Thanks! I've followed the suggestion and added a 'a and after that it compiles again. I've made a new release, 0.23, which also has various changes and new features concerning serialization I still had to release.

@faassen faassen closed this as completed Mar 22, 2024
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

No branches or pull requests

2 participants