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

manually test converting a bunch of crates to rust 2018 preview #51180

Closed
11 tasks done
nikomatsakis opened this issue May 29, 2018 · 10 comments
Closed
11 tasks done

manually test converting a bunch of crates to rust 2018 preview #51180

nikomatsakis opened this issue May 29, 2018 · 10 comments
Labels
A-rust-2018-preview Area: The 2018 edition preview C-tracking-issue Category: A tracking issue for an RFC or an unstable feature.

Comments

@nikomatsakis
Copy link
Contributor

nikomatsakis commented May 29, 2018

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

@kennytm kennytm added C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. A-rust-2018-preview Area: The 2018 edition preview labels May 29, 2018
@teiesti
Copy link
Contributor

teiesti commented May 29, 2018

crates that work:

crates that don't work:

$ 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
$ 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

@zackmdavis
Copy link
Member

The instructions should include cargo test, which typically runs code that is cfg'd out of a normal cargo build.


didn't work:

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 uses 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 uses of linalg were rewritten).

@AdamNiederer
Copy link

AdamNiederer commented May 30, 2018

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.

@mati865
Copy link
Contributor

mati865 commented May 30, 2018

Clippy (branch here) builds and passes tests after changing deprecated rustfmt annotation.

@nikomatsakis
Copy link
Contributor Author

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.

@achanda
Copy link
Contributor

achanda commented May 30, 2018

ipnetwork works fine!

@mkpankov
Copy link
Contributor

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.

Branch.

@steveklabnik
Copy link
Member

steveklabnik commented May 31, 2018

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.

thanks has... problems: https://gist.github.com/steveklabnik/31e1f5b576aa2ed13e5a671c48d03cc0

@Dylan-DPC-zz
Copy link

UUID works!

@Mark-Simulacrum
Copy link
Member

Thanks everyone for the feedback here; we've filed some issues to track them and will be working to fix the outstanding bugs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rust-2018-preview Area: The 2018 edition preview C-tracking-issue Category: A tracking issue for an RFC or an unstable feature.
Projects
None yet
Development

No branches or pull requests