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

avoid breaking change in new Rust versions #45

Merged
merged 1 commit into from
Jul 17, 2024
Merged

Conversation

lcnr
Copy link

@lcnr lcnr commented Feb 15, 2024

Your crate will unfortunately stop compiling due to changes to compiler internals in rust-lang/rust#119989.

The affected pattern is the following

fn ret_string() -> &'static str {
    let slice = &[];
    
    let temp = if false {
        slice[0]
    } else {
        unsafe { slice.get_unchecked(0) }
        // Fixed by changing it to `*slice.get_unchecked(0)`.
        //
        // This incorrectly equates `slice[0]` of type `&?a` with
        // `slice.get_unchecked(0)` of type `&&?b` where `?a` and `?b`
        // are inference variables which are related via subtyping.
        // This previously resulting in a eager "occurs check" failure, causing
        // us to add an auto-deref step. We now stop to eagerly fail here
        // so the deref has to be added manually.
    };

    temp
}

for more details see rust-lang/rust#119989 (comment)

I apologize for the inconvenience.

@lcnr lcnr changed the title prevent breaking change in new Rust versions avoid breaking change in new Rust versions Feb 15, 2024
ytanay added a commit to pelanororg/lasso that referenced this pull request May 2, 2024
ytanay added a commit to pelanororg/lasso that referenced this pull request May 2, 2024
@Kixiron Kixiron merged commit d3addad into Kixiron:master Jul 17, 2024
8 of 14 checks passed
@lcnr lcnr deleted the patch-1 branch July 18, 2024 08:20
saethlin added a commit to redjack/lasso that referenced this pull request Jul 25, 2024
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.

2 participants