Merge unused_tuple_struct_fields into dead_code by shepmaster · Pull Request #118297 · rust-lang/rust (original) (raw)

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

shepmaster

@rustbot rustbot added S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

T-compiler

Relevant to the compiler team, which will review and decide on the PR/issue.

labels

Nov 25, 2023

Nadrieril

@rustbot rustbot added A-testsuite

Area: The testsuite used to check the correctness of rustc

T-bootstrap

Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

labels

Nov 26, 2023

@traviscross traviscross added the T-lang

Relevant to the language team, which will review and decide on the PR/issue.

label

Nov 29, 2023

@shepmaster shepmaster changed the titleConvert unused_tuple_struct_fields to warn-by-default Merge unused_tuple_struct_fields into dead_code

Nov 29, 2023

WaffleLapkin

Comment on lines 1015 to 1017

daxpedda added a commit to daxpedda/winit that referenced this pull request

Jan 14, 2024

@daxpedda

kchibisov pushed a commit to rust-windowing/winit that referenced this pull request

Jan 15, 2024

@daxpedda @kchibisov

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request

Jan 19, 2024

@matthiaskrgr

…ent, r=Nilstrieb

dead_code treats #[repr(transparent)] the same as #[repr(C)]

In rust-lang#92972 we enabled linting on unused fields in tuple structs. In rust-lang#118297 that lint was enabled by default. That exposed issues like rust-lang#119659, where the fields of a struct marked #[repr(transparent)] were reported by the dead_code lint. The language team [decided](rust-lang#119659 (comment)) that the lint should treat repr(transparent) the same as #[repr(C)].

Fixes rust-lang#119659

rust-timer added a commit to rust-lang-ci/rust that referenced this pull request

Jan 19, 2024

@rust-timer

Rollup merge of rust-lang#120107 - shepmaster:dead-code-repr-transparent, r=Nilstrieb

dead_code treats #[repr(transparent)] the same as #[repr(C)]

In rust-lang#92972 we enabled linting on unused fields in tuple structs. In rust-lang#118297 that lint was enabled by default. That exposed issues like rust-lang#119659, where the fields of a struct marked #[repr(transparent)] were reported by the dead_code lint. The language team [decided](rust-lang#119659 (comment)) that the lint should treat repr(transparent) the same as #[repr(C)].

Fixes rust-lang#119659

gnoliyil pushed a commit to gnoliyil/fuchsia that referenced this pull request

Jan 27, 2024

Since rust-lang/rust#118297, Rust treats unused tuple struct fields as dead code. This CL adds an #[allow(dead_code)] to silence the warning.

Bug: 318827209 Change-Id: I6858165a085a0ef508722c1ce38f3d95866d2867 Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/972128 Reviewed-by: David Koloski dkoloski@google.com Commit-Queue: Auto-Submit auto-submit@fuchsia-infra.iam.gserviceaccount.com Fuchsia-Auto-Submit: Mitchell Kember mkember@google.com

gnoliyil pushed a commit to gnoliyil/fuchsia that referenced this pull request

Jan 27, 2024

@gmittert

