-
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
Wrong lifetime variance in hover for recursive types #19455
Comments
This is known and currently blocked on us bumping salsa to the version that has fixed point cycle support rust-analyzer/crates/hir-ty/src/variance.rs Lines 954 to 968 in 042e6d8
Anything recursive used currently falls back to bivariant |
Thanks for the quick response, wouldn't it be safer in some sense to fall back to |
My thinking there was I believe that bivariant always implies an error state in Rust (except for generics in function parameters), but you are correct that this may cause some things to incorrectly remain covariant or contravariant when they are in fact invariant. I imagine we properly fix this soon though, someone just needs to migrate us to the next salsa release (has to be cut still). The main annoyance there is that the general cycle handling changed and needs to adapted. |
At Carl Meyer's suggestion, we should hold off on updating to Salsa's new fixpoint iteration until he fixes an exponential blowup. |
rust-analyzer version:
rust-analyzer version: 0.3.2353-standalone (37acea8052 2025-03-23)
rustc version:
rustc 1.84.1 (e71f9a9a9 2025-01-27)
editor or extension: VSCode with rust-analyzer version
0.3.2353
code snippet to reproduce:
For all three defined structs if I hover over the
'a
parameter in VSCode it shows mebivariant
althoughRecursive
is covariant andRecursive1
andRecursive2
are invariant over'a
.This gets worse if for example the invariant structs are used together with other covariant types for example:
In this case when I hover over it, it shows
covariant
although in fact it is invariant.The text was updated successfully, but these errors were encountered: