Re: [PATCH 2/5] rust: pin-init: properly document let binding workaround

From: Gary Guo

Date: Thu Mar 19 2026 - 11:24:18 EST


On Thu Mar 19, 2026 at 2:44 PM GMT, Benno Lossin wrote:
> On Thu Mar 19, 2026 at 12:04 PM CET, Gary Guo wrote:
>> On Thu Mar 19, 2026 at 9:35 AM GMT, Benno Lossin wrote:
>>> The three let bindings (in the bodies of `cast_init`, `cast_pin_init`
>>> and the `init!` macro) are used to avoid the following compiler error in
>>> Rust 1.78.0, 1.79.0, 1.80.0, 1.80.1, and 1.81.0 (just showing the one
>>> for `cast_init`, the others are similar):
>>>
>>> error[E0391]: cycle detected when computing type of opaque `cast_init::{opaque#0}`
>>> --> src/lib.rs:1160:66
>>> |
>>> 1160 | pub const unsafe fn cast_init<T, U, E>(init: impl Init<T, E>) -> impl Init<U, E> {
>>> | ^^^^^^^^^^^^^^^
>>> |
>>> note: ...which requires borrow-checking `cast_init`...
>>> --> src/lib.rs:1160:1
>>> |
>>> 1160 | pub const unsafe fn cast_init<T, U, E>(init: impl Init<T, E>) -> impl Init<U, E> {
>>> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>> note: ...which requires const checking `cast_init`...
>>> --> src/lib.rs:1160:1
>>> |
>>> 1160 | pub const unsafe fn cast_init<T, U, E>(init: impl Init<T, E>) -> impl Init<U, E> {
>>> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>> = note: ...which requires computing whether `cast_init::{opaque#0}` is freeze...
>>> = note: ...which requires evaluating trait selection obligation `cast_init::{opaque#0}: core::marker::Freeze`...
>>> = note: ...which again requires computing type of opaque `cast_init::{opaque#0}`, completing the cycle
>>> note: cycle used when computing type of `cast_init::{opaque#0}`
>>> --> src/lib.rs:1160:66
>>> |
>>> 1160 | pub const unsafe fn cast_init<T, U, E>(init: impl Init<T, E>) -> impl Init<U, E> {
>>> | ^^^^^^^^^^^^^^^
>>> = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
>>>
>>> Once we raise the nightly-MSRV above 1.81, we can remove this
>>> workaround.
>>>
>>> Link: https://github.com/Rust-for-Linux/pin-init/commit/bb3e96f3e9a4f5fca80a22af883c7e5aa90f0893
>>> [ Moved this commit after the previous one to avoid a build failure due
>>> to unstable features. Changed the cfg to use `USE_RUSTC_FEAUTURES`.
>>> - Benno ]
>>> Signed-off-by: Benno Lossin <lossin@xxxxxxxxxx>
>>
>> Reviewed-by: Gary Guo <gary@xxxxxxxxxxx>
>>
>> Perhaps we should import review approvals on GitHub as R-bs.
>
> Yeah we should. A quick internet search didn't reveal a magic tool to
> me. Do you know of any?

One idea that I have:
* Re-target a PR to a temporary branch and merge it
* Have a GitHub action that walks through PR in staging branch and applies
tagging before putting it into the main branch.

Fighting with branch protection rule might be needed:
https://github.com/orgs/community/discussions/13836

Best,
Gary