mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-28 05:53:45 +00:00
fix missing name enum when hovering on fields in variants
This commit is contained in:
parent
dc90d2d7ff
commit
5a3d1a6d0d
2 changed files with 14 additions and 3 deletions
|
@ -5,7 +5,7 @@ use either::Either;
|
||||||
use hir::{
|
use hir::{
|
||||||
db::ExpandDatabase, Adt, AsAssocItem, AsExternAssocItem, AssocItemContainer, CaptureKind,
|
db::ExpandDatabase, Adt, AsAssocItem, AsExternAssocItem, AssocItemContainer, CaptureKind,
|
||||||
DynCompatibilityViolation, HasCrate, HasSource, HirDisplay, Layout, LayoutError,
|
DynCompatibilityViolation, HasCrate, HasSource, HirDisplay, Layout, LayoutError,
|
||||||
MethodViolationCode, Name, Semantics, Symbol, Trait, Type, TypeInfo,
|
MethodViolationCode, Name, Semantics, Symbol, Trait, Type, TypeInfo, VariantDef,
|
||||||
};
|
};
|
||||||
use ide_db::{
|
use ide_db::{
|
||||||
base_db::SourceDatabase,
|
base_db::SourceDatabase,
|
||||||
|
@ -378,7 +378,18 @@ pub(super) fn process_markup(
|
||||||
|
|
||||||
fn definition_owner_name(db: &RootDatabase, def: &Definition, edition: Edition) -> Option<String> {
|
fn definition_owner_name(db: &RootDatabase, def: &Definition, edition: Edition) -> Option<String> {
|
||||||
match def {
|
match def {
|
||||||
Definition::Field(f) => Some(f.parent_def(db).name(db)),
|
Definition::Field(f) => {
|
||||||
|
let parent = f.parent_def(db);
|
||||||
|
let parent_name = parent.name(db);
|
||||||
|
let parent_name = parent_name.display(db, edition).to_string();
|
||||||
|
return match parent {
|
||||||
|
VariantDef::Variant(variant) => {
|
||||||
|
let enum_name = variant.parent_enum(db).name(db);
|
||||||
|
Some(format!("{}::{parent_name}", enum_name.display(db, edition)))
|
||||||
|
}
|
||||||
|
_ => Some(parent_name),
|
||||||
|
};
|
||||||
|
}
|
||||||
Definition::Local(l) => l.parent(db).name(db),
|
Definition::Local(l) => l.parent(db).name(db),
|
||||||
Definition::Variant(e) => Some(e.parent_enum(db).name(db)),
|
Definition::Variant(e) => Some(e.parent_enum(db).name(db)),
|
||||||
|
|
||||||
|
|
|
@ -7294,7 +7294,7 @@ enum Enum {
|
||||||
*field*
|
*field*
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
ra_test_fixture::RecordV
|
ra_test_fixture::Enum::RecordV
|
||||||
```
|
```
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
|
|
Loading…
Reference in a new issue