An upcoming rustc change (rust-lang/rust#118297) marks unused tuple fields as dead code. Explicitly mark these structs as allowed to silence the warning/error.

Bug: 319472617 Change-Id: I248861cd1343a2906a1e97f7e4af06115913eb88 Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/978876 Reviewed-by: Colin Nelson colnnelson@google.com Fuchsia-Auto-Submit: Gwen Mittertreiner gmtr@google.com Commit-Queue: Auto-Submit auto-submit@fuchsia-infra.iam.gserviceaccount.com

jwodder added a commit to jwodder/rsrepo that referenced this pull request

Feb 10, 2024

@jwodder

inejge added a commit to inejge/ldap3 that referenced this pull request

Feb 14, 2024

@inejge

Probably due to rust-lang/rust#118297, our SaslCreds tuple struct now generates a warning. It can be silenced by making the struct public, but it really doesn't need to be, so dead code will be allowd at this point.

The warning will presumably end up in stable Rust in a couple of releases.

fbq pushed a commit to Rust-for-Linux/linux that referenced this pull request

Feb 17, 2024

@ojeda @fbq

This is the next upgrade to the Rust toolchain, from 1.76.0 to 1.77.0 (i.e. the latest) [1].

See the upgrade policy [2] and the comments on the first upgrade in commit 3ed03f4 ("rust: upgrade to Rust 1.68.2").

Unstable features

The offset_of feature (single-field offset_of!) that we were using got stabilized in Rust 1.77.0 [3].

Therefore, now the only unstable features allowed to be used outside the kernel crate is new_uninit, though other code to be upstreamed may increase the list.

Please see [4] for details.

Required changes

Rust 1.77.0 merged the unused_tuple_struct_fields lint into dead_code, thus upgrading it from allow to warn [5]. In turn, this makes rustc complain about the ThisModule's pointer field being never read. Thus locally allow it for the moment, since we will have users later on (e.g. Binder needs a as_ptr method [6]).

Other changes

Rust 1.77.0 introduces the --check-cfg feature [7], for which there is a Call for Testing going on [8]. We were requested to test it and we found it useful [9] -- we will likely enable it in the future.

alloc upgrade and reviewing

The vast majority of changes are due to our alloc fork being upgraded at once.

There are two kinds of changes to be aware of: the ones coming from upstream, which we should follow as closely as possible, and the updates needed in our added fallible APIs to keep them matching the newer infallible APIs coming from upstream.

Instead of taking a look at the diff of this patch, an alternative approach is reviewing a diff of the changes between upstream alloc and the kernel's. This allows to easily inspect the kernel additions only, especially to check if the fallible methods we already have still match the infallible ones in the new version coming from upstream.

Another approach is reviewing the changes introduced in the additions in the kernel fork between the two versions. This is useful to spot potentially unintended changes to our additions.

To apply these approaches, one may follow steps similar to the following to generate a pair of patches that show the differences between upstream Rust and the kernel (for the subset of alloc we use) before and after applying this patch:

# Get the difference with respect to the old version.
git -C rust checkout $(linux/scripts/min-tool-version.sh rustc)
git -C linux ls-tree -r --name-only HEAD -- rust/alloc |
    cut -d/ -f3- |
    grep -Fv README.md |
    xargs -IPATH cp rust/library/alloc/src/PATH linux/rust/alloc/PATH
git -C linux diff --patch-with-stat --summary -R > old.patch
git -C linux restore rust/alloc

# Apply this patch.
git -C linux am rust-upgrade.patch

# Get the difference with respect to the new version.
git -C rust checkout $(linux/scripts/min-tool-version.sh rustc)
git -C linux ls-tree -r --name-only HEAD -- rust/alloc |
    cut -d/ -f3- |
    grep -Fv README.md |
    xargs -IPATH cp rust/library/alloc/src/PATH linux/rust/alloc/PATH
git -C linux diff --patch-with-stat --summary -R > new.patch
git -C linux restore rust/alloc

Now one may check the new.patch to take a look at the additions (first approach) or at the difference between those two patches (second approach). For the latter, a side-by-side tool is recommended.

Link: https://github.com/rust-lang/rust/blob/stable/RELEASES.md#version-1770-2024-03-21 [1] Link: https://rust-for-linux.com/rust-version-policy [2] Link: rust-lang/rust#118799 [3] Link: #2 [4] Link: rust-lang/rust#118297 [5] Link: https://lore.kernel.org/rust-for-linux/20231101-rust-binder-v1-2-08ba9197f637@google.com/#Z31rust:kernel:lib.rs [6] Link: https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html [7] Link: rust-lang/rfcs#3013 (comment) [8] Link: rust-lang/rust#82450 (comment) [9] Signed-off-by: Miguel Ojeda ojeda@kernel.org Link: https://lore.kernel.org/r/20240217002717.57507-1-ojeda@kernel.org

fbq pushed a commit to Rust-for-Linux/linux that referenced this pull request

Feb 19, 2024

@ojeda @fbq

This is the next upgrade to the Rust toolchain, from 1.76.0 to 1.77.0 (i.e. the latest) [1].

See the upgrade policy [2] and the comments on the first upgrade in commit 3ed03f4 ("rust: upgrade to Rust 1.68.2").

The offset_of feature (single-field offset_of!) that we were using got stabilized in Rust 1.77.0 [3].

Therefore, now the only unstable features allowed to be used outside the kernel crate is new_uninit, though other code to be upstreamed may increase the list.

Please see [4] for details.

Rust 1.77.0 merged the unused_tuple_struct_fields lint into dead_code, thus upgrading it from allow to warn [5]. In turn, this makes rustc complain about the ThisModule's pointer field being never read. Thus locally allow it for the moment, since we will have users later on (e.g. Binder needs a as_ptr method [6]).

Rust 1.77.0 introduces the --check-cfg feature [7], for which there is a Call for Testing going on [8]. We were requested to test it and we found it useful [9] -- we will likely enable it in the future.

The vast majority of changes are due to our alloc fork being upgraded at once.

There are two kinds of changes to be aware of: the ones coming from upstream, which we should follow as closely as possible, and the updates needed in our added fallible APIs to keep them matching the newer infallible APIs coming from upstream.

Instead of taking a look at the diff of this patch, an alternative approach is reviewing a diff of the changes between upstream alloc and the kernel's. This allows to easily inspect the kernel additions only, especially to check if the fallible methods we already have still match the infallible ones in the new version coming from upstream.

Another approach is reviewing the changes introduced in the additions in the kernel fork between the two versions. This is useful to spot potentially unintended changes to our additions.

To apply these approaches, one may follow steps similar to the following to generate a pair of patches that show the differences between upstream Rust and the kernel (for the subset of alloc we use) before and after applying this patch:

# Get the difference with respect to the old version.
git -C rust checkout $(linux/scripts/min-tool-version.sh rustc)
git -C linux ls-tree -r --name-only HEAD -- rust/alloc |
    cut -d/ -f3- |
    grep -Fv README.md |
    xargs -IPATH cp rust/library/alloc/src/PATH linux/rust/alloc/PATH
git -C linux diff --patch-with-stat --summary -R > old.patch
git -C linux restore rust/alloc

# Apply this patch.
git -C linux am rust-upgrade.patch

# Get the difference with respect to the new version.
git -C rust checkout $(linux/scripts/min-tool-version.sh rustc)
git -C linux ls-tree -r --name-only HEAD -- rust/alloc |
    cut -d/ -f3- |
    grep -Fv README.md |
    xargs -IPATH cp rust/library/alloc/src/PATH linux/rust/alloc/PATH
git -C linux diff --patch-with-stat --summary -R > new.patch
git -C linux restore rust/alloc

Now one may check the new.patch to take a look at the additions (first approach) or at the difference between those two patches (second approach). For the latter, a side-by-side tool is recommended.

Link: https://github.com/rust-lang/rust/blob/stable/RELEASES.md#version-1770-2024-03-21 [1] Link: https://rust-for-linux.com/rust-version-policy [2] Link: rust-lang/rust#118799 [3] Link: #2 [4] Link: rust-lang/rust#118297 [5] Link: https://lore.kernel.org/rust-for-linux/20231101-rust-binder-v1-2-08ba9197f637@google.com/#Z31rust:kernel:lib.rs [6] Link: https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html [7] Link: rust-lang/rfcs#3013 (comment) [8] Link: rust-lang/rust#82450 (comment) [9] Signed-off-by: Miguel Ojeda ojeda@kernel.org Link: https://lore.kernel.org/r/20240217002717.57507-1-ojeda@kernel.org

fbq pushed a commit to Rust-for-Linux/linux that referenced this pull request

Mar 5, 2024

@ojeda @fbq

This is the next upgrade to the Rust toolchain, from 1.76.0 to 1.77.0 (i.e. the latest) [1].

See the upgrade policy [2] and the comments on the first upgrade in commit 3ed03f4 ("rust: upgrade to Rust 1.68.2").

The offset_of feature (single-field offset_of!) that we were using got stabilized in Rust 1.77.0 [3].

Therefore, now the only unstable features allowed to be used outside the kernel crate is new_uninit, though other code to be upstreamed may increase the list.

Please see [4] for details.

Rust 1.77.0 merged the unused_tuple_struct_fields lint into dead_code, thus upgrading it from allow to warn [5]. In turn, this makes rustc complain about the ThisModule's pointer field being never read. Thus locally allow it for the moment, since we will have users later on (e.g. Binder needs a as_ptr method [6]).

Rust 1.77.0 introduces the --check-cfg feature [7], for which there is a Call for Testing going on [8]. We were requested to test it and we found it useful [9] -- we will likely enable it in the future.

The vast majority of changes are due to our alloc fork being upgraded at once.

There are two kinds of changes to be aware of: the ones coming from upstream, which we should follow as closely as possible, and the updates needed in our added fallible APIs to keep them matching the newer infallible APIs coming from upstream.

Instead of taking a look at the diff of this patch, an alternative approach is reviewing a diff of the changes between upstream alloc and the kernel's. This allows to easily inspect the kernel additions only, especially to check if the fallible methods we already have still match the infallible ones in the new version coming from upstream.

Another approach is reviewing the changes introduced in the additions in the kernel fork between the two versions. This is useful to spot potentially unintended changes to our additions.

To apply these approaches, one may follow steps similar to the following to generate a pair of patches that show the differences between upstream Rust and the kernel (for the subset of alloc we use) before and after applying this patch:

# Get the difference with respect to the old version.
git -C rust checkout $(linux/scripts/min-tool-version.sh rustc)
git -C linux ls-tree -r --name-only HEAD -- rust/alloc |
    cut -d/ -f3- |
    grep -Fv README.md |
    xargs -IPATH cp rust/library/alloc/src/PATH linux/rust/alloc/PATH
git -C linux diff --patch-with-stat --summary -R > old.patch
git -C linux restore rust/alloc

# Apply this patch.
git -C linux am rust-upgrade.patch

# Get the difference with respect to the new version.
git -C rust checkout $(linux/scripts/min-tool-version.sh rustc)
git -C linux ls-tree -r --name-only HEAD -- rust/alloc |
    cut -d/ -f3- |
    grep -Fv README.md |
    xargs -IPATH cp rust/library/alloc/src/PATH linux/rust/alloc/PATH
git -C linux diff --patch-with-stat --summary -R > new.patch
git -C linux restore rust/alloc

Now one may check the new.patch to take a look at the additions (first approach) or at the difference between those two patches (second approach). For the latter, a side-by-side tool is recommended.

Link: https://github.com/rust-lang/rust/blob/stable/RELEASES.md#version-1770-2024-03-21 [1] Link: https://rust-for-linux.com/rust-version-policy [2] Link: rust-lang/rust#118799 [3] Link: #2 [4] Link: rust-lang/rust#118297 [5] Link: https://lore.kernel.org/rust-for-linux/20231101-rust-binder-v1-2-08ba9197f637@google.com/#Z31rust:kernel:lib.rs [6] Link: https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html [7] Link: rust-lang/rfcs#3013 (comment) [8] Link: rust-lang/rust#82450 (comment) [9] Signed-off-by: Miguel Ojeda ojeda@kernel.org Link: https://lore.kernel.org/r/20240217002717.57507-1-ojeda@kernel.org

fbq pushed a commit to Rust-for-Linux/linux that referenced this pull request

Mar 25, 2024

@ojeda @fbq

This is the next upgrade to the Rust toolchain, from 1.76.0 to 1.77.0 (i.e. the latest) [1].

See the upgrade policy [2] and the comments on the first upgrade in commit 3ed03f4 ("rust: upgrade to Rust 1.68.2").

The offset_of feature (single-field offset_of!) that we were using got stabilized in Rust 1.77.0 [3].

Therefore, now the only unstable features allowed to be used outside the kernel crate is new_uninit, though other code to be upstreamed may increase the list.

Please see [4] for details.

Rust 1.77.0 merged the unused_tuple_struct_fields lint into dead_code, thus upgrading it from allow to warn [5]. In turn, this makes rustc complain about the ThisModule's pointer field being never read. Thus locally allow it for the moment, since we will have users later on (e.g. Binder needs a as_ptr method [6]).

Rust 1.77.0 introduces the --check-cfg feature [7], for which there is a Call for Testing going on [8]. We were requested to test it and we found it useful [9] -- we will likely enable it in the future.

The vast majority of changes are due to our alloc fork being upgraded at once.

There are two kinds of changes to be aware of: the ones coming from upstream, which we should follow as closely as possible, and the updates needed in our added fallible APIs to keep them matching the newer infallible APIs coming from upstream.

Instead of taking a look at the diff of this patch, an alternative approach is reviewing a diff of the changes between upstream alloc and the kernel's. This allows to easily inspect the kernel additions only, especially to check if the fallible methods we already have still match the infallible ones in the new version coming from upstream.

Another approach is reviewing the changes introduced in the additions in the kernel fork between the two versions. This is useful to spot potentially unintended changes to our additions.

To apply these approaches, one may follow steps similar to the following to generate a pair of patches that show the differences between upstream Rust and the kernel (for the subset of alloc we use) before and after applying this patch:

# Get the difference with respect to the old version.
git -C rust checkout $(linux/scripts/min-tool-version.sh rustc)
git -C linux ls-tree -r --name-only HEAD -- rust/alloc |
    cut -d/ -f3- |
    grep -Fv README.md |
    xargs -IPATH cp rust/library/alloc/src/PATH linux/rust/alloc/PATH
git -C linux diff --patch-with-stat --summary -R > old.patch
git -C linux restore rust/alloc

# Apply this patch.
git -C linux am rust-upgrade.patch

# Get the difference with respect to the new version.
git -C rust checkout $(linux/scripts/min-tool-version.sh rustc)
git -C linux ls-tree -r --name-only HEAD -- rust/alloc |
    cut -d/ -f3- |
    grep -Fv README.md |
    xargs -IPATH cp rust/library/alloc/src/PATH linux/rust/alloc/PATH
git -C linux diff --patch-with-stat --summary -R > new.patch
git -C linux restore rust/alloc

Now one may check the new.patch to take a look at the additions (first approach) or at the difference between those two patches (second approach). For the latter, a side-by-side tool is recommended.

Link: https://github.com/rust-lang/rust/blob/stable/RELEASES.md#version-1770-2024-03-21 [1] Link: https://rust-for-linux.com/rust-version-policy [2] Link: rust-lang/rust#118799 [3] Link: #2 [4] Link: rust-lang/rust#118297 [5] Link: https://lore.kernel.org/rust-for-linux/20231101-rust-binder-v1-2-08ba9197f637@google.com/#Z31rust:kernel:lib.rs [6] Link: https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html [7] Link: rust-lang/rfcs#3013 (comment) [8] Link: rust-lang/rust#82450 (comment) [9] Signed-off-by: Miguel Ojeda ojeda@kernel.org Link: https://lore.kernel.org/r/20240217002717.57507-1-ojeda@kernel.org

wip-sync pushed a commit to NetBSD/pkgsrc-wip that referenced this pull request

Mar 29, 2024

@he32

fbq pushed a commit to Rust-for-Linux/linux that referenced this pull request

Mar 29, 2024

@ojeda @fbq

This is the next upgrade to the Rust toolchain, from 1.76.0 to 1.77.0 (i.e. the latest) [1].

See the upgrade policy [2] and the comments on the first upgrade in commit 3ed03f4 ("rust: upgrade to Rust 1.68.2").

The offset_of feature (single-field offset_of!) that we were using got stabilized in Rust 1.77.0 [3].

Therefore, now the only unstable features allowed to be used outside the kernel crate is new_uninit, though other code to be upstreamed may increase the list.

Please see [4] for details.

Rust 1.77.0 merged the unused_tuple_struct_fields lint into dead_code, thus upgrading it from allow to warn [5]. In turn, this makes rustc complain about the ThisModule's pointer field being never read. Thus locally allow it for the moment, since we will have users later on (e.g. Binder needs a as_ptr method [6]).

Rust 1.77.0 introduces the --check-cfg feature [7], for which there is a Call for Testing going on [8]. We were requested to test it and we found it useful [9] -- we will likely enable it in the future.

The vast majority of changes are due to our alloc fork being upgraded at once.

There are two kinds of changes to be aware of: the ones coming from upstream, which we should follow as closely as possible, and the updates needed in our added fallible APIs to keep them matching the newer infallible APIs coming from upstream.

Instead of taking a look at the diff of this patch, an alternative approach is reviewing a diff of the changes between upstream alloc and the kernel's. This allows to easily inspect the kernel additions only, especially to check if the fallible methods we already have still match the infallible ones in the new version coming from upstream.

Another approach is reviewing the changes introduced in the additions in the kernel fork between the two versions. This is useful to spot potentially unintended changes to our additions.

To apply these approaches, one may follow steps similar to the following to generate a pair of patches that show the differences between upstream Rust and the kernel (for the subset of alloc we use) before and after applying this patch:

# Get the difference with respect to the old version.
git -C rust checkout $(linux/scripts/min-tool-version.sh rustc)
git -C linux ls-tree -r --name-only HEAD -- rust/alloc |
    cut -d/ -f3- |
    grep -Fv README.md |
    xargs -IPATH cp rust/library/alloc/src/PATH linux/rust/alloc/PATH
git -C linux diff --patch-with-stat --summary -R > old.patch
git -C linux restore rust/alloc

# Apply this patch.
git -C linux am rust-upgrade.patch

# Get the difference with respect to the new version.
git -C rust checkout $(linux/scripts/min-tool-version.sh rustc)
git -C linux ls-tree -r --name-only HEAD -- rust/alloc |
    cut -d/ -f3- |
    grep -Fv README.md |
    xargs -IPATH cp rust/library/alloc/src/PATH linux/rust/alloc/PATH
git -C linux diff --patch-with-stat --summary -R > new.patch
git -C linux restore rust/alloc

Now one may check the new.patch to take a look at the additions (first approach) or at the difference between those two patches (second approach). For the latter, a side-by-side tool is recommended.

Link: https://github.com/rust-lang/rust/blob/stable/RELEASES.md#version-1770-2024-03-21 [1] Link: https://rust-for-linux.com/rust-version-policy [2] Link: rust-lang/rust#118799 [3] Link: #2 [4] Link: rust-lang/rust#118297 [5] Link: https://lore.kernel.org/rust-for-linux/20231101-rust-binder-v1-2-08ba9197f637@google.com/#Z31rust:kernel:lib.rs [6] Link: https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html [7] Link: rust-lang/rfcs#3013 (comment) [8] Link: rust-lang/rust#82450 (comment) [9] Signed-off-by: Miguel Ojeda ojeda@kernel.org Link: https://lore.kernel.org/r/20240217002717.57507-1-ojeda@kernel.org [boqun: Resolve the conflicts with using upstream alloc]

ojeda added a commit to ojeda/linux that referenced this pull request

Mar 29, 2024

@ojeda

This is the next upgrade to the Rust toolchain, from 1.76.0 to 1.77.1 (i.e. the latest) [1].

See the upgrade policy [2] and the comments on the first upgrade in commit 3ed03f4 ("rust: upgrade to Rust 1.68.2").

Unstable features

The offset_of feature (single-field offset_of!) that we were using got stabilized in Rust 1.77.0 [3].

Therefore, now the only unstable features allowed to be used outside the kernel crate is new_uninit, though other code to be upstreamed may increase the list.

Please see [4] for details.

Required changes

Rust 1.77.0 merged the unused_tuple_struct_fields lint into dead_code, thus upgrading it from allow to warn [5]. In turn, this made rustc complain about the ThisModule's pointer field being never read, but the previous patch adds the as_ptr method to it, needed by Binder [6], so that we do not need to locally allow it.

Other changes

Rust 1.77.0 introduces the --check-cfg feature [7], for which there is a Call for Testing going on [8]. We were requested to test it and we found it useful [9] -- we will likely enable it in the future.

alloc upgrade and reviewing

The vast majority of changes are due to our alloc fork being upgraded at once.

There are two kinds of changes to be aware of: the ones coming from upstream, which we should follow as closely as possible, and the updates needed in our added fallible APIs to keep them matching the newer infallible APIs coming from upstream.

Instead of taking a look at the diff of this patch, an alternative approach is reviewing a diff of the changes between upstream alloc and the kernel's. This allows to easily inspect the kernel additions only, especially to check if the fallible methods we already have still match the infallible ones in the new version coming from upstream.

Another approach is reviewing the changes introduced in the additions in the kernel fork between the two versions. This is useful to spot potentially unintended changes to our additions.

To apply these approaches, one may follow steps similar to the following to generate a pair of patches that show the differences between upstream Rust and the kernel (for the subset of alloc we use) before and after applying this patch:

# Get the difference with respect to the old version.
git -C rust checkout $(linux/scripts/min-tool-version.sh rustc)
git -C linux ls-tree -r --name-only HEAD -- rust/alloc |
    cut -d/ -f3- |
    grep -Fv README.md |
    xargs -IPATH cp rust/library/alloc/src/PATH linux/rust/alloc/PATH
git -C linux diff --patch-with-stat --summary -R > old.patch
git -C linux restore rust/alloc

# Apply this patch.
git -C linux am rust-upgrade.patch

# Get the difference with respect to the new version.
git -C rust checkout $(linux/scripts/min-tool-version.sh rustc)
git -C linux ls-tree -r --name-only HEAD -- rust/alloc |
    cut -d/ -f3- |
    grep -Fv README.md |
    xargs -IPATH cp rust/library/alloc/src/PATH linux/rust/alloc/PATH
git -C linux diff --patch-with-stat --summary -R > new.patch
git -C linux restore rust/alloc

Now one may check the new.patch to take a look at the additions (first approach) or at the difference between those two patches (second approach). For the latter, a side-by-side tool is recommended.

Link: https://github.com/rust-lang/rust/blob/stable/RELEASES.md#version-1770-2024-03-21 [1] Link: https://rust-for-linux.com/rust-version-policy [2] Link: rust-lang/rust#118799 [3] Link: Rust-for-Linux#2 [4] Link: rust-lang/rust#118297 [5] Link: https://lore.kernel.org/rust-for-linux/20231101-rust-binder-v1-2-08ba9197f637@google.com/#Z31rust:kernel:lib.rs [6] Link: https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html [7] Link: rust-lang/rfcs#3013 (comment) [8] Link: rust-lang/rust#82450 (comment) [9] Reviewed-by: Alice Ryhl aliceryhl@google.com Tested-by: Boqun Feng boqun.feng@gmail.com Link: https://lore.kernel.org/r/20240217002717.57507-1-ojeda@kernel.org [ Upgraded to 1.77.1. No changed to alloc during the beta. ] Signed-off-by: Miguel Ojeda ojeda@kernel.org

ojeda added a commit to Rust-for-Linux/linux that referenced this pull request

Mar 29, 2024

@ojeda

This is the next upgrade to the Rust toolchain, from 1.76.0 to 1.77.1 (i.e. the latest) [1].

See the upgrade policy [2] and the comments on the first upgrade in commit 3ed03f4 ("rust: upgrade to Rust 1.68.2").

Unstable features

The offset_of feature (single-field offset_of!) that we were using got stabilized in Rust 1.77.0 [3].

Therefore, now the only unstable features allowed to be used outside the kernel crate is new_uninit, though other code to be upstreamed may increase the list.

Please see [4] for details.

Required changes

Rust 1.77.0 merged the unused_tuple_struct_fields lint into dead_code, thus upgrading it from allow to warn [5]. In turn, this made rustc complain about the ThisModule's pointer field being never read, but the previous patch adds the as_ptr method to it, needed by Binder [6], so that we do not need to locally allow it.

Other changes

Rust 1.77.0 introduces the --check-cfg feature [7], for which there is a Call for Testing going on [8]. We were requested to test it and we found it useful [9] -- we will likely enable it in the future.

alloc upgrade and reviewing

The vast majority of changes are due to our alloc fork being upgraded at once.

There are two kinds of changes to be aware of: the ones coming from upstream, which we should follow as closely as possible, and the updates needed in our added fallible APIs to keep them matching the newer infallible APIs coming from upstream.

Instead of taking a look at the diff of this patch, an alternative approach is reviewing a diff of the changes between upstream alloc and the kernel's. This allows to easily inspect the kernel additions only, especially to check if the fallible methods we already have still match the infallible ones in the new version coming from upstream.

Another approach is reviewing the changes introduced in the additions in the kernel fork between the two versions. This is useful to spot potentially unintended changes to our additions.

To apply these approaches, one may follow steps similar to the following to generate a pair of patches that show the differences between upstream Rust and the kernel (for the subset of alloc we use) before and after applying this patch:

# Get the difference with respect to the old version.
git -C rust checkout $(linux/scripts/min-tool-version.sh rustc)
git -C linux ls-tree -r --name-only HEAD -- rust/alloc |
    cut -d/ -f3- |
    grep -Fv README.md |
    xargs -IPATH cp rust/library/alloc/src/PATH linux/rust/alloc/PATH
git -C linux diff --patch-with-stat --summary -R > old.patch
git -C linux restore rust/alloc

# Apply this patch.
git -C linux am rust-upgrade.patch

# Get the difference with respect to the new version.
git -C rust checkout $(linux/scripts/min-tool-version.sh rustc)
git -C linux ls-tree -r --name-only HEAD -- rust/alloc |
    cut -d/ -f3- |
    grep -Fv README.md |
    xargs -IPATH cp rust/library/alloc/src/PATH linux/rust/alloc/PATH
git -C linux diff --patch-with-stat --summary -R > new.patch
git -C linux restore rust/alloc

Now one may check the new.patch to take a look at the additions (first approach) or at the difference between those two patches (second approach). For the latter, a side-by-side tool is recommended.

Link: https://github.com/rust-lang/rust/blob/stable/RELEASES.md#version-1770-2024-03-21 [1] Link: https://rust-for-linux.com/rust-version-policy [2] Link: rust-lang/rust#118799 [3] Link: #2 [4] Link: rust-lang/rust#118297 [5] Link: https://lore.kernel.org/rust-for-linux/20231101-rust-binder-v1-2-08ba9197f637@google.com/#Z31rust:kernel:lib.rs [6] Link: https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html [7] Link: rust-lang/rfcs#3013 (comment) [8] Link: rust-lang/rust#82450 (comment) [9] Reviewed-by: Alice Ryhl aliceryhl@google.com Tested-by: Boqun Feng boqun.feng@gmail.com Link: https://lore.kernel.org/r/20240217002717.57507-1-ojeda@kernel.org [ Upgraded to 1.77.1. Removed allow(dead_code) thanks to the previous patch. Reworded accordingly. No changes to alloc during the beta. ] Signed-off-by: Miguel Ojeda ojeda@kernel.org

sweettea pushed a commit to sweettea/btrfs-fscrypt that referenced this pull request

Apr 3, 2024

@ojeda @sweettea

This is the next upgrade to the Rust toolchain, from 1.76.0 to 1.77.1 (i.e. the latest) [1].

See the upgrade policy [2] and the comments on the first upgrade in commit 3ed03f4 ("rust: upgrade to Rust 1.68.2").

Unstable features

The offset_of feature (single-field offset_of!) that we were using got stabilized in Rust 1.77.0 [3].

Therefore, now the only unstable features allowed to be used outside the kernel crate is new_uninit, though other code to be upstreamed may increase the list.

Please see [4] for details.

Required changes

Rust 1.77.0 merged the unused_tuple_struct_fields lint into dead_code, thus upgrading it from allow to warn [5]. In turn, this made rustc complain about the ThisModule's pointer field being never read, but the previous patch adds the as_ptr method to it, needed by Binder [6], so that we do not need to locally allow it.

Other changes

Rust 1.77.0 introduces the --check-cfg feature [7], for which there is a Call for Testing going on [8]. We were requested to test it and we found it useful [9] -- we will likely enable it in the future.

alloc upgrade and reviewing

The vast majority of changes are due to our alloc fork being upgraded at once.

There are two kinds of changes to be aware of: the ones coming from upstream, which we should follow as closely as possible, and the updates needed in our added fallible APIs to keep them matching the newer infallible APIs coming from upstream.

Instead of taking a look at the diff of this patch, an alternative approach is reviewing a diff of the changes between upstream alloc and the kernel's. This allows to easily inspect the kernel additions only, especially to check if the fallible methods we already have still match the infallible ones in the new version coming from upstream.

Another approach is reviewing the changes introduced in the additions in the kernel fork between the two versions. This is useful to spot potentially unintended changes to our additions.

To apply these approaches, one may follow steps similar to the following to generate a pair of patches that show the differences between upstream Rust and the kernel (for the subset of alloc we use) before and after applying this patch:

# Get the difference with respect to the old version.
git -C rust checkout $(linux/scripts/min-tool-version.sh rustc)
git -C linux ls-tree -r --name-only HEAD -- rust/alloc |
    cut -d/ -f3- |
    grep -Fv README.md |
    xargs -IPATH cp rust/library/alloc/src/PATH linux/rust/alloc/PATH
git -C linux diff --patch-with-stat --summary -R > old.patch
git -C linux restore rust/alloc

# Apply this patch.
git -C linux am rust-upgrade.patch

# Get the difference with respect to the new version.
git -C rust checkout $(linux/scripts/min-tool-version.sh rustc)
git -C linux ls-tree -r --name-only HEAD -- rust/alloc |
    cut -d/ -f3- |
    grep -Fv README.md |
    xargs -IPATH cp rust/library/alloc/src/PATH linux/rust/alloc/PATH
git -C linux diff --patch-with-stat --summary -R > new.patch
git -C linux restore rust/alloc

Now one may check the new.patch to take a look at the additions (first approach) or at the difference between those two patches (second approach). For the latter, a side-by-side tool is recommended.

Link: https://github.com/rust-lang/rust/blob/stable/RELEASES.md#version-1770-2024-03-21 [1] Link: https://rust-for-linux.com/rust-version-policy [2] Link: rust-lang/rust#118799 [3] Link: Rust-for-Linux#2 [4] Link: rust-lang/rust#118297 [5] Link: https://lore.kernel.org/rust-for-linux/20231101-rust-binder-v1-2-08ba9197f637@google.com/#Z31rust:kernel:lib.rs [6] Link: https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html [7] Link: rust-lang/rfcs#3013 (comment) [8] Link: rust-lang/rust#82450 (comment) [9] Reviewed-by: Alice Ryhl aliceryhl@google.com Tested-by: Boqun Feng boqun.feng@gmail.com Link: https://lore.kernel.org/r/20240217002717.57507-1-ojeda@kernel.org [ Upgraded to 1.77.1. Removed allow(dead_code) thanks to the previous patch. Reworded accordingly. No changes to alloc during the beta. ] Signed-off-by: Miguel Ojeda ojeda@kernel.org

This was referenced

Apr 20, 2024

SifraiTeam pushed a commit to grandinetech/grandine that referenced this pull request

Sep 6, 2024

@weekday-grandine-io

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request

Oct 13, 2024

@he32

This is based on the pkgsrc-wip rust180 package, retaining the main pkgsrc changes as best as I could.

Pkgsrc changes:

Upstream chnages:

Version 1.80.1 (2024-08-08)

Version 1.80.0 (2024-07-25)

Language

Compiler

Libraries

Stabilized APIs

These APIs are now stable in const contexts:

Cargo

Rustdoc

Compatibility Notes

Internal Changes

These changes do not affect any public interfaces of Rust, but they represent significant improvements to the performance or internals of rustc and related tools.

Version 1.79.0 (2024-06-13)

Language

Compiler

Refer to Rust's [platform support page][platform-support-doc] for more information on Rust's tiered platform support.

Libraries

Stabilized APIs

These APIs are now stable in const contexts:

Cargo

Rustdoc

Misc

Compatibility Notes

Version 1.78.0 (2024-05-02)

Language

Compiler

Target changes:

Refer to Rust's [platform support page][platform-support-doc] for more information on Rust's tiered platform support.

Libraries

Stabilized APIs

These APIs are now stable in const contexts:

Cargo

Misc

Compatibility Notes

Internal Changes

These changes do not affect any public interfaces of Rust, but they represent significant improvements to the performance or internals of rustc and related tools.

Version 1.77.0 (2024-03-21)

Compiler

Refer to Rust's [platform support page][platform-support-doc] for more information on Rust's tiered platform support.

Libraries

Stabilized APIs

Cargo

Rustdoc

Misc

Internal Changes

These changes do not affect any public interfaces of Rust, but they represent significant improvements to the performance or internals of rustc and related tools.

jdygert-spok added a commit to aranya-project/aranya-core that referenced this pull request

Oct 15, 2024

@jdygert-spok

Follpvosten pushed a commit to Follpvosten/nix-rust-quickstart that referenced this pull request

Nov 21, 2024

@CobaltCause