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

Trait bound impl Into not able to infer return type. #9729

Closed
jhgg opened this issue Jul 30, 2021 · 1 comment
Closed

Trait bound impl Into not able to infer return type. #9729

jhgg opened this issue Jul 30, 2021 · 1 comment

Comments

@jhgg
Copy link
Contributor

jhgg commented Jul 30, 2021

In both these examples, the type of y is unable to be inferred by rust-analyzer:

fn a(x: impl Into<String>) {
    let y = x.into();
    y.to_ascii_lowercase();
}

fn b<T>(x: T)
where
    T: Into<String>,
{
    let y = x.into();
    y.to_ascii_lowercase();
}

However, interestingly enough, if the following is defined in the file (to shadow built in Into) it works:

pub trait Into<T>: Sized {
    fn into(self) -> T;
}

On: rust-analyzer version: 8232804 2021-07-30 nightly & rustc 1.53.0 (53cb7b09b 2021-06-17)

2021-07-30_02-47-48

@flodiebold
Copy link
Member

Duplicate of #5514.

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

No branches or pull requests

2 participants