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

Use Rust 2018 and remove build.rs #824

Merged
merged 21 commits into from Jun 23, 2019
Merged

Conversation

vks
Copy link
Collaborator

@vks vks commented Jun 12, 2019

This updates the remaining code to use Rust 2018 and removes all build.rs, which are no longer necessary, because we support only Rust 1.32 and higher.

@dhardy
Copy link
Member

dhardy commented Jun 13, 2019

Thanks @vks!

Shall we add a new policy? All PRs should add a note to the changelog (unless very minor). This would save us the job of going back through PRs for the next release. (@newpavlov may like to comment too since he is also a long-term contributor.)

Edit: I see someone suggested the same thing on Reddit. Lets start that trend from here on, unless you have objections.

@vks
Copy link
Collaborator Author

vks commented Jun 13, 2019

I don't understand why the examples fail to build.

@dhardy
Copy link
Member

dhardy commented Jun 13, 2019

Me neither (I can reproduce the issue). Not much time to look into it now.

@dhardy
Copy link
Member

dhardy commented Jun 16, 2019

It's caused by adding the following code in 294d16c.

#![cfg(all(feature="alloc", not(feature="std")))]
extern crate alloc;

@dhardy
Copy link
Member

dhardy commented Jun 16, 2019

With the nightly compiler, we can (a) remove feature(alloc) (rust-lang/rust#59675), and (b) use just extern crate alloc; (without the cfg above). This appears to solve our issues.

Unfortunately (b) is incompatible with current stable compilers, leaving us stuck.

@SimonSapin landed the alloc crate stabilisation; do you have any idea why this PR fails with such an odd message? I think it must be a Rustc bug. (Just checkout the PR and build with cargo test; both stable and nightly do the same thing.)

@tesuji
Copy link

tesuji commented Jun 16, 2019

Could we force to use edition idioms by adding #![deny(rust_2018_idioms)] in crate root?

@vks
Copy link
Collaborator Author

vks commented Jun 18, 2019

@dhardy Could it also be a cargo bug related to examples?

Currently, it seems like we have to wait for feature(alloc) to become stable and increase the MSRV accordingly, before we can use Rust 2018 without regressions.

@dhardy
Copy link
Member

dhardy commented Jun 20, 2019

I don't believe it is a Cargo bug. I can extract the rustc commands from cargo test --verbose and reproduce, and I don't see anything odd about these commands. @alexcrichton any ideas?

~/projects/rand/rand$ rustc --edition=2018 --crate-name rand src/lib.rs --color always --crate-type lib --emit=dep-info,link -C debuginfo=2 --cfg 'feature="alloc"' --cfg 'feature="default"' --cfg 'feature="getrandom"' --cfg 'feature="getrandom_package"' --cfg 'feature="rand_core"' --cfg 'feature="std"' -C metadata=1b726c70baf9c429 -C extra-filename=-1b726c70baf9c429 --out-dir /home/dhardy/projects/rand/rand/target/debug/deps -L dependency=/home/dhardy/projects/rand/rand/target/debug/deps --extern getrandom_package=/home/dhardy/projects/rand/rand/target/debug/deps/libgetrandom-3257ec60faaf3040.rlib --extern libc=/home/dhardy/projects/rand/rand/target/debug/deps/liblibc-bdbdc84b2556a7c9.rlib --extern rand_chacha=/home/dhardy/projects/rand/rand/target/debug/deps/librand_chacha-6decec9409e8722c.rlib --extern rand_core=/home/dhardy/projects/rand/rand/target/debug/deps/librand_core-6c84f106de869675.rlib
~/projects/rand/rand$ rustc --edition=2018 --crate-name monte_carlo examples/monte-carlo.rs --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 --cfg 'feature="alloc"' --cfg 'feature="default"' --cfg 'feature="getrandom"' --cfg 'feature="getrandom_package"' --cfg 'feature="rand_core"' --cfg 'feature="std"' -C metadata=0d912ac65a32d291 -C extra-filename=-0d912ac65a32d291 --out-dir /home/dhardy/projects/rand/rand/target/debug/examples -L dependency=/home/dhardy/projects/rand/rand/target/debug/deps --extern getrandom_package=/home/dhardy/projects/rand/rand/target/debug/deps/libgetrandom-3257ec60faaf3040.rlib --extern libc=/home/dhardy/projects/rand/rand/target/debug/deps/liblibc-bdbdc84b2556a7c9.rlib --extern rand=/home/dhardy/projects/rand/rand/target/debug/deps/librand-1b726c70baf9c429.rlib --extern rand_chacha=/home/dhardy/projects/rand/rand/target/debug/deps/librand_chacha-6decec9409e8722c.rlib --extern rand_core=/home/dhardy/projects/rand/rand/target/debug/deps/librand_core-6c84f106de869675.rlib
error[E0432]: unresolved import `rand::distributions`
  --> examples/monte-carlo.rs:29:11
   |
29 | use rand::distributions::{Distribution, Uniform};
   |           ^^^^^^^^^^^^^ could not find `distributions` in `rand`

error[E0425]: cannot find function `thread_rng` in module `rand`
  --> examples/monte-carlo.rs:33:25
   |
33 |     let mut rng = rand::thread_rng();
   |                         ^^^^^^^^^^ not found in `rand`

warning: unused import: `Distribution`
  --> examples/monte-carlo.rs:29:27
   |
29 | use rand::distributions::{Distribution, Uniform};
   |                           ^^^^^^^^^^^^
   |
   = note: #[warn(unused_imports)] on by default

error: aborting due to 2 previous errors

Some errors occurred: E0425, E0432.
For more information about an error, try `rustc --explain E0425`.

The module is just: pub mod distributions;

@dhardy
Copy link
Member

dhardy commented Jun 20, 2019

Stranger: if I replace edition=2018 with edition=2015 in the above, then add extern crate rand; to monte-carlo.rs, I can reproduce exactly the same output.

(Setting edition = 2015 in the top Cargo.toml, then cargo clean; cargo test results in the same error, plus a similar error for the monty-hall example.)

@alexcrichton
Copy link
Contributor

The line above extern crate alloc in src/lib.rs erroneously contains a !, configuring out the entire crate by accident.

@dhardy
Copy link
Member

dhardy commented Jun 22, 2019

Remaining errors:

  • trace and debug macros not available in rand_jitter (test: cargo doc --no-deps --all --all-features)

@dhardy
Copy link
Member

dhardy commented Jun 23, 2019

All checks passed. Thanks @vks!

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.

None yet

4 participants