+ let name_class = match NameRefClass::classify(sema, &name_ref) {
+ Some(name_kind) => name_kind,
+ None if syntactic_name_ref_highlighting => {
+ return highlight_name_ref_by_syntax(name_ref, sema, krate)
+ }
+ // FIXME: Workaround for https://github.com/rust-analyzer/rust-analyzer/issues/10708
+ //
+ // Some popular proc macros (namely async_trait) will rewrite `self` in such a way that it no
+ // longer resolves via NameRefClass. If we can't be resolved, but we know we're a self token,
+ // within a function with a self param, pretend to still be `self`, rather than
+ // an unresolved reference.
+ None if name_ref.self_token().is_some() && is_in_fn_with_self_param(&name_ref) => {
+ return SymbolKind::SelfParam.into()
+ }
+ None => return HlTag::UnresolvedReference.into(),
+ };
+ let mut h = match name_class {
+ NameRefClass::Definition(def) => {
+ if let Definition::Local(local) = &def {
+ if let Some(name) = local.name(db) {
+ let shadow_count = bindings_shadow_count.entry(name.clone()).or_default();
+ *binding_hash = Some(calc_binding_hash(&name, *shadow_count))
+ }
+ };
+
+ let mut h = highlight_def(sema, krate, def);