You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
25
25
26
26
The `core` prelude will parallel the `std` prelude, containing the same structure and the same items as far as they are available in `core`.
27
27
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`:
29
29
30
30
-`TryFrom`/`TryInto`
31
31
-`FromIterator`
32
32
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.
@@ -46,10 +46,13 @@ The migration lint will be implemented as follows:
46
46
* Find method calls matching the name of one of the newly added traits' methods.
47
47
This can be done either by hardcoding these method names or by setting up some
48
48
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.
53
56
54
57
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.
0 commit comments