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 problem with Into & .to_string() #18230

Closed
adsick opened this issue Oct 2, 2024 · 1 comment
Closed

Type inference problem with Into & .to_string() #18230

adsick opened this issue Oct 2, 2024 · 1 comment
Labels
C-bug Category: bug

Comments

@adsick
Copy link

adsick commented Oct 2, 2024

When using Into<String> paired with .to_string() RA fails to infer the type of the variable between the calls.

rust-analyzer version:

rust-analyzer version: 0.3.2129-standalone [/home/adsick/.vscode/extensions/rust-lang.rust-analyzer-0.3.2129-linux-x64/server/rust-analyzer]

rustc version: (eg. output of rustc -V)
rustc 1.80.0 (051478957 2024-07-21)

editor or extension: VSCode

code snippet to reproduce:

pub fn test(s: impl Into<String>) -> String {
    let s = s.into();
    // type of s is not known to the rust analyzer here
    // try typing `s.` and you will see no completions

    let s = s.to_string();
    // here rust analyzer knows that s is a String
    s
}

It's not critical but a tiny bit annoying.

@adsick adsick added the C-bug Category: bug label Oct 2, 2024
@flodiebold
Copy link
Member

Duplicate of #5514

@flodiebold flodiebold marked this as a duplicate of #5514 Oct 3, 2024
@flodiebold flodiebold closed this as not planned Won't fix, can't repro, duplicate, stale Oct 3, 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

2 participants