Skip to content

Commit 95f5788

Browse files
committed
reword existing method -> pre-edition method
1 parent 59c8d6b commit 95f5788

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

text/0000-edition-based-method-disambiguation.md

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

99
This RFC proposes a way to introduce new trait methods that conflict with
10-
existing trait methods in downstream crates in a backwards compatible fashion.
10+
pre-edition[^1] trait methods in downstream crates in a backwards compatible fashion.
1111
We do so by annotating new methods with the edition they're introduced in. Then
1212
when ambigutity is detected between a new method in the standard library and an
13-
existing downstream method the compiler will check if the crate edition matches
13+
pre-edition downstream method the compiler will check if the crate edition matches
1414
the edition that the method was introduced in. If it does we pick the
15-
presumably pre-existing downstream method and output a warning that there was
15+
pre-edition method and output a warning that there was
1616
an ambigutity with a newly introduced std method and that this warning will be
1717
promoted to a hard error in the next edition.
1818

1919
# Motivation
2020
[motivation]: #motivation
2121

2222
Rust has had a long standing issue with breaking changes caused by introducing
23-
new methods that conflict with existing downstream methods. This issue is best
23+
new methods that conflict with pre-edition downstream methods. This issue is best
2424
exemplified with the recent attempt to move `Itertools::intersperse` into the
2525
`Iterator` trait which [broke a large number of
2626
crates](https://github.com/rust-lang/rust/issues/88967). Continuing as we have
@@ -34,9 +34,9 @@ introduce methods like these without causing any breakage.
3434
*written as though this feature is already implemented and stable*
3535

3636
The rust standard library recently added support for adding new methods to
37-
traits that conflict with existing methods with the same name on other traits
38-
without causing breakage due to ambiguity. Since adding this feature you may
39-
start running into errors that look like this
37+
traits that conflict with pre-edition[^1] methods with the same name on other
38+
traits without causing breakage due to ambiguity. Since adding this feature you
39+
may start running into errors that look like this
4040

4141
```
4242
warning[E0034]: multiple applicable items in scope
@@ -73,7 +73,7 @@ lifecycle, where methods are experimented within 3rd party crates and then
7373
moved into the standard library once they've been thorougly tested. A classic
7474
example of this is the `Itertools` crate for experimenting with extentions to
7575
the `Iterator` trait. However this problem isn't restricted to extension traits
76-
of existing standard library traits, and can indeed become a problem whenever
76+
of pre-edition standard library traits, and can indeed become a problem whenever
7777
any two methods have the same name.
7878

7979
You can fix issues like this by manually editing the code to select the
@@ -82,10 +82,10 @@ can use cargo fix. cargo fix will make assumptions about how the methods relate
8282
depending on if you're using cargo fix for an edition upgrade or not.
8383

8484
* **Within same edition** cargo fix will assume that the new method is a drop
85-
in replacement of the existing downstream one and will disambiguate by
85+
in replacement of the pre-edition downstream one and will disambiguate by
8686
selecting the upstream method defined in `std`.
8787
* **As part of an edition upgrade** cargo fix will prioritize maintaining the
88-
same behavior, and will disambiguate by selecting the existing method that
88+
same behavior, and will disambiguate by selecting the pre-edition method that
8989
was being used previously.
9090

9191
To run cargo fix within the same edition run:
@@ -104,7 +104,7 @@ cargo fix --edition
104104
```
105105

106106
In the example above this would replace the ambiguous code with
107-
`Itertools::intersperse(it, sep)`, maintaining the existing behavior.
107+
`Itertools::intersperse(it, sep)`, maintaining the pre-edition behavior.
108108

109109
# Reference-level explanation
110110
[reference-level-explanation]: #reference-level-explanation
@@ -122,11 +122,11 @@ normal and emit an error for the ambiguity.
122122

123123
This flag should be usable to resolve the following forms of breakage:
124124

125-
* A new method on an existing trait ([e.g.
125+
* A new method on an pre-edition trait ([e.g.
126126
itertools::intersperse](https://github.com/rust-lang/rust/issues/88967))
127-
* A new trait implementation of an existing trait on an existing types ([e.g.
127+
* A new trait implementation of an pre-edition trait on an pre-edition type ([e.g.
128128
ErrorKind Display](https://github.com/rust-lang/rust/issues/94507))
129-
* A new inherent method on an existing type (no recent examples)
129+
* A new inherent method on an pre-edition type (no recent examples)
130130

131131
# Drawbacks
132132
[drawbacks]: #drawbacks
@@ -149,7 +149,11 @@ disambiguating the trait a method call should come from.
149149
# Rationale and alternatives
150150
[rationale-and-alternatives]: #rationale-and-alternatives
151151

152-
[This comment](https://github.com/rust-lang/rust/issues/88967#issuecomment-938024847) on the `Iterator::intersperse` issue details a few alternatives that were discussed by the libs team when we encountered that specific issue. These include both short term and long term suggestions.
152+
[This
153+
comment](https://github.com/rust-lang/rust/issues/88967#issuecomment-938024847)
154+
on the `Iterator::intersperse` issue details a few alternatives that were
155+
discussed by the libs team when we encountered that specific issue. These
156+
include both short term and long term suggestions.
153157

154158
**Short Term**
155159

@@ -188,15 +192,19 @@ supertrait.
188192
## Interaction with autoderef
189193

190194
We already have logic for preferring stable methods to unstable methods but it
191-
breaks[^1] if the auto deref for one requires one more level of indirection
195+
breaks[^2] if the auto deref for one requires one more level of indirection
192196
than the other. We should be careful to consider how autoderef behavior can
193197
affect edition based method disambiguation.
194198

195-
[^1]: https://github.com/rust-lang/rust/issues/86682
196199

197200
# Future possibilities
198201
[future-possibilities]: #future-possibilities
199202

200203
As this RFC previously pointed out in the drawbacks section, introducing a new
201204
syntax for unambiguous method calls for a specific trait would significantly
202205
improve the experience of resolving these warnings.
206+
207+
[^1]: Definition: Pre-edition methods are methods that could legally have been
208+
introduced during the current edition which do not conflict with any methods
209+
that existed during the initial release of the current edition.
210+
[^2]: https://github.com/rust-lang/rust/issues/86682

0 commit comments

Comments
 (0)