manually test converting a bunch of crates to rust 2018 preview
Closed this issue · 10 comments
What is this?
This is a meta issue for tracking manual testing of "upgrading" crates to Rust 2018 preview. We're hoping to kick the tires for a lot of crates. There's a list below, but feel free to test your own additions and leave comments.
How to test a crate
The steps are described here in the transition guide, but here is a cheat sheet:
- Update nightly:
rustup update nightly
- Install rustfix if you haven't already:
cargo install cargo-fix --git https://github.com/rust-lang-nursery/rustfix
- Clone the crate in question
- Verify that it builds (if not, that's some other problem we better fix first):
cargo +nightly build
- Edit
src/lib.rs
and add#![feature(rust_2018_preview)]
- Verify that it still builds:
cargo +nightly build
- Create a commit, perhaps on a new branch (recommended name:
rust-2018-migration
):git commit -a -m 'add rust_2018_preview feature'
- Run rustfix:
cargo +nightly fix --prepare-for 2018
- Verify that it still builds:
cargo +nightly build
- Create another commit on that same branch:
git commit -a -m 'run rustfix
- Update to the new edition by adding the following to
Cargo.toml
:cargo-features = ["edition"]
package.edition = "2018"
- Verify that it still builds:
cargo +nightly build
- Create another commit on that same branch:
git commit -a -m 'upgraded to new edition
If all of this works, great! Leave a comment below, including a link to the commit or branch with the changes.
If you encounter an error due to the migration, leave a comment below with a link to the commit and the error!
Crate listing
- ✅ clap (branch here)
- ✅ futures-core and futures-io 0.2.x (branch here)
- ✅ cargo (branch here)
- ✅ bitflags (comment)
- ✅ serde (comment)
- ❌ libc (comment — #51210
- ❌ rand (comment — opened #51209
- ❌ rusty-machine (comment) — caveat, build works,
#[cfg(test)]
code fails, filed #51208 - ❌ faster (comment) — #51211
- ✅ clippy (comment)
- ✅ ipnetwork (comment)
crates that work:
- bitflags (branch here)
- serde (branch here)
crates that don't work:
- libc (branch here)
$ cargo +nightly build
Compiling libc v0.2.41 (file:///home/tobias/dev/libc)
error[E0463]: can't find crate for `dox`
--> src/macros.rs:44:16
|
44 | impl ::dox::Copy for $i {}
| ^^^ can't find crate
|
::: src/unix/mod.rs:19:1
|
19 | / s! {
20 | | pub struct group {
21 | | pub gr_name: *mut crate::c_char,
22 | | pub gr_passwd: *mut crate::c_char,
... |
186 | | }
187 | | }
| |_- in this macro invocation
error: aborting due to previous error
- rand (branch here)
$ cargo +nightly build
Compiling rand v0.5.0 (file:///home/tobias/dev/rand)
error[E0463]: can't find crate for `distributions`
--> src/distributions/uniform.rs:104:5
|
104 | use distributions::Distribution;
| ^^^^^^^^^^^^^ can't find crate
error: aborting due to previous error
The instructions should include cargo test
, which typically runs code that is cfg'd out of a normal cargo build
.
didn't work:
- rusty-machine (branch tip)
Build works, but tests fail to compile with two errors:
zmd@ReflectiveCoherence:~/Code/rusty-machine$ cargo +nightly test
Compiling rusty-machine v0.5.4 (file:///home/zmd/Code/rusty-machine)
error[E0463]: can't find crate for `rm`
--> tests/learning/dbscan.rs:1:5
|
1 | use rm::linalg::Matrix;
| ^^ can't find crate
error: aborting due to previous error
For more information about this error, try `rustc --explain E0463`.
error[E0463]: can't find crate for `linalg`
--> src/data/transforms/minmax.rs:195:9
|
195 | use linalg::Matrix;
| ^^^^^^ can't find crate
error: aborting due to previous error
For more information about this error, try `rustc --explain E0463`.
error: Could not compile `rusty-machine`.
warning: build failed, waiting for other jobs to finish...
error: Could not compile `rusty-machine`.
To learn more, run the command again with --verbose.
For the first error, we have a tests/
directory that use
s the main crate under the alias rm
, and it looks like rustfix/diagnostics doesn't understand that it's an alias rather than a crate literally named rm
?
For the second error, we have a use
of the crate-local linalg
that for whatever reason wasn't rewritten as crate::linalg
(even though other use
s of linalg
were rewritten).
Failing: https://github.com/AdamNiederer/faster/commits/rust-2018-migration
$ cargo build
Compiling faster v0.4.3
error[E0463]: can't find crate for `core_or_std`
--> src/intrin/eq.rs:58:25
|
58 | use core_or_std::mem::transmute;
| ^^^^^^^^^^^ can't find crate
...
79 | / rust_fallback_eq! {
80 | | impl Eq for u8x16 where "sse2" {
81 | | eq_mask, eq => u8x16, u8, _mm_cmpeq_epi8(), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];
82 | | }
83 | | }
| |_- in this macro invocation
error: aborting due to previous error
For more information about this error, try `rustc --explain E0463`.
error: Could not compile `faster`.
To learn more, run the command again with --verbose.
It looks like cargo fix
isn't applying a crate::
prefix to my custom core/std module in a few cases. Manually fixing the imports fixes the build. It looks like cargo fix
makes no attempt to fix imports in test modules, so the tests are still broken.
Clippy (branch here) builds and passes tests after changing deprecated rustfmt annotation.
Wow, thanks all =) I updated the issue with notes and filed bugs where appropriate. One point I wanted to make: the transition is not meant to necessarily be perfect, since it is known that there will be edge cases — especially around #[cfg]
and macro code — that we cannot handle. That said, we need a better story, particularly around #[cfg(test)]
code, which is obviously super common. So I've filed #51208 to discuss that a bit more generally.
hlua doesn't migrate:
➜ hlua git:(rust-2018-migration) ✗ cargo +nightly build
Compiling hlua v0.4.1 (file:///home/mkpankov/projects/hlua/hlua)
error[E0463]: can't find crate for `ffi`
--> hlua/src/any.rs:1:5
|
1 | use ffi;
| ^^^ can't find crate
error: aborting due to previous error
For more information about this error, try `rustc --explain E0463`.
error: Could not compile `hlua`.
To learn more, run the command again with --verbose.
I decided "go big or go home", went big, and ... won the game. I dunno where this metaphor is going.
Anyway, Cargo works! I'm going to test some more crates and update this comment as they compile.
dir-diff
works (funny enough, with no changes)- the intermezzOS kernel works
semver
workssemver-parser
workssimple-server
works
thanks has... problems: https://gist.github.com/steveklabnik/31e1f5b576aa2ed13e5a671c48d03cc0
UUID works!
Thanks everyone for the feedback here; we've filed some issues to track them and will be working to fix the outstanding bugs.