Common issues
Problem:
PR #1804 backported #1790 to the 0.8 branch.
After that, trying to compile v0.8.7 fails on openSUSE Tumbleweed.
Quick solution:
Change std::char::MAX to char::MAX on
|
if sampler.max() > std::char::MAX as u32 - CHAR_SURROGATE_LEN { |
Details:
I use a Rust program called Mago. It is a tool for PHP code analysis, and it uses rand as a dependency.
Since Mago v1.44, compiling the rand crate when updating Mago using:
cargo-install-update install-update mago
Failed with the following error:
Compiling rand v0.8.7
error[E0433]: cannot find module or crate `std` in this scope
--> /home/rodrigo/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rand-0.8.7/src/distributions/uniform.rs:605:24
|
605 | if sampler.max() > std::char::MAX as u32 - CHAR_SURROGATE_LEN {
| ^^^ use of unresolved module or unlinked crate `std`
|
= help: if you wanted to use a crate named `std`, use `cargo add std` to add it to your `Cargo.toml`
help: consider importing this module
|
109 + use core::char;
|
help: if you import `char`, refer to it directly
|
605 - if sampler.max() > std::char::MAX as u32 - CHAR_SURROGATE_LEN {
605 + if sampler.max() > char::MAX as u32 - CHAR_SURROGATE_LEN {
|
I also tried compiling it on a fresh openSUSE install within a VM to rule out any custom config I could have on my main machine and got the same error.
As the original change in PR #1790 doesn't have the std:: namespace on the correspondent line:
|
if sampler.max() > char::MAX as u32 - CHAR_SURROGATE_LEN { |
So I removed it from my local source copy at
/home/rodrigo/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rand-0.8.7/src/distributions/uniform.rs:605
Resulting in:
if sampler.max() > char::MAX as u32 - CHAR_SURROGATE_LEN {
And then running
cargo-install-update install-update mago
Succeeds in compiling both the crate and the Mago program.
I don't have any experience with Rust. Thus, I have no idea how to test this change properly, and I am also not sure if my "fix" is a proper fix or just masquerades the problem (by reading a constant from somewhere else not intended when removing the std:: namespace).
That is why I chose to open an issue and not send a PR.
If you need any further information about my setup or anything else, I am glad to provide it.
Common issues
Problem:
PR #1804 backported #1790 to the 0.8 branch.
After that, trying to compile v0.8.7 fails on openSUSE Tumbleweed.
Quick solution:
Change
std::char::MAXtochar::MAXonrand/src/distributions/uniform.rs
Line 605 in 90ff85e
Details:
I use a Rust program called Mago. It is a tool for PHP code analysis, and it uses
randas a dependency.Since Mago v1.44, compiling the
randcrate when updating Mago using:cargo-install-update install-update magoFailed with the following error:
I also tried compiling it on a fresh openSUSE install within a VM to rule out any custom config I could have on my main machine and got the same error.
As the original change in PR #1790 doesn't have the
std::namespace on the correspondent line:rand/src/distr/uniform_other.rs
Line 46 in bb1262f
So I removed it from my local source copy at
Resulting in:
And then running
cargo-install-update install-update magoSucceeds in compiling both the crate and the Mago program.
I don't have any experience with Rust. Thus, I have no idea how to test this change properly, and I am also not sure if my "fix" is a proper fix or just masquerades the problem (by reading a constant from somewhere else not intended when removing the
std::namespace).That is why I chose to open an issue and not send a PR.
If you need any further information about my setup or anything else, I am glad to provide it.