Skip to content

Commit 8f1618a

Browse files
committed
Address review feedback
1 parent b6c02d0 commit 8f1618a

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

text/0000-prelude-2021-traits.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ The expected outcome is to make the newly added traits more accessible to users,
2121
# Guide-level explanation
2222
[guide-level-explanation]: #guide-level-explanation
2323

24-
The compiler currently brings all items from `std::prelude::v1` into scope for each module (for code using `std`). Crates that declare usage of the 2021 edition will instead get items from `std::prelude::edition2021` imported into scope. With the implementation of this RFC, we will add `edition2015` and `edition2018` modules in `std::prelude`, and a crate configuring a particular edition will get the prelude appropriate for its edition. The `v1` module will stick around for compatibility reasons, although it might be deprecated in the future.
24+
The compiler currently brings all items from `std::prelude::v1` into scope for each module (for code using `std`). Crates that declare usage of the 2021 edition will instead get items from `std::prelude::rust_2021` imported into scope. With the implementation of this RFC, we will add `rust_2015` and `rust_2018` modules in `std::prelude`, and a crate configuring a particular edition will get the prelude appropriate for its edition. The `v1` module will stick around for compatibility reasons, although it might be deprecated in the future.
2525

2626
The `core` prelude will parallel the `std` prelude, containing the same structure and the same items as far as they are available in `core`.
2727

28-
This RFC proposes to add the following traits to `std::prelude::edition2021`, but not `std::prelude::v1`:
28+
This RFC proposes to add the following traits to `std::prelude::rust_2021`, but not `std::prelude::v1`:
2929

3030
- `TryFrom`/`TryInto`
3131
- `FromIterator`
3232

33-
Except for newly added traits, the `v1` and `edition2021` preludes should be kept in sync. Items that are added to the `edition2021` prelude should also be added to the `v1` prelude if there is negligible risk for compatibility. On the other hand, newer edition preludes may decide not to include items from an older edition's prelude.
33+
Except for newly added traits, the `v1` and `rust_2021` preludes should be kept in sync. Items that are added to the `rust_2021` prelude should also be added to the `v1` prelude if there is negligible risk for compatibility. On the other hand, newer edition preludes may decide not to include items from an older edition's prelude.
3434

3535
# Reference-level explanation
3636
[reference-level-explanation]: #reference-level-explanation
@@ -46,10 +46,13 @@ The migration lint will be implemented as follows:
4646
* Find method calls matching the name of one of the newly added traits' methods.
4747
This can be done either by hardcoding these method names or by setting up some
4848
kind of registry through the use of an attribute on the relevant traits.
49-
* After method resolution, if the method matches one of the newly added methods'
50-
names but the originating trait is not from `core` or `std` (and/or does not
51-
match the originating trait), suggest a rewrite to disambiguating syntax
52-
(such as `foo.try_into()` to `TryInto::try_into(foo)`).
49+
* After method resolution, if:
50+
* The method matches one of the newly added methods' names, and
51+
* The originating trait is not from `core` or `std` (and/or does not
52+
match the originating trait), and
53+
* The originating trait is also implemented for the receiver's type,
54+
* Suggest a rewrite to disambiguating syntax (such as `foo.try_into()` to `TryInto::try_into(foo)`). If necessary, additional levels of (de)referencing
55+
might be needed to match the implementing type of the target trait.
5356

5457
Currently, diagnostics for trait methods that are not in scope suggest importing the originating trait. For traits that have become part of the prelude in a newer edition, the diagnostics should be updated such that they suggest upgrading to the latest edition as an alternative to importing the relevant trait.
5558

0 commit comments

Comments
 (0)