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

Update transitioning chapter. #255

Merged
merged 7 commits into from
Jul 20, 2021
Merged

Conversation

ehuss
Copy link
Contributor

@ehuss ehuss commented Jul 15, 2021

This updates the transitioning chapter to make it more up-to-date, and to correct some issues.

I decided to leave it with a 2018 example, since I think it is clear enough. Most of the 2021 lints are pretty obscure or complicated, and I think readers will get the gist of what it is saying. I also feel like rewriting this for every edition will be a bit tedious.

This also adds a new chapter to help people if they are having trouble, or need advanced information.

Copy link
Member

@rylev rylev left a comment

Choose a reason for hiding this comment

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

Looks wonderful!

# Advanced migration strategies

## How migrations work

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we can note again that migration works by migrates code to a state that compiles on both the current edition and the next edition. This is why you migrate, then update the edition in Cargo.toml.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, sounds good. I wanted to make it clear that it is compatible on both editions, but maybe wasn't explicit enough. I added another paragraph trying to explain why it works that way.

@ehuss
Copy link
Contributor Author

ehuss commented Jul 16, 2021

I pushed a couple more things that I forgot to include.

Copy link
Member

@rylev rylev left a comment

Choose a reason for hiding this comment

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

Still looks good. One question though

src/editions/advanced-migrations.md Outdated Show resolved Hide resolved
Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

This looks great. Left one comment about an area I think could be clarified, but I don't consider it a blocker to merging.

`macro_rules` macros can be updated if the macro is used within the same crate, but if it is exported with `#[macro_export]`, then it may not be able to fix it.
Proc macros in general cannot be fixed at all.

For example, this (contrived) macro won't get fixed when migrating to 2018.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it'd be good to talk about migrating crates, not macros.

Suggested change
For example, this (contrived) macro won't get fixed when migrating to 2018.
For example, if we migrate the crate containing the (contrived) macro `foo` to 2018, `foo` would not be automatically fixed (note though that macro hygiene, discussed below, means it is possible to migrate other crates that use `foo` to 2018 without changes).

Copy link
Contributor

Choose a reason for hiding this comment

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

This text might not actually be right, but I got a bit confused here about the details in reading it, and I imagine others might, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, yea after re-reading that section, it was pretty confusing (and misleading in places). I reworked it to hopefully make it a little clearer and more correct.

(I noticed that the keyword_idents lint doesn't work for macros at all due to the way the parser works, so cargo fix won't work even if you call the macro from the same crate.)

```

If you don't have any tests that actually call this macro, then `cargo fix --edition` won't display any warnings or errors at all.
However, it won't work when called from another crate.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
However, it won't work when called from another crate.
However, `foo` won't work when called from another crate.

@nikomatsakis nikomatsakis merged commit 4f90df3 into rust-lang:master Jul 20, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 20, 2021
Update books

## reference

6 commits in ab60513a3a5a0591e237fddff5d027a982648392..82d75cf423e4a7824fb36e73ccb18519d6900610
2021-07-05 08:27:31 -0700 to 2021-07-15 06:49:08 -0700
- fix wording/punctuation in "Lifetime bounds" (rust-lang/reference#1062)
- mention implicit `Sized` bound in more places (rust-lang/reference#1053)
-  (rust-lang/reference#1060)
- Remove inner attributes from non-block expressions. (rust-lang/reference#1051)
- Add note about the sign of the remainder (rust-lang/reference#1073)
- Clarify closure capture modes slightly (rust-lang/reference#1064)

## book

21 commits in a90f07f1e9a7fc75dc9105a6c6f16d5c13edceb0..eac55314210519238652f12b30fec9daea61f7fe
2021-07-05 14:43:12 -0400 to 2021-07-19 11:08:01 -0400
-  (rust-lang/book#2791)
- Add Deref trait to overload the deref operator in appendix table
- Revise linker installation instructions. Fixes rust-lang/book#2151.
- Clarify number literal type suffixes. Fixes rust-lang/book#1979.
- Add a note that lifetimes are coming up but aren't required
- Zip creates an iterator, not a vector. Fixes rust-lang/book#2762.
- Add Thai translation to the appendix. Connects to rust-lang/book#2636
- Derive Copy and Clone for Point to match stdlib docs example; fixes rust-lang/book#2657
- Make the definition of Option match the stdlib's, fixes rust-lang/book#2634
- Explain double quote backslash; closes rust-lang/book#2597
- Don't use the term 'anonymous struct' to fix rust-lang/book#2584
- Reword a sentence to fix rust-lang/book#2525
- Add Hindi translation. Connects to rust-lang/book#2496
- Remove unsafe Ferris designations from code. Fixes rust-lang/book#2555
- Add Traditional Chinese translation. Connects to rust-lang/book#2470
- Remove some more references to the authors field
- Make Appendix E be a link
- fix line wrapping
- remove description about the authors field
- remove the authors field
- remove the authors field

## rust-by-example

6 commits in 028f93a61500fe8f746ee7cc6b204ea6c9f42935..1db6bb483cc87ad3b424d9aba764fe622960a1be
2021-07-06 06:28:53 -0300 to 2021-07-15 06:17:42 -0300
- Updated the file destructure_tuple.md (rust-lang/rust-by-example#1452)
- Fix nomenclature around methods (rust-lang/rust-by-example#1450)
- std_misc/path.md: update `Show` to `Display` (rust-lang/rust-by-example#1449)
- Fix up github action (rust-lang/rust-by-example#1451)
- Remove github pages
- Support GitHub Actions (rust-lang/rust-by-example#1330)

## rustc-dev-guide

2 commits in 60e282559104035985331645907c3d9f842312c5..93422c21baca585dc88357ec886a48f6ddc7d665
2021-07-05 11:21:03 -0400 to 2021-07-13 12:45:58 -0400
- Update for merge of CrateDisambiguator into StableCrateId
- Minor capitalization fix (rust-lang/rustc-dev-guide#1170)

## edition-guide

8 commits in 5d57b3832f8d308a9f478ce0a69799548f27ad4d..af696ce8ea526445590ae0ca66a8128d2a95a69a
2021-07-05 10:33:32 +0200 to 2021-07-20 11:38:03 -0400
- Add migration section for panic-macro-consistency (rust-lang/edition-guide#258)
- Update transitioning chapter. (rust-lang/edition-guide#255)
- Add details on migrating the Cargo feature resolver. (rust-lang/edition-guide#259)
- Improve panic macro consistency summary (rust-lang/edition-guide#256)
- Add migration details to or-patterns guide (rust-lang/edition-guide#252)
- Add migration section to into-iterator (rust-lang/edition-guide#253)
- Add Rust 2021 prelude migration details (rust-lang/edition-guide#251)
- Provide more information about disjoint capture in closures and migration instructions (rust-lang/edition-guide#246)

## embedded-book

1 commits in 506840eb73b0749336e1d5274e16d6393892ee82..09986cd352404eb4659db44613b27cac9aa652fc
2021-06-24 00:01:32 +0000 to 2021-07-18 19:26:46 +0000
- Stop referring to the alloc crate as unstable  (rust-embedded/book#297)
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.

3 participants