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-mismatch Error Misattributed #14936

Closed
kierankasha opened this issue May 31, 2023 · 2 comments
Closed

type-mismatch Error Misattributed #14936

kierankasha opened this issue May 31, 2023 · 2 comments
Labels
A-ty type system / type inference / traits / method resolution C-bug Category: bug

Comments

@kierankasha
Copy link

rust-analyzer version: 0.3.1533-standalone

rustc version: rustc 1.67.1

I'm working on a library that includes a function that converts various input data into String format. I encountered a type-mismatch error in the VsCode plugin between &ToString and any type that is not already String/ &str. The Quick Fix recommendation is to add a reference. Doing so just perpetuates the error and the suggestion remains the same ad infinitum. Here is a minimal reproducible example where this issue occurs:

fn main() {
    convert_to_string(&0.02)
}

fn convert_to_string(argument: &dyn ToString) {
    let argument = argument.to_string();
    println!("{argument}");
}

image

When I build, run this example, or run clippy on this, no errors are identified by the compiler and I get the output that I want:
image

What's even stranger is this error was not identified by rust-analyzer yesterday. I tried disabling and re-enabling the plugin, uninstalling and reinstalling the plugin, and reverting to a pre-release version to no success.

@kierankasha kierankasha added the C-bug Category: bug label May 31, 2023
@lnicola
Copy link
Member

lnicola commented May 31, 2023

This is a duplicate of #11847, an old issue.

@lowr
Copy link
Contributor

lowr commented Jul 15, 2023

Closing as a duplicate of #11847. Thanks for the report though!

@lowr lowr closed this as not planned Won't fix, can't repro, duplicate, stale Jul 15, 2023
@lowr lowr added the A-ty type system / type inference / traits / method resolution label Jul 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ty type system / type inference / traits / method resolution C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

3 participants