Auto merge of #16525 - Veykril:item-loc, r=Veykril

Abstract more over ItemTreeLoc-like structs

Allows reducing some code duplication by using functions generic over said structs. The diff isn't negative due to me adding some additional impls for completeness.
This commit is contained in:
bors 2024-02-10 10:47:37 +00:00
commit 1ef7a2329b
28 changed files with 409 additions and 413 deletions

View file

@ -23,7 +23,7 @@ fn render(ctx: RenderContext<'_>, const_: hir::Const) -> Option<CompletionItem>
.set_relevance(ctx.completion_relevance());
if let Some(actm) = const_.as_assoc_item(db) {
if let Some(trt) = actm.containing_trait_or_trait_impl(db) {
if let Some(trt) = actm.container_or_implemented_trait(db) {
item.trait_name(trt.name(db).to_smol_str());
}
}

View file

@ -75,7 +75,7 @@ fn render(
let ret_type = func.ret_type(db);
let assoc_item = func.as_assoc_item(db);
let trait_ = assoc_item.and_then(|trait_| trait_.containing_trait_or_trait_impl(db));
let trait_ = assoc_item.and_then(|trait_| trait_.container_or_implemented_trait(db));
let is_op_method = trait_.map_or(false, |trait_| completion.is_ops_trait(trait_));
let is_item_from_notable_trait =
@ -145,7 +145,7 @@ fn render(
}
None => {
if let Some(actm) = assoc_item {
if let Some(trt) = actm.containing_trait_or_trait_impl(db) {
if let Some(trt) = actm.container_or_implemented_trait(db) {
item.trait_name(trt.name(db).to_smol_str());
}
}

View file

@ -47,7 +47,7 @@ fn render(
.set_relevance(ctx.completion_relevance());
if let Some(actm) = type_alias.as_assoc_item(db) {
if let Some(trt) = actm.containing_trait_or_trait_impl(db) {
if let Some(trt) = actm.container_or_implemented_trait(db) {
item.trait_name(trt.name(db).to_smol_str());
}
}