-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Fails to identify type of vec![] macro #6837
Comments
I can't reproduce this with current rust-analyzer. Can you check whether it's still happening? |
Yes, I've just updated rust-analyzer vscode plugin, the language server, and rustup. The issue is still here. If it's relevant, I'm using |
Ah wait, I missed that this is with nightly rust. |
Yeah, I'm pretty sure it's to do with the new allocator API adding extra type parameters to |
Ah, |
I've got the same problem but with stable rust v 1.50 |
It's the let a = <[_]>::into_vec(Box::new([1i32])); // Vec<i32, Global>
let a = <[_]>::into_vec(box [1i32]); // Vec<{unknown}, {unknown}> I think RA doesn't figure out the allocator parameter when using < [INFO hir_ty::traits] trait_solve_query(Implements(fn new<?0.0>(?0.0) -> Box<?0.0, Global>: Deref))
< [INFO hir_ty::traits] trait_solve_query(Implements(Box<[i32; _], Global>: CoerceUnsized<Box<[?0.0], ?0.1>>))
> [INFO hir_ty::traits] trait_solve_query(Implements(Box<[i32; _], ?0.0>: CoerceUnsized<Box<[?0.1], ?0.2>>)) |
How does |
According to rust#58457):
So at the moment |
Tried it out, and turns out that box_syntax currently always uses |
Ok, that's probably the reason it doesn't work then. The handling for the box syntax is here: |
In an empty (latest rust-analyzer, nightly rust) VSCode project, I am getting the following (related) errors to do with the
![image](https://user-images.githubusercontent.com/50671761/101955389-9bb09780-3bf5-11eb-95b7-783ab28dd90c.png)
![image](https://user-images.githubusercontent.com/50671761/101955513-de726f80-3bf5-11eb-8675-45c40f83f2c5.png)
vec!
macro.It seems as if rust-analyzer is maybe unable to resolve the second type parameter related to the new allocator API, and that error stops it from filling in the first parameter. Weirdly, it semi-correctly identifies a
char
in the following image, but thinks that it is part of an array.It also identifies
vec!["];
to be aVec<[&str; _]>
.This is probably not a direct repeat of #6668 - I'm using a nightly version of rust-analyzer released after that issue was patched. Also, using the normal
Vec
constructor, and adding elements in afterwards, works fine thanks to type inference - it's only a problem with the macro, it seems.The text was updated successfully, but these errors were encountered: