Skip to content
This repository was archived by the owner on Jan 29, 2025. It is now read-only.

build: move to the Rust 2021 edition #2085

Merged
merged 3 commits into from
Oct 25, 2022

Conversation

ErichDonGubler
Copy link
Member

@ErichDonGubler ErichDonGubler commented Oct 14, 2022

Since the MSRV of naga is currently 1.56, I don't think there's a strong reason to stay with the 2018 edition, and there are a few good reasons to move to the 2021 edition.

I did this migration mostly automatically, per official Rust guidelines:

$ cargo fix --edition --all-targets
$ sed -i Cargo.toml 's/2018/2021'
$ cargo fix --edition-idioms --allow-dirty # doesn't change anything

The only manual edit needed to stymie a new warning introduced was the removal of the TryFrom import from several modules, since it's now in the 2021 prelude.

Since the MSRV of `naga` [is currently 1.56][msrv], I don't think there's a strong reason to stay
with the 2018 edition, and there _are_ a [few good reasons][edition-guide] to move to the 2021
edition.

I did this migration mostly automatically, per [official Rust guidelines]:

```sh
$ cargo fix --edition --all-targets
$ sed -i Cargo.toml 's/2018/2021'
$ cargo fix --edition-idioms --allow-dirty # doesn't change anything
```

The only manual edit needed to stymie a new warning introduced was the removal of the `TryFrom`
import in several modules, since it's now in the 2021 prelude.

[msrv]: https://github.com/gfx-rs/naga/blob/a7193d652e49180661a6ca047889e0685667acdb/.github/workflows/pipeline.yml#L14
[edition-guide]: https://doc.rust-lang.org/edition-guide/rust-2021/index.html
[official Rust guidelines]: https://doc.rust-lang.org/cargo/commands/cargo-fix.html#edition-migration
Copy link
Member

@jimblandy jimblandy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! But don't forget cli/Cargo.toml, and I'd like to see the macros addressed differently.

How we were using `pat` in the Rust 2018 edition is actually the use case that
Rust 2021's `pat` fragment specifier is intended to satisfy. So, let's just use
that!
@ErichDonGubler
Copy link
Member Author

@jimblandy: Just fixed cli/Cargo.toml with 00220ec, which I'll autosquash right now. I believe I've addressed all feedback now. 😄

Copy link
Member

@jimblandy jimblandy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great.

@jimblandy jimblandy merged commit b37dda8 into gfx-rs:master Oct 25, 2022
@ErichDonGubler ErichDonGubler deleted the rust-2021-edition branch October 25, 2022 15:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants