Skip to content

Commit 1fcf1e3

Browse files
authored
Merge pull request #2683 from integer32llc/epoch-to-edition
META: Replace "epoch" with "edition"
2 parents 496a954 + 6197c26 commit 1fcf1e3

File tree

7 files changed

+181
-179
lines changed

7 files changed

+181
-179
lines changed

text/2052-epochs.md

Lines changed: 108 additions & 108 deletions
Large diffs are not rendered by default.

text/2103-tool-attributes.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,10 @@ Although the mechanism for opt-in for the long-term solution is unspecified, the
218218
actual usage of tool attributes seems pretty clear. Therefore we can be reasonably
219219
confident that this proposal is forward-compatible in its syntax, etc.
220220

221-
For the white-listed tools, will their names be implicitly imported in the long-
222-
term solution? One could imagine either leaving them implicit (similar to the
223-
libraries prelude) or using warning cycles or an epoch to move them to explicit
224-
opt-in.
221+
For the white-listed tools, will their names be implicitly imported in the
222+
long-term solution? One could imagine either leaving them implicit (similar to
223+
the libraries prelude) or using warning cycles or an edition to move them to
224+
explicit opt-in.
225225

226226

227227
# Drawbacks

text/2113-dyn-trait-syntax.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
# Summary
77
[summary]: #summary
88

9-
Introduce a new `dyn Trait` syntax for trait objects using a contextual `dyn` keyword, and deprecate "bare trait" syntax for trait objects. In a future epoch, `dyn` will become a proper keyword and a lint against bare trait syntax will become deny-by-default.
9+
Introduce a new `dyn Trait` syntax for trait objects using a contextual `dyn` keyword, and deprecate "bare trait" syntax for trait objects. In a future edition, `dyn` will become a proper keyword and a lint against bare trait syntax will become deny-by-default.
1010

1111
# Motivation
1212
[motivation]: #motivation
1313

1414
### In a nutshell
1515

16-
The current syntax is often ambiguous and confusing, even to veterans, and favors a feature that is not more frequently used than its alternatives, is sometimes slower, and often cannot be used at all when its alternatives can. By itself, that's not enough to make a breaking change to syntax that's already been stabilized. Now that we have epochs, it won't have to be a breaking change, but it will still cause significant churn. However, impl Trait is going to require a significant shift in idioms and teaching materials all on its own, and "dyn Trait vs impl Trait" is much nicer for teaching and ergonomics than "bare trait vs impl Trait", so this author believes it is worthwhile to change trait object syntax too.
16+
The current syntax is often ambiguous and confusing, even to veterans, and favors a feature that is not more frequently used than its alternatives, is sometimes slower, and often cannot be used at all when its alternatives can. By itself, that's not enough to make a breaking change to syntax that's already been stabilized. Now that we have editions, it won't have to be a breaking change, but it will still cause significant churn. However, impl Trait is going to require a significant shift in idioms and teaching materials all on its own, and "dyn Trait vs impl Trait" is much nicer for teaching and ergonomics than "bare trait vs impl Trait", so this author believes it is worthwhile to change trait object syntax too.
1717

1818
Motivation is the key issue for this RFC, so let's expand on some of those claims:
1919

@@ -74,15 +74,15 @@ The functionality of `dyn Trait` is identical to today's trait object syntax.
7474

7575
### Migration
7676

77-
On the current epoch:
77+
On the current edition:
7878
- The `dyn` keyword will be added, and will be a contextual keyword
7979
- A lint against bare trait syntax will be added
8080

81-
In the next epoch:
81+
In the next edition:
8282
- `dyn` becomes a real keyword, uses of it as an identifier become hard errors
8383
- The bare trait syntax lint is raised to deny-by-default
8484

