Skip to content

Commit b3a034b

Browse files
committed
Merge PR #314: Add docs for 2024 prelude migration
2 parents 5454de3 + 2c54899 commit b3a034b

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

src/rust-2024/prelude.md

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,7 @@ If in the unlikely case there is a project still using these, it is recommended
4848

4949
## Migration
5050

51-
🚧 The automatic migration for this has not yet been implemented.
52-
53-
### Migration needed
54-
55-
#### Conflicting trait methods
51+
### Conflicting trait methods
5652

5753
When two traits that are in scope have the same method name, it is ambiguous which trait method should be used. For example:
5854

@@ -74,7 +70,7 @@ fn main() {
7470
}
7571
```
7672

77-
We can fix this by using fully qualified syntax:
73+
We can fix this so that it works on all editions by using fully qualified syntax:
7874

7975
```rust,ignore
8076
fn main() {
@@ -83,7 +79,22 @@ fn main() {
8379
}
8480
```
8581

86-
#### `RustcEncodable` and `RustcDecodable`
82+
The [`rust_2024_prelude_collisions`] lint will automatically modify any ambiguous method calls to use fully qualified syntax. This lint is part of the `rust-2024-compatibility` lint group, which will automatically be applied when running `cargo fix --edition`. To migrate your code to be Rust 2024 Edition compatible, run:
83+
84+
```sh
85+
cargo fix --edition
86+
```
87+
88+
Alternatively, you can manually enable the lint to find places where these qualifications need to be added:
89+
90+
```rust
91+
// Add this to the root of your crate to do a manual migration.
92+
#![warn(rust_2024_prelude_collisions)]
93+
```
94+
95+
[`rust_2024_prelude_collisions`]: ../../rustc/lints/listing/allowed-by-default.html#rust-2024-prelude-collisions
96+
97+
### `RustcEncodable` and `RustcDecodable`
8798

8899
It is strongly recommended that you migrate to a different serialization library if you are still using these.
89100
However, these derive macros are still available in the standard library, they are just required to be imported from the older prelude now:
@@ -92,3 +103,5 @@ However, these derive macros are still available in the standard library, they a
92103
#[allow(soft_unstable)]
93104
use core::prelude::v1::{RustcDecodable, RustcEncodable};
94105
```
106+
107+
There is no automatic migration for this change; you will need to make the update manually.

0 commit comments

Comments
 (0)