rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
13.62k stars 1.49k forks source link

lifetime param variance method in Hover Doc #17183

Closed A4-Tacks closed 2 weeks ago

A4-Tacks commented 2 weeks ago

Can an optional feature be added: when viewing HoverDoc of struct, etc., display whether the variance method of their lifetime param is covariant invariant or contravariant

Example

struct Foo<'a>(fn(&'a ()));
struct Bar<'a>(fn() -> &'a ());
struct Baz<'a>(fn(&'a ()) -> &'a ());

Hover Doc Output

struct Foo<'a> // size = 8, align = 0x8

---
'a: contravariant
struct Bar<'a> // size = 8, align = 0x8

---
'a: covariant
struct Baz<'a> // size = 8, align = 0x8

---
'a: invariant
Veykril commented 2 weeks ago

Duplicate of https://github.com/rust-lang/rust-analyzer/issues/13073