85-
This follows the policy laid out in the epochs RFC, where a hard error is "only available when the deprecation is expected to hit a relatively small percentage of code." Adding the `dyn` keyword is unlikely to affect much code, but removing bare trait syntax will clearly affect a lot of code, so only the latter change is implemented as a deny-by-default lint.
85+
This follows the policy laid out in the editions RFC, where a hard error is "only available when the deprecation is expected to hit a relatively small percentage of code." Adding the `dyn` keyword is unlikely to affect much code, but removing bare trait syntax will clearly affect a lot of code, so only the latter change is implemented as a deny-by-default lint.
8686

8787
# Drawbacks
8888
[drawbacks]: #drawbacks
@@ -104,7 +104,7 @@ This author believes that `dyn` is a better choice because the notion of "dynami
104104

105105
We could also use a more radical syntax for trait objects. `Object<Trait>` was suggested on the original RFC thread but didn't gain much traction, presumably because it adds more "noise" than a keyword and is arguably misleading.
106106

107-
Finally, we could repurpose bare trait syntax for something other than trait objects. It's been frequently suggested in the past that impl Trait would be a far better candidate for bare trait syntax than trait objects. Even this RFC's motivation section indirectly argues for this, e.g. impl Trait does work with all traits and does not carry a runtime cost, unlike trait objects. However, this RFC does not propose repurposing bare trait syntax yet, only deprecating and removing it. This author believes dyn Trait is worth adding even if we never repurpose bare trait, and repurposing it has some significant downsides that dyn Trait does not (such as creating the possibility of code that compiles in two different epochs with radically different semantics). This author believes the repurposing debate should come later, probably after impl Trait and dyn Trait have been stabilized.
107+
Finally, we could repurpose bare trait syntax for something other than trait objects. It's been frequently suggested in the past that impl Trait would be a far better candidate for bare trait syntax than trait objects. Even this RFC's motivation section indirectly argues for this, e.g. impl Trait does work with all traits and does not carry a runtime cost, unlike trait objects. However, this RFC does not propose repurposing bare trait syntax yet, only deprecating and removing it. This author believes dyn Trait is worth adding even if we never repurpose bare trait, and repurposing it has some significant downsides that dyn Trait does not (such as creating the possibility of code that compiles in two different editions with radically different semantics). This author believes the repurposing debate should come later, probably after impl Trait and dyn Trait have been stabilized.
108108

109109
# Unresolved questions
110110
[unresolved]: #unresolved-questions

text/2115-argument-lifetimes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ impl<T> VecIter<'_, T> { ... }
277277
# Reference-level explanation
278278
[reference-level-explanation]: #reference-level-explanation
279279

280-
**Note: these changes are designed to *not* require a new epoch**. They do
280+
**Note: these changes are designed to *not* require a new edition**. They do
281281
expand our naming style lint, however.
282282

283283
## Lifetimes in `impl` headers

text/2126-path-clarity.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ This RFC seeks to clarify and streamline Rust's story around paths and visibilit
1313
- The `crate` keyword also acts as a visibility modifier, equivalent to today's `pub(crate)`. Consequently, uses of bare `pub` on items that are not actually publicly exported are linted, suggesting `crate` visibility instead.
1414
- A `foo.rs` and `foo/` subdirectory may coexist; `mod.rs` is no longer needed when placing submodules in a subdirectory.
1515

16-
**These changes do not require a new epoch**. The new features are purely additive. They can ship with **allow-by-default** lints, which can gradually be moved to warn-by-default and deny-by-default over time, as better tooling is developed and more code has actively made the switch.
16+
**These changes do not require a new edition**. The new features are purely additive. They can ship with **allow-by-default** lints, which can gradually be moved to warn-by-default and deny-by-default over time, as better tooling is developed and more code has actively made the switch.
1717

1818
*This RFC incorporates some text written by @withoutboats and @cramertj, who have both been involved in the long-running discussions on this topic.*
1919

20-
[new epoch]: https://github.com/rust-lang/rfcs/pull/2052
20+
[new edition]: https://github.com/rust-lang/rfcs/pull/2052
2121

