-
Notifications
You must be signed in to change notification settings - Fork 137
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
Conversation
src/editions/transitioning.md
Outdated
``` | ||
|
||
And that's it! Note that you do need a nightly Cargo to use `rustfix` at the |
There was a problem hiding this comment.
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!
There was a problem hiding this 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?
src/editions/transitioning.md
Outdated
|
||
```shell | ||
$ cargo +nightly install cargo-fix --git https://github.com/killercup/rustfix.git |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the official repo is https://github.com/rust-lang-nursery/rustfix
src/editions/transitioning.md
Outdated
|
||
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 |
There was a problem hiding this comment.
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"?
src/editions/transitioning.md
Outdated
## Prepare for the next edition | ||
|
||
There are some lints that can help you prepare for the next edition, but |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
I've updated this a bit. r? anyone? |
There was a problem hiding this 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
src/editions/transitioning.md
Outdated
## Installing rustfix | ||
|
||
You can get `rustfix` from crates.io. Given that you're probably using Cargo, |
There was a problem hiding this comment.
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
src/editions/transitioning.md
Outdated
|
||
|
||
* New editions may have features that are only available in the new edition. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 😆
There was a problem hiding this comment.
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."
src/editions/transitioning.md
Outdated
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
src/editions/transitioning.md
Outdated
``` | ||
|
||
This will ensure that you're enabling all of the relevant features. |
There was a problem hiding this comment.
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!
src/editions/transitioning.md
Outdated
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
src/editions/transitioning.md
Outdated
``` | ||
|
||
This will fix up all of the new warnings. Congrats! You're done! |
There was a problem hiding this comment.
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)
src/editions/transitioning.md
Outdated
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`. |
There was a problem hiding this comment.
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/
Looks great, thanks @steveklabnik! |
bf90471
to
325d3df
Compare
Thanks for the review yinz <3 |
Circle CIの有効化 -- その2
r? @alexcrichton @killercup