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

Update rust edition to 2021 #2835

Merged
merged 1 commit into from
Mar 2, 2023

Conversation

stmcginnis
Copy link
Contributor

Issue number:

Closes #1789

Description of changes:

The 2021 edition of Rust has been available in the Bottlerocket SDK since late 2021. Most crates in the project still set their edition to 2018 though.

This updates the declared edition to 2021. This brings various default language improvements.

Testing done:

Ran cargo make check to run linters and unit tests.
Build aws-k8s-1.24 variant and deployed new cluster. Verified cluster initializes successfully and deployed a pod to cluster to verify operation.

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

@bcressey
Copy link
Contributor

bcressey commented Mar 1, 2023

In a clean checkout of the current develop branch, if I run this command in sources and tools:

cargo fix --edition --all-features --allow-dirty

It suggests this fix:

diff --git a/sources/api/apiserver/src/server/exec/child.rs b/sources/api/apiserver/src/server/exec/child.rs
index e50076e5..d87e4971 100644
--- a/sources/api/apiserver/src/server/exec/child.rs
+++ b/sources/api/apiserver/src/server/exec/child.rs
@@ -142,6 +142,7 @@ impl ChildHandles {
         // process too, or it'd stick around forever.  Perform the rest of initialization in a
         // closure so that we can kill the child easily on any error, returning the original value.
         (move || {
+            let _ = &child;
             // Now that the process is spawned, if we created a PTY, close its slave fd in the
             // parent process, or reads of the master side will block.
             if let Some(close_fd) = child_fds.close_fd {

Which is a conservative fix for the new disjoint captures in closures feature.

@bcressey
Copy link
Contributor

bcressey commented Mar 1, 2023

cargo fix --edition-idioms didn't seem to find anything to change for the 2021 edition, FWIW.

The 2021 edition of Rust has been available in the Bottlerocket SDK
since late 2021. Most crates in the project still set their edition to
2018 though.

This updates the declared edition to 2021. This brings various default
language improvements [0].

[0] https://doc.rust-lang.org/edition-guide/rust-2021/index.html

Signed-off-by: Sean McGinnis <[email protected]>
Copy link
Contributor

@zmrow zmrow left a comment

Choose a reason for hiding this comment

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

🎮

@stmcginnis stmcginnis merged commit 0500ec1 into bottlerocket-os:develop Mar 2, 2023
@stmcginnis stmcginnis deleted the rust-2021 branch March 2, 2023 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update to Rust 2021 edition
4 participants