owned this note
owned this note
Published
Linked with GitHub
# :fireworks: Rust Edition 2021
This document will be turned into tracking issues and an RFC for more structure at some point. For now, we'll try to collect everything here. Please also add ideas that are not very concrete yet, just so we don't miss anything.
---
**Discussion: [`#edition` on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/268952-edition)**
---
## :motorway: Milestone planning
**December 2020:**
- [x] :pencil2: Start this document.
- [x] :incoming_envelope: Ask teams to check this document and add things.
- [x] :calendar: Preliminary roadmap with rough dates.
- [x] :fireworks: Add unstable `rustc --edition=2021`: [#79576](https://github.com/rust-lang/rust/pull/79576)
**January 2021:**
- [x] :point_up: Make sure all relevant teams have brought attention to the 2021 edition in one of their meetings.
- [x] compiler
- [x] lang
- [x] libs
- [x] rustdoc
- [x] cargo
- [x] :gear: Add initial support for edition 2021 to all tools.
(Just to make them aware of the new edition. Any edition-specific changes will be added later as part of that edition change itself.)
- [x] :package: Add `edition = "2021"` to `cargo`: [cargo#8922](https://github.com/rust-lang/cargo/pull/8922)
- [x] 🧹 Add edition 2021 to `rustfmt`: [rustfmt#4618](https://github.com/rust-lang/rustfmt/pull/4618)
- [x] :symbols: Add edition 2021 to `rls`: [rls#1709](https://github.com/rust-lang/rls/pull/1709)
- [x] :racing_car: Add edition 2021 to `racer`: [racer#1152](https://github.com/racer-rust/racer/pull/1152)
- [x] :paperclip: Add edition 2021 to `clippy`: [rust-clippy#6530](https://github.com/rust-lang/rust-clippy/pull/6530)
- [x] :mag: Add edition 2021 to `rust-analyzer`: [rust-analyzer#7123](https://github.com/rust-analyzer/rust-analyzer/pull/7123)
- [x] ~~:book: Add `edition2021` to `rustdoc`~~: No change required.
- [ ] :speech_balloon: Make sure the relevant teams discuss each of the proposed changes.
- [ ] compiler
- [ ] lang
- [ ] libs
- [ ] rustdoc
- [ ] cargo
**February 2021:**
- [ ] :scroll: Final list of changes. All proposed changes have:
- [ ] An approved RFC
- [ ] Migration+idiom lint plan
- [ ] Partial implementation or plan for implementation
**March 2021:**
**April 2021:**
**May 2021:**
- [ ] :computer: All proposed changes implemented and available in nightly.
**June 2021:**
- [ ] :warning: All lints implemented on nightly and tested on crater.
**July 2021:**
- [ ] :busts_in_silhouette: Announce start of public testing.
**August 2021:**
- [ ] :loudspeaker: Finish marketing materials, docs, etc.
- [ ] Blog post(s)
- [ ] Edition guide
**September 2021:**
- [x] :tada: Stabilize `--edition=2021` on nightly (1.56).
**October 2021:**
- [x] :checkered_flag: `--edition=2021` available on stable in Rust 1.56.
---
## :bookmark_tabs: Edition Changes
<!-- Empty template:
### :question: Title
| Team(s) | Status | RFC | Tracking issue | Who |
| ------- | ------ | --- | -------------- | ------ |
| `libs`, `lang` | Incomplete idea | None (yet?) | None yet | ? |
-->
### :heavy_check_mark: Unify `std::panic` and `core::panic`
| Team(s) | Status | RFC | Tracking issue | Who |
| ------- | ------ | --- | -------------- | ------ |
| `libs`, `lang` | RFC accepted | [RFC 3007](https://github.com/rust-lang/rfcs/pull/3007) | [#80162](https://github.com/rust-lang/rust/issues/80162) | Mara |
This makes `panic!()` consistent with `print!()`:
`panic!("{}")` becomes an error, and `panic!("{x}")` will format `x` once implicit formatting arguments are stabilized.
To do:
- Implement things. See tracking issue.
### :pencil: Promote 2018 warn lints to deny
| Team(s) | Status | RFC | Tracking issue | Who |
| ------- | ------ | --- | -------------- | ------ |
| `compiler` | - | - | [#80165](https://github.com/rust-lang/rust/issues/80165) | Ryan Levick |
To do:
- Decide on final list of promotions
- Implementation
### :question: Forbid `bare_trait_objects`
| Team(s) | Status | RFC | Tracking issue | Who |
| ------- | ------ | --- | -------------- | ------ |
| `lang` | Not yet decided | None (yet?) | [lang-team#65](https://github.com/rust-lang/lang-team/issues/65) | t-lang |
- Context: [this Zulip topic](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/bare_trait_objects.202021).
To do:
- Make decision
- Implementation
### :hammer_and_wrench: Change Cargo's feature resolver to `resolver = "2"` by default for edition 2021
| Team(s) | Status | RFC | Tracking issue | Who |
| ------- | ------ | --- | -------------- | ------ |
| `cargo` | Accepted | - | [cargo#9048](https://github.com/rust-lang/cargo/issues/9048) | ? |
### :pencil: Edition specific or-patterns
| Team(s) | Status | RFC | Tracking issue | Who |
| ------- | ------ | --- | -------------- | ------ |
| `lang` | Team consensus | [RFC 2535](https://github.com/rust-lang/rfcs/pull/2535) | [#54883](https://github.com/rust-lang/rust/issues/54883) | mark-i-m |
- Consensus from t-lang: [comment on #54883](https://github.com/rust-lang/rust/issues/54883#issuecomment-745509090)
- Implementation: [#80100](https://github.com/rust-lang/rust/pull/80100)
- Stabilization FCP: [#79278](https://github.com/rust-lang/rust/pull/79278#issuecomment-773032487)
### :question: Disjoint captures in closures
| Team(s) | Status | RFC | Tracking issue | Who |
| ------- | ------ | --- | -------------- | ------ |
| `lang` | ? | [RFC 2229](https://github.com/rust-lang/rfcs/pull/2229) | [#53488](https://github.com/rust-lang/rust/issues/53488) | ? |
- Migrations needed for changes in drop order and around auto traits
- Update: https://hackmd.io/wPs-tHJZR1Cj9j_vwsxwbw?view
- Implentation Status: [Github Project Board](https://github.com/rust-lang/project-rfc-2229/projects/1)
### :heavy_check_mark: Fix `cargo fix --edition` for edition 2021
| Team(s) | Status | RFC | Tracking issue | Who |
| ------- | ------ | --- | -------------- | ------ |
| `cargo` | Implemented | N/A | [cargo#9047](https://github.com/rust-lang/cargo/issues/9047) | ? |
### :pencil: Prelude changes
| Team(s) | Status | RFC | Tracking issue | Who |
| ------- | ------ | --- | -------------- | ------ |
| `libs`, `lang` | Incomplete idea | [RFC 3090](https://github.com/rust-lang/rfcs/pull/3090) | [#65512](https://github.com/rust-lang/rust/issues/65512/) | t-libs? |
- Add `TryFrom` / `TryInto`
- Add other things?
- Needs a compatibility warning (See [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/268952-edition/topic/Prelude.202021/near/221214002))
- Prioritization of glob import method resolution the same as item resolution (language change)
- Doesn't need to be edition-specific:
- :thought_balloon: Add `std::iter`? ([#80216](https://github.com/rust-lang/rust/issues/80216))
- Might not need to be edition-specific:
(but have potential breakage from trait method conflicts, so would probably need at least a crater run)
- :thought_balloon: Add `ops::Not`? ([thread on Internals](https://internals.rust-lang.org/t/the-is-not-empty-method-as-more-clearly-alternative-for-is-empty/10612/8))
- :thought_balloon: Add `Debug` and `Display` ([#80360](https://github.com/rust-lang/rust/issues/80360) and [Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/268952-edition/topic/Edition.202021/near/220445708))
- :thought_balloon: Add `Hash` ([#80361](https://github.com/rust-lang/rust/issues/80361) and [Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/268952-edition/topic/Edition.202021/near/220527514))
To do:
- Complete the list of changes (see tracking issue)
- Implement glob and prelude import changes in compiler? Compatibility warning? (RFC/MCP first?)
- Implement new prelude
### :question: Removing ``#[macro_export]``
| Team(s) | Status | RFC | Tracking issue | Who |
| ------- | ------ | --- | -------------- | ------ |
| `lang` | Not yet decided | - | None yet | petrochenkov? |
To do:
- Support `pub` on `macro_rules!`: [#78166](https://github.com/rust-lang/rust/pull/78166)
- Remove `#[macro_export]`
- Could also be just a deprecation warning.
### :question: `IntoIterator` for `[T; N]`
| Team(s) | Status | RFC | Tracking issue | Who |
| ------- | ------ | --- | -------------- | ------ |
| `libs` | Incomplete idea | None (yet?) | None yet | Mara |
- Context: [this comment](https://github.com/rust-lang/rust/pull/65819#issuecomment-700131423) and a few more after that one.
### :question: Replace `#[rustc_args_required_const(..)]` with const generics
| Team(s) | Status | RFC | Tracking issue | Who |
| ------- | ------ | --- | -------------- | ------ |
| `libs`, `lang` | Incomplete idea | None (yet?) | None yet | Amanieu |
- Context: [this comment](https://github.com/rust-lang/stdarch/issues/248#issuecomment-756240852), and also the rest of that issue.
- Could also be a warning on all editions. (So, not deny on 2021.)
### :pencil: Reserve new keywords
| Team(s) | Status | RFC | Tracking issue | Who |
| ------- | ------ | --- | -------------- | ------ |
| `lang` | Incomplete idea | None | None | t-lang? |
To do:
- List keywords to reserve
- Implement it
### :thought_balloon: New/fixed range types (make `a..b` Copy)
| Team(s) | Status | RFC | Tracking issue | Who |
| ------- | ------ | --- | -------------- | ------ |
| `libs`, `lang` | Incomplete idea | None | None | t-libs? sfackler? |
To do:
- Investigate alternative solutions, see [rfcs#2848](https://github.com/rust-lang/rfcs/issues/2848)
- Decide on the best solution
- Implement it
### :pencil: Change rustdoc lints to have a tool prefix and make changing the names deny-by-default
| Team(s) | Status | RFC | Tracking issue | Who |
| ------- | ------ | --- | -------------- | ------ |
| `rustdoc` | waiting on FCP (see [Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/What.20is.20the.20policy.20for.20new.20lints.3F)) | - | - | Joshua Nelson |
To do:
- Add `rustdoc::` lints and suggest changing builtin rustdoc lints to use `rustdoc::` prefix ([#80527](https://github.com/rust-lang/rust/pull/80527))
- Add a deny-by-default lint to rename the old lints
- Cohesive lints suggests all tools should be namespacing lints, is this true?
Does this actually need to be deny by default? Warn-by-default seems good enough; it wouldn't allow simplifying code since the compiler has to support all editions.
### :question: Run doctests in a single binary?
| Team(s) | Status | RFC | Tracking issue | Who |
| ------- | ------ | --- | -------------- | ------ |
| `rustdoc` | Incomplete idea | - | [#75341](https://github.com/rust-lang/rust/issues/75341) | - |
It's unclear whether we should do this. Preferably we could find a smaller hammer to throw at this that still gives performance gains.
### :question: Separate compile-time from run-time working directory for doctests?
| Team(s) | Status | RFC | Tracking issue | Who |
| ------- | ------ | --- | -------------- | ------ |
| `rustdoc` | Incomplete idea | - | [#8993](https://github.com/rust-lang/cargo/issues/8993) | - |
Similar to doctests in a single binary, I would prefer to find a smaller hammer that doesn't require breaking changes.
### :question: Change Rustdoc's URL structure?
| Team(s) | Status | RFC | Tracking issue | Who |
| ------- | ------ | --- | -------------- | ------ |
| `rustdoc` | Incomplete idea | [rfcs#2988](https://github.com/rust-lang/rfcs/pull/2988) | [#25879](https://github.com/rust-lang/rust/issues/25879), [#80504](https://github.com/rust-lang/rust/issues/80504), [docs.rs#1055](https://github.com/rust-lang/docs.rs/issues/1055), [#55160](https://github.com/rust-lang/rust/issues/55160), [#71912](https://github.com/rust-lang/rust/issues/71912) | Joshua Nelson |
This change might be too big even for an edition. It also needs better planning of what the end result is - if we're changing URLs anyway, it probably makes sense to solve the case-insensitive files issue at the same time.
---
## Notes
..
## Links
- [Project Board: Edition 2021](https://github.com/orgs/rust-lang/projects/7)
- [RFC 2052: Editions](https://github.com/rust-lang/rfcs/blob/master/text/2052-epochs.md)
- [RFC 2966: Edition 2021 and Beyond (Closed)](https://github.com/rust-lang/rfcs/pull/2966)