2222
# Motivation
2323
[motivation]: #motivation
@@ -447,7 +447,7 @@ The actual changes in this RFC are fairly small tweaks to the current module
447447
system; most of the complexity comes from the migration plans.
448448

449449
The proposed migration plan is minimally disruptive; **it does not require an
450-
epoch**.
450+
edition**.
451451

452452
## Basic changes
453453

@@ -507,11 +507,11 @@ and Cargo/the ambient build system is needed.
507507
This approach is designed for backwards compatibility, but it means that you
508508
cannot have a top-level module and an external crate with the same
509509
name. Allowing that would require all fully-qualified paths into the current
510-
crate to start with `crate`, which can only be done on a future epoch. We can
510+
crate to start with `crate`, which can only be done on a future edition. We can
511511
and should consider making such a change eventually, but it is not required for
512512
this RFC.
513513

514-
[epoch]: https://github.com/rust-lang/rfcs/pull/2052
514+
[edition]: https://github.com/rust-lang/rfcs/pull/2052
515515
[macros 2.0]: https://github.com/rust-lang/rfcs/blob/master/text/1561-macro-naming.md#importing-macros
516516
[previous RFC]: https://github.com/rust-lang/rfcs/pull/2088
517517

@@ -574,14 +574,14 @@ motivation. The crucial insight of the design is that, by making absolute paths
574574
unambiguous about which crate they draw from, we can solve a number of
575575
confusions and papercuts with the module system.
576576

577-
## Epoch-based migration story
577+
## Edition-based migration story
578578

579-
We can avoid the need for fallback in resolution by leveraging epochs instead.
580-
On the current epoch, we would make `crate::` paths available and start warning
581-
about *not* using them for crate-internal paths, but we would not issue warnings
582-
about `extern crate`. In the next epoch, we would change absolute path
583-
interpretations, such that warning-free code on the previous epoch would
584-
continue to compile and have the same meaning.
579+
We can avoid the need for fallback in resolution by leveraging editions
580+
instead. On the current edition, we would make `crate::` paths available and
581+
start warning about *not* using them for crate-internal paths, but we would not
582+
issue warnings about `extern crate`. In the next edition, we would change
583+
absolute path interpretations, such that warning-free code on the previous
584+
edition would continue to compile and have the same meaning.
585585

586586
## Bike-sheddy choices
587587

@@ -652,6 +652,6 @@ ideas off into a separate *experimental* RFC:
652652
# Unresolved questions
653653
[unresolved]: #unresolved-questions
654654

655-
- How should we approach migration? Via a fallback, as proposed, or via epochs?
656-
It is probably best to make this determination with more experience,
655+
- How should we approach migration? Via a fallback, as proposed, or via
656+
editions? It is probably best to make this determination with more experience,
657657
e.g. after we have a `rustfix` tool in hand.

text/2151-raw-identifiers.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@
77
[summary]: #summary
88

99
Add a raw identifier format `r#ident`, so crates written in future language
10-
epochs/versions can still use an older API that overlaps with new keywords.
10+
editions/versions can still use an older API that overlaps with new keywords.
1111

1212
# Motivation
1313
[motivation]: #motivation
1414

15-
One of the primary examples of breaking changes in the epoch RFC is to add new
16-
keywords, and specifically `catch` is the first candidate. However, since
17-
that's seeking crate compatibility across epochs, this would leave a crate in a
18-
newer epoch unable to use `catch` identifiers in the API of a crate in an older
19-
epoch. [@matklad found] 28 crates using `catch` identifiers, some public.
15+
One of the primary examples of breaking changes in the edition RFC is to add
16+
new keywords, and specifically `catch` is the first candidate. However, since
17+
that's seeking crate compatibility across editions, this would leave a crate in
18+
a newer edition unable to use `catch` identifiers in the API of a crate in an
19+
older edition. [@matklad found] 28 crates using `catch` identifiers, some
20+
public.
2021

