3 ms·
> I can't get any dot-completions on vpt > Even more weird is that if I add a type declaration to "let vpt" (specifying the same type that would be inferred), t
by saghm 9y ago
> I can't get any dot-completions on vpt
> Even more weird is that if I add a type declaration to "let vpt" (specifying the same type that would be inferred), then completion works
I'm fairly certain the reason for this is that RLS (and every other Rust editor/tool I've tried) isn't able to handle completions for things coming from macros (transitively or otherwise). Although the prevalence of the `vec!` macro might make it seem like the completion is "extremely basic", variables coming from macros are pretty much the only case I've found that RLS can't completely properly for. If you manually write the code that the macro would produce (i.e. `{ let mut temp = Vec::new(); temp.push(pt); temp }`, I think it should work fine.
- tomjakubowski 9y agoIt might also help to manually annotate the type of the binding being assigned to. let v: Vec<i32> = vec![ pt ]; let vpt = &v[0];
- int_19h 9y agoNope, doesn't help (corrected to Vec<Point>). The only thing that works is annotating the vpt binding itself. In any case, if you have to annotate all local bindings for completion to work, that's not idiomatic Rust anymore. Another interesting thing that I've noticed, is that it does know what vpt.x and vpt.y are - when hovering over them, it correctly says that they're i32. So the type inference works as it should. It's specifically completion that is broken here for some unclear reason.
- saghm 9y agoI wonder if this is an issue with the VSCode extension rather than the RLS then; all RLS can do is provide information to the extension, so maybe the extension just isn't using the information.
- int_19h 9y agoIt's not an issue with vec! - the same problem occurs if I use Vector::new and push. It seems to be a problem with the vector itself, or perhaps indexing. Besides, it does know the type of vpt in code snippet above - like I said, when I hover about it, it correctly tells me that it's &Point. So it clearly can handle macros, or at least vec! specifically.