highlight: trait path
This commit is contained in:
parent
9ea8d5806d
commit
353829fc4e
@ -69,17 +69,10 @@ fn item_for_path_search(db: &dyn HirDatabase, item: ItemInNs) -> Option<ItemInNs
|
||||
ItemInNs::Types(_) | ItemInNs::Values(_) => match item_as_assoc(db, item) {
|
||||
Some(assoc_item) => match assoc_item.container(db) {
|
||||
AssocItemContainer::Trait(trait_) => ItemInNs::from(ModuleDef::from(trait_)),
|
||||
AssocItemContainer::Impl(impl_) => {
|
||||
let impled_trait = if matches!(assoc_item, AssocItem::Function(..)) {
|
||||
impl_.trait_(db)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
match impled_trait {
|
||||
None => ItemInNs::from(ModuleDef::from(impl_.self_ty(db).as_adt()?)),
|
||||
Some(t) => ItemInNs::from(ModuleDef::from(t)),
|
||||
}
|
||||
}
|
||||
AssocItemContainer::Impl(impl_) => match impl_.trait_(db) {
|
||||
None => ItemInNs::from(ModuleDef::from(impl_.self_ty(db).as_adt()?)),
|
||||
Some(trait_) => ItemInNs::from(ModuleDef::from(trait_)),
|
||||
},
|
||||
},
|
||||
None => item,
|
||||
},
|
||||
|
@ -510,7 +510,11 @@ fn highlight_method_call(
|
||||
if func.is_async(sema.db) {
|
||||
h |= HlMod::Async;
|
||||
}
|
||||
if func.as_assoc_item(sema.db).and_then(|it| it.containing_trait(sema.db)).is_some() {
|
||||
if func
|
||||
.as_assoc_item(sema.db)
|
||||
.and_then(|it| it.containing_trait_or_trait_impl(sema.db))
|
||||
.is_some()
|
||||
{
|
||||
h |= HlMod::Trait;
|
||||
}
|
||||
|
||||
|
@ -121,6 +121,6 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
||||
<span class="keyword">let</span> <span class="struct">Packed</span> <span class="brace">{</span> <span class="field">a</span><span class="colon">:</span> <span class="keyword unsafe">ref</span> <span class="variable declaration reference">_a</span> <span class="brace">}</span> <span class="operator">=</span> <span class="variable">packed</span><span class="semicolon">;</span>
|
||||
|
||||
<span class="comment">// unsafe auto ref of packed field</span>
|
||||
<span class="variable">packed</span><span class="operator">.</span><span class="field">a</span><span class="operator">.</span><span class="function associated reference unsafe">calls_autoref</span><span class="parenthesis">(</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
||||
<span class="variable">packed</span><span class="operator">.</span><span class="field">a</span><span class="operator">.</span><span class="function associated reference trait unsafe">calls_autoref</span><span class="parenthesis">(</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
||||
<span class="brace">}</span>
|
||||
<span class="brace">}</span></code></pre>
|
Loading…
Reference in New Issue
Block a user