Skip to content

Document how to transition between editions #4

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

Merged
merged 3 commits into from
May 16, 2018
Merged

Conversation

steveklabnik
Copy link
Member

```

And that's it! Note that you do need a nightly Cargo to use `rustfix` at the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically you don't actually need a nightly Cargo for rustfix, it's just a nightly rustc currently. As an implementation detail though cargo-fix purely delegates to cargo check, which does end up transitively and effectively requiring nightly.

In any case though the +nightly on the cargo install in theory shouldn't be necessary even today!

Copy link
Member

@killercup killercup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Maybe you can also remind people to commit their changes before running cargo-fix so they easily roll back?


```shell
$ cargo +nightly install cargo-fix --git https://github.com/killercup/rustfix.git
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


And that's it! Note that you do need a nightly Cargo to use `rustfix` at the
moment; in fact, all of the edition stuff is nightly only for now. Eventually
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"nightly-only" or "nightly only"?

## Prepare for the next edition

There are some lints that can help you prepare for the next edition, but
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be worth re-emphasizing a few points here as well:

  • The 2018 edition has some features that are exclusive to it, aka not available in the 2015 edition. For example async/await.
  • It's our intention that the migration to the 2018 is as smooth an experience as possible. It's a technical breaking change so it must be opt-in, but we want to make it as easy as possible for you to opt in so you can get access to the new features. (hence cargo fix)
  • It's considered a bug if it's difficult to upgrade your crate to the 2018 edition. If you have a difficult time then a bug should be filed with either rustfix or rust-lang/rust

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, as we've just seen, for the preview you'll need to opt into some unstable features that will become stable in both 2015 and 2018 soon to actually get something that cargo-fix will fix (#![feature(crate_in_paths)], for example).

(Correct me if I'm wrong, @Manishearth)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I mentioned this in gitter. We should ask people to use #![feature(crate_in_paths)] before they trigger rustfix

We can also change https://github.com/rust-lang/rust/blob/master/src/librustc_resolve/lib.rs#L3354-L3355 to no longer require crate_in_paths, but they need to add it anyway so it's not that useful? I'm less fond of the idea of lints that suggest broken code (which is what it is until crate_in_paths stabilizes)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After some gitter discussion I've added a new step to the cheat sheet where for the preview only users will be required to list #![feature(rust_2018_preview)] in their crates they wish to migrate.

@steveklabnik
Copy link
Member Author

I've updated this a bit. r? anyone?

Copy link
Member

@killercup killercup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented on some stuff I'd clarify

## Installing rustfix

You can get `rustfix` from crates.io. Given that you're probably using Cargo,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from crates.io

well, we're actually getting it from github.com right now



* New editions may have features that are only available in the new edition.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New editions may have features that are only available in the new edition.

That sounds… obvious. How about

New editions may introduce features that are available in that form in previous editions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what @alexcrichton suggested above; the opposite is also true, idk 😆

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol, true. Okay, how about this: "New editions might change the way you write Rust -- the add syntax, language, and library features but also remove others."

For example, `async`/`await` is available in Rust 2018, but not Rust 2015.
* It's our intention that the migration to new editions is as smooth an experience
as possible. It's considered a bug if it's difficult to upgrade your crate to
Copy link
Member

@killercup killercup May 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

difficult

That is a super opaque and undefined metric. It's cool if you don't want to be more specific, but I'd add something like

What do we mean by "difficult"? Migration code in macros for example: The compiler often can't directly determine how the code might be used and thus can't provide a way to upgrade in a straightforward way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally like this sort of being opaque and undefined in the sense that if you feel it's difficult that's a bug we want to know about and fix. It'll definitely be a lot of work for us to bottom out "what makes it difficult" in some situations, but no one should ever get the impression that an edition upgrade is difficult ideally

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think for now I'd like to leave this vague. As we get closer to shipping, we'll know better what those pain points are.

```

This will ensure that you're enabling all of the relevant features.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is currently relevant and I'd add

Note that during the time the preview is available, we may continue to add/enable new features with this flag!

This would turn on those lints, and fix up the project for the 2018 edition.
If there's something that `rustfix` doesn't know how to fix automatically yet,
the warning will be printed; you'll need to fix those manually. Do so
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the [usual compiler] warning will be printed


```shell
$ cargo +nightly fix --prepare-for 2018
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assumes people use rustup -- fine but should be mentioned

```

This will fix up all of the new warnings. Congrats! You're done!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will [try to] fix

Same drill as above regarding manual fixes (can be downplayed)

feature of Cargo, so you need to enable it for things to work.

At this point, your project should compile with a regular old `cargo build`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/cargo build/cargo +nightly build/

@alexcrichton
Copy link
Member

Looks great, thanks @steveklabnik!

@steveklabnik steveklabnik merged commit b1b997b into master May 16, 2018
@steveklabnik steveklabnik deleted the upgrade-docs branch May 16, 2018 20:07
@steveklabnik
Copy link
Member Author

Thanks for the review yinz <3

tsraom pushed a commit to tsraom/edition-guide that referenced this pull request Aug 19, 2018
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.

4 participants