rust: pin-init: replace clippy `expect` with `allow`
Subsystems (2)
Benno Lossin
maintainerPATCH 1/1 rust: pin-init: replace clippy `expect` with `allow`
clippy has changed behavior in [1] (Rust 1.95) where it no longer warns about the let_and_return lint when a comment is placed between the let binding and the return expression. Nightly thus fails to build, because the expectation is no longer fulfilled.
Thus replace the expectation with an allow.
--- rust/pin-init/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
rust/pin-init/src/lib.rs +2 -2
@@ -1143,13 +1143,13 @@ unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {/// /// - `*mut U` must be castable to `*mut T` and any value of type `T` written through such a /// pointer must result in a valid `U`. -#[expect(clippy::let_and_return)] pub const unsafe fn cast_pin_init <T ,U ,E >(init:impl PinInit <T ,E >) ->impl PinInit <U ,E > {// SAFETY: initialization delegated to a valid initializer. Cast is valid by function safety // requirements. let res =unsafe {pin_init_from_closure (|ptr: *mut U | init.__pinned_init (ptr.cast ::<T >())) };// FIXME: remove the let statement once the nightly-MSRV allows it (1.78 otherwise encounters a // cycle when computing the type returned by this function) +#[allow(clippy::let_and_return)] res }
@@ -1159,13 +1159,13 @@ unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {/// /// - `*mut U` must be castable to `*mut T` and any value of type `T` written through such a /// pointer must result in a valid `U`. -#[expect(clippy::let_and_return)] pub const unsafe fn cast_init <T ,U ,E >(init:impl Init <T ,E >) ->impl Init <U ,E > {// SAFETY: initialization delegated to a valid initializer. Cast is valid by function safety // requirements. let res =unsafe {init_from_closure (|ptr: *mut U | init.__init (ptr.cast ::<T >())) };// FIXME: remove the let statement once the nightly-MSRV allows it (1.78 otherwise encounters a // cycle when computing the type returned by this function) +#[allow(clippy::let_and_return)] res }
base-commit: ca4ee40bf13dbd3a4be3b40a00c33a1153d487e5
Signature · 1 line
2.52.0
Tamir Duberstein
reviewerQuoted 20 lines · Benno Lossin
clippyhas changed behavior in [1] (Rust 1.95) where it no longer warns about thelet_and_returnlint when a comment is placed between the let binding and the return expression. Nightly thus fails to build, because the expectation is no longer fulfilled.Thus replace the expectation with an
allow.Signed-off-by Benno Lossin <[email protected]>--- rust/pin-init/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)rust/pin-init/src/lib.rs +0
-0@@ -1143,13 +1143,13 @@ unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {///
rust/pin-init/src/lib.rs unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> { · line 1152
Quoted 10 lines
rust/pin-init/src/lib.rs +1
-1/// - `*mut U` must be castable to `*mut T` and any value of type `T` written through such a /// pointer must result in a valid `U`. -#[expect(clippy::let_and_return)] pub const unsafe fn cast_pin_init <T ,U ,E >(init:impl PinInit <T ,E >) ->impl PinInit <U ,E > {// SAFETY: initialization delegated to a valid initializer. Cast is valid by function safety // requirements. let res =unsafe {pin_init_from_closure (|ptr: *mut U | init.__pinned_init (ptr.cast ::<T >())) };// FIXME: remove the let statement once the nightly-MSRV allows it (1.78 otherwise encounters a // cycle when computing the type returned by this function) +#[allow(clippy::let_and_return)]
Consider adding reason = "...".
Quoted 5 lines
rust/pin-init/src/lib.rs +0
-0res }@@ -1159,13 +1159,13 @@ unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {///
rust/pin-init/src/lib.rs unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> { · line 1168
Quoted 10 lines
rust/pin-init/src/lib.rs +1
-1/// - `*mut U` must be castable to `*mut T` and any value of type `T` written through such a /// pointer must result in a valid `U`. -#[expect(clippy::let_and_return)] pub const unsafe fn cast_init <T ,U ,E >(init:impl Init <T ,E >) ->impl Init <U ,E > {// SAFETY: initialization delegated to a valid initializer. Cast is valid by function safety // requirements. let res =unsafe {init_from_closure (|ptr: *mut U | init.__init (ptr.cast ::<T >())) };// FIXME: remove the let statement once the nightly-MSRV allows it (1.78 otherwise encounters a // cycle when computing the type returned by this function) +#[allow(clippy::let_and_return)]
Consider adding reason = "...".
Quoted 9 lines
rust/pin-init/src/lib.rs +0
-0res }base-commit:
ca4ee40bf13dbd3a4be3b40a00c33a1153d487e5--
2.52.0
Benno Lossin
maintainerQuoted 25 lines · Tamir Duberstein
Quoted 24 lines · Benno Lossin
clippyhas changed behavior in [1] (Rust 1.95) where it no longer warns about thelet_and_returnlint when a comment is placed between the let binding and the return expression. Nightly thus fails to build, because the expectation is no longer fulfilled.Thus replace the expectation with an
allow.Signed-off-by Benno Lossin <[email protected]>--- rust/pin-init/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)rust/pin-init/src/lib.rs +0
-1@@ -1143,13 +1143,13 @@ unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {/// /// - `*mut U` must be castable to `*mut T` and any value of type `T` written through such a /// pointer must result in a valid `U`. -#[expect(clippy::let_and_return)] pub const unsafe fn cast_pin_init <T ,U ,E >(init:impl PinInit <T ,E >) ->impl PinInit <U ,E > {
Quoted 8 lines
rust/pin-init/src/lib.rs unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> { · line 1152
Quoted 6 lines
rust/pin-init/src/lib.rs +1
-0// SAFETY: initialization delegated to a valid initializer. Cast is valid by function safety // requirements. let res =unsafe {pin_init_from_closure (|ptr: *mut U | init.__pinned_init (ptr.cast ::<T >())) };// FIXME: remove the let statement once the nightly-MSRV allows it (1.78 otherwise encounters a // cycle when computing the type returned by this function) +#[allow(clippy::let_and_return)] Consider adding
reason = "...".
Isn't the FIXME comment directly above enough? I don't want to duplicate the information and the string constant explaining the reason looks ugly.
Cheers,
Benno
Tamir Duberstein
reviewerQuoted 36 lines · Benno Lossin
Quoted 25 lines · Tamir Duberstein
Quoted 24 lines · Benno Lossin
clippyhas changed behavior in [1] (Rust 1.95) where it no longer warns about thelet_and_returnlint when a comment is placed between the let binding and the return expression. Nightly thus fails to build, because the expectation is no longer fulfilled.Thus replace the expectation with an
allow.Signed-off-by Benno Lossin <[email protected]>--- rust/pin-init/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)rust/pin-init/src/lib.rs +0
-1@@ -1143,13 +1143,13 @@ unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {/// /// - `*mut U` must be castable to `*mut T` and any value of type `T` written through such a /// pointer must result in a valid `U`. -#[expect(clippy::let_and_return)] pub const unsafe fn cast_pin_init <T ,U ,E >(init:impl PinInit <T ,E >) ->impl PinInit <U ,E > {Quoted 8 lines
rust/pin-init/src/lib.rs unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> { · line 1152
Quoted 6 lines
rust/pin-init/src/lib.rs +1
-0// SAFETY: initialization delegated to a valid initializer. Cast is valid by function safety // requirements. let res =unsafe {pin_init_from_closure (|ptr: *mut U | init.__pinned_init (ptr.cast ::<T >())) };// FIXME: remove the let statement once the nightly-MSRV allows it (1.78 otherwise encounters a // cycle when computing the type returned by this function) +#[allow(clippy::let_and_return)] Consider adding
reason = "...".
Quoted 3 lines
Isn't the FIXME comment directly above enough? I don't want to duplicate the information and the string constant explaining the reason looks ugly.
The FIXME explains why the allowance is needed, but it doesn't explain why it is an allow rather than an expect.
Benno Lossin
maintainerQuoted 18 lines · Tamir Duberstein
Quoted 17 lines · Benno Lossin
Quoted 15 lines · Tamir Duberstein
rust/pin-init/src/lib.rs unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> { · line 1152
Quoted 12 lines · Benno Lossin
rust/pin-init/src/lib.rs +1
-1@@ -1143,13 +1143,13 @@ unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {/// /// - `*mut U` must be castable to `*mut T` and any value of type `T` written through such a /// pointer must result in a valid `U`. -#[expect(clippy::let_and_return)] pub const unsafe fn cast_pin_init <T ,U ,E >(init:impl PinInit <T ,E >) ->impl PinInit <U ,E > {// SAFETY: initialization delegated to a valid initializer. Cast is valid by function safety // requirements. let res =unsafe {pin_init_from_closure (|ptr: *mut U | init.__pinned_init (ptr.cast ::<T >())) };// FIXME: remove the let statement once the nightly-MSRV allows it (1.78 otherwise encounters a // cycle when computing the type returned by this function) +#[allow(clippy::let_and_return)] Consider adding
reason = "...".
Quoted 6 lines
Quoted 3 lines
Isn't the FIXME comment directly above enough? I don't want to duplicate the information and the string constant explaining the reason looks ugly.
The FIXME explains why the allowance is needed, but it doesn't explain why it is an allow rather than an expect.
I don't see much value in documenting that in the code. This'll be removed once we raise the MSRV, which should happen later this year. If one really wants to know why it's there, there is the git log.
Cheers,
Benno
Quoted 9 lines · Benno Lossin
clippyhas changed behavior in [1] (Rust 1.95) where it no longer warns about thelet_and_returnlint when a comment is placed between the let binding and the return expression. Nightly thus fails to build, because the expectation is no longer fulfilled.Thus replace the expectation with an
allow.Signed-off-by Benno Lossin <[email protected]>
I think it's worth adding a comment (or reason) that this is no longer needed after 1.95.
With that:
Quoted 40 lines
--- rust/pin-init/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)rust/pin-init/src/lib.rs +2
-2@@ -1143,13 +1143,13 @@ unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {/// /// - `*mut U` must be castable to `*mut T` and any value of type `T` written through such a /// pointer must result in a valid `U`. -#[expect(clippy::let_and_return)] pub const unsafe fn cast_pin_init <T ,U ,E >(init:impl PinInit <T ,E >) ->impl PinInit <U ,E > {// SAFETY: initialization delegated to a valid initializer. Cast is valid by function safety // requirements. let res =unsafe {pin_init_from_closure (|ptr: *mut U | init.__pinned_init (ptr.cast ::<T >())) };// FIXME: remove the let statement once the nightly-MSRV allows it (1.78 otherwise encounters a // cycle when computing the type returned by this function) +#[allow(clippy::let_and_return)] res }@@ -1159,13 +1159,13 @@ unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {/// /// - `*mut U` must be castable to `*mut T` and any value of type `T` written through such a /// pointer must result in a valid `U`. -#[expect(clippy::let_and_return)] pub const unsafe fn cast_init <T ,U ,E >(init:impl Init <T ,E >) ->impl Init <U ,E > {// SAFETY: initialization delegated to a valid initializer. Cast is valid by function safety // requirements. let res =unsafe {init_from_closure (|ptr: *mut U | init.__init (ptr.cast ::<T >())) };// FIXME: remove the let statement once the nightly-MSRV allows it (1.78 otherwise encounters a // cycle when computing the type returned by this function) +#[allow(clippy::let_and_return)] res }base-commit:
ca4ee40bf13dbd3a4be3b40a00c33a1153d487e5
Benno Lossin
maintainerQuoted 6 lines · Gary Guo
Quoted 5 lines · Benno Lossin
clippyhas changed behavior in [1] (Rust 1.95) where it no longer warns about thelet_and_returnlint when a comment is placed between the let binding and the return expression. Nightly thus fails to build, because the expectation is no longer fulfilled.
Quoted 6 lines
Quoted 4 lines
Thus replace the expectation with an
allow.Signed-off-by Benno Lossin <[email protected]>I think it's worth adding a comment (or reason) that this is no longer needed after 1.95.
We'll remove the let binding when we raise the MSRV above 1.78 and then the allow should also be gone. Do you still want me to add it?
Cheers,
Benno
Gary Guo
maintainerQuoted 12 lines · Benno Lossin
Quoted 11 lines · Gary Guo
Quoted 9 lines · Benno Lossin
clippyhas changed behavior in [1] (Rust 1.95) where it no longer warns about thelet_and_returnlint when a comment is placed between the let binding and the return expression. Nightly thus fails to build, because the expectation is no longer fulfilled.Thus replace the expectation with an
allow.Signed-off-by Benno Lossin <[email protected]>
Quoted 7 lines
Quoted 1 line
I think it's worth adding a comment (or reason) that this is no longer needed after 1.95.
We'll remove the let binding when we raise the MSRV above 1.78 and then the
allowshould also be gone. Do you still want me to add it?Cheers,
Benno
The existing comment just says that the bug exists in 1.78. So is it fixed in 1.79+? If so, please update the comment to say the MSRV that this is no longer needed, then I'm fine without reason for clippy allow.
Best,
Gary
Benno Lossin
maintainerQuoted 21 lines · Gary Guo
Quoted 20 lines · Benno Lossin
Quoted 8 lines · Gary Guo
Quoted 7 lines · Benno Lossin
clippyhas changed behavior in [1] (Rust 1.95) where it no longer warns about thelet_and_returnlint when a comment is placed between
the let binding and the return expression. Nightly thus fails to build,
because the expectation is no longer fulfilled.Quoted 7 lines
Quoted 4 lines
Thus replace the expectation with an
allow.Signed-off-by Benno Lossin <[email protected]>I think it's worth adding a comment (or reason) that this is no longer needed after 1.95.
We'll remove the let binding when we raise the MSRV above 1.78 and then the
allowshould also be gone. Do you still want me to add it?
Quoted 8 lines
Quoted 2 lines
Cheers,
BennoThe existing comment just says that the bug exists in 1.78. So is it fixed in 1.79+? If so,
please update the comment to say the MSRV that this is no longer needed, then I'm fine
without reason for clippy allow.
We discussed this in the meeting, Miguel will pick this patch as-is and I'll send a follow up to change the comment.
Cheers,
Benno
As we discaOn Sun, Feb 15, 2026 at 2:22 PM Benno Lossin
Quoted 10 lines · <[email protected]> wrote:
clippyhas changed behavior in [1] (Rust 1.95) where it no longer warns about thelet_and_returnlint when a comment is placed between the let binding and the return expression. Nightly thus fails to build, because the expectation is no longer fulfilled.Thus replace the expectation with an
allow.Signed-off-by Benno Lossin <[email protected]>
Thanks for figuring out the PR upstream, that is always helpful -- I also noticed it in the 2026-02-13 nightly, so this saved me having to dig into it.
If you want, when you decide it is ready, I can take it into rust-fixes.
By the way, if you send a new version, please include the error -- it makes it easier for others to find it later in lore.kernel.org. In case you don't have it around, this is what I got in that run from a few days ago:
error: this lint expectation is unfulfilled
--> rust/pin-init/src/lib.rs:1279:10
|
1279 | #[expect(clippy::let_and_return)]
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D unfulfilled-lint-expectations` implied by `-D warnings`
= help: to override `-D warnings` add#[allow(unfulfilled_lint_expectations)]
error: this lint expectation is unfulfilled
--> rust/pin-init/src/lib.rs:1295:10
|
1295 | #[expect(clippy::let_and_return)]
| ^^^^^^^^^^^^^^^^^^^^^^Cheers,
Miguel
Miguel Ojeda
AppliedQuoted 10 lines · Benno Lossin
clippyhas changed behavior in [1] (Rust 1.95) where it no longer warns about thelet_and_returnlint when a comment is placed between the let binding and the return expression. Nightly thus fails to build, because the expectation is no longer fulfilled.Thus replace the expectation with an
allow.Signed-off-by Benno Lossin <[email protected]>
Applied to rust-fixes -- thanks everyone!
Gary: I wasn't sure if you would have wanted me to pick your tag, since it was conditional to adding the message, but we agreed to add it later on. Just in case, I didn't add it to be on the safe side, but I can add it.
By the way, I added:
[ The errors were:
error: this lint expectation is unfulfilled
--> rust/pin-init/src/lib.rs:1279:10
|
1279 | #[expect(clippy::let_and_return)]
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D unfulfilled-lint-expectations` implied by-D warnings
= help: to override -D warnings add#[allow(unfulfilled_lint_expectations)]
error: this lint expectation is unfulfilled
--> rust/pin-init/src/lib.rs:1295:10
|
1295 | #[expect(clippy::let_and_return)]
| ^^^^^^^^^^^^^^^^^^^^^^
- Miguel ]Cheers,
Miguel