Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation for 2024 prelude migration. #314

Merged
merged 2 commits into from
Jul 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions src/rust-2024/prelude.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@ If in the unlikely case there is a project still using these, it is recommended

## Migration

🚧 The automatic migration for this has not yet been implemented.

### Migration needed

#### Conflicting trait methods
### Conflicting trait methods

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

Expand All @@ -74,7 +70,7 @@ fn main() {
}
```

We can fix this by using fully qualified syntax:
We can fix this so that it works on all editions by using fully qualified syntax:

```rust,ignore
fn main() {
Expand All @@ -83,7 +79,22 @@ fn main() {
}
```

#### `RustcEncodable` and `RustcDecodable`
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:

```sh
cargo fix --edition
```

Alternatively, you can manually enable the lint to find places where these qualifications need to be added:

```rust
// Add this to the root of your crate to do a manual migration.
#![warn(rust_2024_prelude_collisions)]
```

[`rust_2024_prelude_collisions`]: ../../rustc/lints/listing/allowed-by-default.html#rust-2024-prelude-collisions

### `RustcEncodable` and `RustcDecodable`

It is strongly recommended that you migrate to a different serialization library if you are still using these.
However, these derive macros are still available in the standard library, they are just required to be imported from the older prelude now:
Expand All @@ -92,3 +103,5 @@ However, these derive macros are still available in the standard library, they a
#[allow(soft_unstable)]
use core::prelude::v1::{RustcDecodable, RustcEncodable};
```

There is no automatic migration for this change; you will need to make the update manually.