mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
Deduplicate some code
This commit is contained in:
parent
bb0de88f24
commit
2ebf0c87c2
22 changed files with 299 additions and 234 deletions
|
@ -112,7 +112,7 @@ impl<'a> RenderContext<'a> {
|
|||
};
|
||||
is_assoc_deprecated
|
||||
|| assoc
|
||||
.containing_trait_or_trait_impl(db)
|
||||
.container_or_implemented_trait(db)
|
||||
.map(|trait_| self.is_deprecated(trait_))
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue