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

Update rand to 0.9.0 #221

Merged
merged 1 commit into from
Feb 5, 2025
Merged

Update rand to 0.9.0 #221

merged 1 commit into from
Feb 5, 2025

Conversation

thomas-tribus
Copy link
Contributor

I wanted to create a PR to switch from rand 0.8.5 to 0.9.0. It is quite an involved upgrade and my knowledge of fake-rs is far from complete. I created a PR to get some feedback. I have one issue (and I'm not sure how many other issues this is hiding) with the proc-macro which won't compile anymore. I don't have much experience with proc macros, so I'm hoping the error below triggers something in somebody here.

For the actual upgrade notes see:

See: https://rust-random.github.io/book/update-0.9.html

The upgrade has quite a few breaking changes. Most notable are:

  • Drop support for usize and isize from Uniform
  • Uniform::sample returns result (used to panic)
  • Deprecate gen like function names (replace with random)

The actual error I'm getting is this. To be honest, I'm not even sure where to begin to fix it.

error[E0782]: expected a type, found a trait
  --> fake/tests/derive_macros.rs:22:22
   |
22 |             #[derive(Dummy, Debug, Eq, PartialEq)]
   |                      ^^^^^ in this derive macro expansion
   |
  ::: .../fake-rs/dummy_derive/src/lib.rs:59:1   |

@thomas-tribus thomas-tribus changed the title Update rand to 0.9.0 Update rand to 0.9.0 [[Don't merge yet]] Feb 3, 2025
@cksac
Copy link
Owner

cksac commented Feb 3, 2025

you can look at usage of rand in dummy_derive, and update the usage of rand accordingly.
https://github.com/cksac/fake-rs/blob/master/dummy_derive/src/lib.rs#L220 this part is used when generate dummy impl for enum.

@thomas-tribus thomas-tribus changed the title Update rand to 0.9.0 [[Don't merge yet]] Update rand to 0.9.0 Feb 3, 2025
@thomas-tribus
Copy link
Contributor Author

update the usage of rand accordingly.

That was indeed the issue, after updating the usage of rand the issue was fixed.

Another thing; I encountered failing tests after my changes. It seems the new rand version is giving different numbers vs the expected numbers. After changing the tests to accept the new values they pass consistently on my machine. But while I'm writing this I see I still have builds. But that is for tomorrow.

See: https://rust-random.github.io/book/update-0.9.html

The upgrade has quite a few breaking changes. Most notable are:
- Drop support for `usize` and `isize` from Uniform
- Uniform::sample returns result (used to panic)
- Deprecate `gen` like function names (replace with `random`
@thomas-tribus
Copy link
Contributor Author

@cksac All builds pass now, please let me know what you think.

@cksac
Copy link
Owner

cksac commented Feb 5, 2025

LGTM

@cksac cksac merged commit 1604ccc into cksac:master Feb 5, 2025
5 checks passed
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