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

type inference fails when using matching on an Option using .into() on an impl Into<Option<T>> #17307

Closed
databasedav opened this issue May 29, 2024 · 1 comment
Labels
C-bug Category: bug

Comments

@databasedav
Copy link

databasedav commented May 29, 2024

rust-analyzer version: 0.3.1975-standalone

rustc version: rustc 1.78.0 (9b00956e5 2024-04-29)

editor or extension: VSCode 1.89.1

code snippet to reproduce:

// let x: {unknown}
fn f1<T>(x_option: impl Into<Option<T>>) {
    if let Some(x) = x_option.into() {
        x;
    }
}

// let x: {unknown}
fn f2<T>(x_option: impl Into<Option<T>>) {
    match x_option.into() {
        Some(x) => { x; },
        _ => ()
    };
}

// let x: T
fn f3<T>(x_option: impl Into<Option<T>>) {
    if let Some(x) = Into::<Option<T>>::into(x_option) {
        x;
    }
}

i'm expecting f1 and f2 to give me let x: T like f3 does, but instead i get let x: {unknown}

also f1 and f2 compile regardless

@databasedav databasedav added the C-bug Category: bug label May 29, 2024
@databasedav databasedav changed the title type inference fails when using matching on an Option using Into::into type inference fails when using matching on an Option using .into() on an impl Into<Option<T>> May 29, 2024
@ChayimFriedman2
Copy link
Contributor

Dup of #5514.

@flodiebold flodiebold closed this as not planned Won't fix, can't repro, duplicate, stale Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

3 participants