Skip to content

Comments

properly document let binding workaround#108

Merged
BennoLossin merged 1 commit intomainfrom
dev/msrv-clippy-comment
Feb 24, 2026
Merged

properly document let binding workaround#108
BennoLossin merged 1 commit intomainfrom
dev/msrv-clippy-comment

Conversation

@BennoLossin
Copy link
Member

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.

@BennoLossin BennoLossin requested a review from nbdd0121 February 24, 2026 08:11
@BennoLossin BennoLossin force-pushed the dev/msrv-clippy-comment branch 3 times, most recently from f650a66 to e3f5827 Compare February 24, 2026 08:23
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.

Signed-off-by: Benno Lossin <lossin@kernel.org>
@BennoLossin BennoLossin force-pushed the dev/msrv-clippy-comment branch from e3f5827 to bb3e96f Compare February 24, 2026 08:30
@BennoLossin
Copy link
Member Author

@nbdd0121 happy with this?

@BennoLossin
Copy link
Member Author

Ah this also conflicts with #102, we can merge that first as well.

@BennoLossin BennoLossin merged commit 54f5649 into main Feb 24, 2026
26 checks passed
@BennoLossin BennoLossin deleted the dev/msrv-clippy-comment branch February 24, 2026 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants