Use explicit match for extracting def from `classify_name`
use hir::Semantics;
use ra_ide_db::{
- defs::{classify_name, classify_name_ref},
+ defs::{classify_name, classify_name_ref, NameClass},
symbol_index, RootDatabase,
};
use ra_syntax::{
@@ -39,7 +39,10 @@ pub(crate) fn goto_definition(
reference_definition(&sema, &name_ref).to_vec()
},
ast::Name(name) => {
- let def = classify_name(&sema, &name)?.into_definition()?;
+ let def = match classify_name(&sema, &name)? {
+ NameClass::Definition(def) | NameClass::ConstReference(def) => def,
+ NameClass::FieldShorthand { local: _, field } => field,
+ };
let nav = def.try_to_nav(sema.db)?;
vec![nav]
},
