-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Bump rand, mt19937; fix associated build failures #7800
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: RustPython/RustPython
Length of output: 47
🏁 Script executed:
# Check if file exists and get the imports section head -30 crates/stdlib/src/random.rsRepository: RustPython/RustPython
Length of output: 851
🏁 Script executed:
Repository: RustPython/RustPython
Length of output: 387
🏁 Script executed:
Repository: RustPython/RustPython
Length of output: 47
🏁 Script executed:
Repository: RustPython/RustPython
Length of output: 4288
🏁 Script executed:
Repository: RustPython/RustPython
Length of output: 530
🏁 Script executed:
Repository: RustPython/RustPython
Length of output: 249
🏁 Script executed:
Repository: RustPython/RustPython
Length of output: 151
🏁 Script executed:
Repository: RustPython/RustPython
Length of output: 160
🏁 Script executed:
Repository: RustPython/RustPython
Length of output: 47
🌐 Web query:
mt19937 Rust crate from_rng method parameter trait💡 Result:
In the rand_core-based Rust ecosystem, the MT19937 generator’s “from_rng” style constructor is exposed via the rand_core::SeedableRng trait as: fn from_rng<R: RngCore>(rng: R) -> Result<Self, Error> So the parameter is a type parameter R constrained by rand_core::RngCore (an RNG producing values without error), passed by value (rng: R) and returns Result<Self, Error>. This is the generic trait signature in rand_core’s SeedableRng: [1]. Common related (infallible) variant in rand_mt: rand_mt’s Mt implements a method with signature: fn from_rng(rng: &mut R) -> Self where R: Rng +?Sized Here the parameter is &mut R, where R: rand::Rng (the infallible high-level RNG trait), and the method returns Self directly. [2] For the “mt19937” crate specifically (coolreader18/hiroshima-univ translation), its source shows implementations of rand_core::TryRng and rand_core::SeedableRng for MT19937 (but the exact from_rng signature there follows the rand_core::SeedableRng trait; the trait provides from_rng generically). [3][4] Therefore, when you ask “mt19937 Rust crate from_rng method parameter trait”, the trait bound for from_rng is R: RngCore in rand_core::SeedableRng. [1] If instead you are referring to rand_mt’s Mt::from_rng convenience API, the parameter uses &mut R where R: rand::Rng +?Sized. [2]
Citations:
🏁 Script executed:
Repository: RustPython/RustPython
Length of output: 47
🏁 Script executed:
Repository: RustPython/RustPython
Length of output: 185
🏁 Script executed:
Repository: RustPython/RustPython
Length of output: 325
🏁 Script executed:
Repository: RustPython/RustPython
Length of output: 47
Replace
RngwithRngCorein the import statement.The
MT19937::from_rng()call at line 62 uses theSeedableRng::from_rng()trait method, which requires a generic parameter bound byRngCore, notRng. The current import (use rand::{Rng, SeedableRng}) is missingRngCoreand cannot satisfy the trait bound forfrom_rng(). Whilenext_u32()at line 82 is a concrete method onMT19937itself (not requiring a trait import), the trait-basedfrom_rng()method cannot be properly used withoutRngCorein scope.Proposed fix
or equivalently:
🤖 Prompt for AI Agents