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

calling .into() on a Into<Box<...>> resolving to {unknown} #15675

Closed
vivax3794 opened this issue Sep 27, 2023 · 1 comment
Closed

calling .into() on a Into<Box<...>> resolving to {unknown} #15675

vivax3794 opened this issue Sep 27, 2023 · 1 comment
Labels
C-bug Category: bug

Comments

@vivax3794
Copy link

rust-analyzer version: 0.3.1673-standalone
rustc version: rustc 1.72.1 (d5c2e9c34 2023-09-13)

The follow code:

fn bar(_: &str) {}

fn foo<T: Into<Box<str>>>(x: T) {
    let y = x.into();
    bar(&y);
}

compiles fine, and of course the type of y is Box<str>, but the inlay hints (and hover) are saying something else:
image

this isnt just happening with Box<str> but seems to happen to any Into<Box<_>>, and it look to just pick up whatever it guesses based on the usage (like above it saw &y when a &str is expected to guessed y must be a str), so you can get some pretty strange stuff:

image
(of course in this case it wont compile, but it shows that rust analyzer is just picking up what ever you use it as)

@vivax3794 vivax3794 added the C-bug Category: bug label Sep 27, 2023
@lnicola
Copy link
Member

lnicola commented Sep 27, 2023

Duplicate of #5514.

@lnicola lnicola closed this as completed Sep 27, 2023
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