2122
A raw syntax that's *always* an identifier would allow these to remain
2223
compatible, so one can write `r#catch` where `catch`-as-identifier is needed.
@@ -57,14 +58,14 @@ they are mentioned, making them cumbersome to both the developer and users.
5758
Usually an alternate is preferable: `crate` -> `krate`, `const` -> `constant`,
5859
etc.
5960

60-
However, new Rust epochs may add to the list of reserved keywords, making a
61-
formerly legal identifier now interpreted otherwise. Since compatibility is
62-
maintained between crates of different epochs, this could mean that code written
63-
in a new epoch might not be able to name an identifier in the API of another
64-
crate. Using a raw identifier, it can still be named and used.
61+
However, new Rust editions may add to the list of reserved keywords, making a
62+
formerly legal identifier now interpreted otherwise. Since compatibility is
63+
maintained between crates of different editions, this could mean that code
64+
written in a new edition might not be able to name an identifier in the API of
65+
another crate. Using a raw identifier, it can still be named and used.
6566

6667
```rust
67-
//! baseball.rs in epoch 2015
68+
//! baseball.rs in edition 2015
6869
pub struct Ball;
6970
pub struct Player;
7071
impl Player {
@@ -74,7 +75,7 @@ impl Player {
7475
```
7576

7677
```rust
77-
//! main.rs in epoch 2018 -- `catch` is now a keyword!
78+
//! main.rs in edition 2018 -- `catch` is now a keyword!
7879
use baseball::*;
7980
fn main() {
8081
let mut player = Player;
@@ -107,9 +108,10 @@ let bar = r#foo * 2;
107108
[alternatives]: #alternatives
108109

109110
If we don't have any way to refer to identifiers that were legal in prior
110-
epochs, but later became keywords, then this may hurt interoperability between
111-
crates of different epochs. The `r#ident` syntax enables interoperability, and
112-
will hopefully invoke some intuition of being raw, similar to raw strings.
111+
editions, but later became keywords, then this may hurt interoperability
112+
between crates of different editions. The `r#ident` syntax enables
113+
interoperability, and will hopefully invoke some intuition of being raw,
114+
similar to raw strings.
113115

114116
The `br#ident` syntax is also possible, but I see no advantage over `r#ident`.
115117
Identifiers don't need the same kind of distinction as `str` and `[u8]`.
@@ -153,12 +155,12 @@ Java also allows Unicode escapes, but they don't avoid keywords.
153155
For some new keywords, there may be contextual mitigations. In the case of
154156
`catch`, it couldn't be a fully contextual keyword because `catch { ... }` could
155157
be a struct literal. That context might be worked around with a path, like
156-
`old_epoch::catch { ... }` to use an identifier instead. Contexts that don't
158+
`old_edition::catch { ... }` to use an identifier instead. Contexts that don't
157159
make sense for a `catch` expression can just be identifiers, like `foo.catch()`.
158160
However, this might not be possible for all future keywords.
159161

160162
There might also be a need for raw keywords in the other direction, e.g. so the
161-
older epoch can still use the new `catch` functionality somehow. I think this
163+
older edition can still use the new `catch` functionality somehow. I think this
162164
particular case is already served well enough by `do catch { ... }`, if we
163165
choose to stabilize it that way. Perhaps `br#keyword` could be used for this,
164166
but that may not be a good intuitive relationship.
@@ -175,4 +177,4 @@ but that may not be a good intuitive relationship.
175177

176178
- Do macros need any special care with such identifier tokens?
177179
- Should diagnostics use the `r#` syntax when printing identifiers that overlap keywords?
178-
- Does rustdoc need to use the `r#` syntax? e.g. to document `pub use old_epoch::*`
180+
- Does rustdoc need to use the `r#` syntax? e.g. to document `pub use old_edition::*`

0 commit comments

Comments
 (0)