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

Build on stable Rust #31

Closed
philpax opened this issue Feb 9, 2023 · 2 comments · Fixed by #45
Closed

Build on stable Rust #31

philpax opened this issue Feb 9, 2023 · 2 comments · Fixed by #45
Labels
enhancement New feature or request meta:good first issue Good for newcomers

Comments

@philpax
Copy link
Contributor

philpax commented Feb 9, 2023

At present, the runtime does not build on stable Rust. This is due to the use of four features:

#![feature(map_many_mut)]
#![feature(cursor_remaining)]
#![feature(coerce_unsized)]
#![feature(unsize)]

The first two features are primarily used for convenience and can be replaced with slightly-less-ergonomic equivalents. The latter two features are used to enable easy construction of Cb callback wrappers - it's likely that the downstream code will need to be changed to not rely on this, or another way is found to make Cb construction simpler.

@philpax philpax added enhancement New feature or request meta:good first issue Good for newcomers labels Feb 9, 2023
@philpax philpax mentioned this issue Feb 11, 2023
@xunilrj
Copy link

xunilrj commented Feb 12, 2023

I created a small commit to test how to remove map_many_mut at https://github.com/xunilrj/Kiwi/commit/b0c9b739c3cfef4b41755cbf7a7ac226ed121208.

Unfortunately, this solution has two issues:

1 - has unsafe;
2 - rustc is smart enough to complain that will cause conflicts in the future:

warning: an associated function with this name may be added to the standard library in the future
  --> crates/network/src/rpc.rs:65:60
   |
65 |         let [old_instance, new_instance] = state.instances.get_many_mut([&old_instance_id, &instance_id]).unwrap();
   |                                                            ^^^^^^^^^^^^
   |
   = warning: once this associated item is added to the standard library, the ambiguity may cause an error or change in behavior!
   = note: for more information, see issue #48919 <https://github.com/rust-lang/rust/issues/48919>
   = help: call with fully qualified syntax `get_many_mut(...)` to keep using the current method
   = help: add `#![feature(map_many_mut)]` to the crate attributes to enable `HashMap::<K, V, S>::get_many_mut`
   = note: `#[warn(unstable_name_collisions)]` on by default

The worst part for me is that we need to use *mut V to bypass the borrow checker that complains about multiple mut borrows to the hashmap.

@pierd
Copy link
Contributor

pierd commented Feb 12, 2023

You could potentially use hashbrown's HashMap directly in the meantime. That's what's used internally anyway so you'd basically bypass the map_many_mut feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request meta:good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants