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

tests don't compile on stable Rust: std::hash::RandomState only present on nightly #1098

Open
decathorpe opened this issue Jan 3, 2024 · 0 comments

Comments

@decathorpe
Copy link

It looks like there might be a problem in nightly Rust, where RandomState is available under a different module / import path than on stable Rust.

On Rust stable, RandomState is only available at std::collections::hash_map::RandomState, but on Rust nightly, it's also available at std::hash::RandomState (which is what is now used by serde_json's tests), but this looks like a mistake.

Not sure why your CI didn't catch that serde_json tests currently don't compile on stable Rust (i.e. this fails: cargo +stable test):

error[E0433]: failed to resolve: could not find `RandomState` in `hash`
    --> tests/test.rs:2494:27
     |
2494 |     let rand = std::hash::RandomState::new();
     |                           ^^^^^^^^^^^ could not find `RandomState` in `hash`
     |
help: consider importing this struct
     |
23   + use std::collections::hash_map::RandomState;
     |
help: if you import `RandomState`, refer to it directly
     |
2494 -     let rand = std::hash::RandomState::new();
2494 +     let rand = RandomState::new();
     |

warning: unused import: `std::hash::BuildHasher`
  --> tests/test.rs:37:5
   |
37 | use std::hash::BuildHasher;
   |     ^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant