mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 01:17:27 +00:00
Merge #11186
11186: minor: Simplify r=Veykril a=Veykril bors r+ Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
commit
22edf2e8a0
3 changed files with 15 additions and 15 deletions
|
@ -90,7 +90,7 @@ impl Completions {
|
|||
cov_mark::hit!(qualified_path_doc_hidden);
|
||||
return;
|
||||
}
|
||||
self.add_opt(render_resolution(RenderContext::new(ctx), local_name, resolution));
|
||||
self.add(render_resolution(RenderContext::new(ctx), local_name, resolution));
|
||||
}
|
||||
|
||||
pub(crate) fn add_macro(
|
||||
|
@ -103,7 +103,7 @@ impl Completions {
|
|||
Some(it) => it,
|
||||
None => return,
|
||||
};
|
||||
self.add_opt(render_macro(RenderContext::new(ctx), None, name, macro_));
|
||||
self.add(render_macro(RenderContext::new(ctx), None, name, macro_));
|
||||
}
|
||||
|
||||
pub(crate) fn add_function(
|
||||
|
|
|
@ -130,7 +130,7 @@ pub(crate) fn render_resolution(
|
|||
ctx: RenderContext<'_>,
|
||||
local_name: hir::Name,
|
||||
resolution: ScopeDef,
|
||||
) -> Option<CompletionItem> {
|
||||
) -> CompletionItem {
|
||||
render_resolution_(ctx, local_name, None, resolution)
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ pub(crate) fn render_resolution_with_import(
|
|||
ScopeDef::ModuleDef(hir::ModuleDef::TypeAlias(t)) => t.name(ctx.completion.db),
|
||||
_ => item_name(ctx.db(), import_edit.import.original_item)?,
|
||||
};
|
||||
render_resolution_(ctx, local_name, Some(import_edit), resolution)
|
||||
Some(render_resolution_(ctx, local_name, Some(import_edit), resolution))
|
||||
}
|
||||
|
||||
fn render_resolution_(
|
||||
|
@ -153,7 +153,7 @@ fn render_resolution_(
|
|||
local_name: hir::Name,
|
||||
import_to_add: Option<ImportEdit>,
|
||||
resolution: ScopeDef,
|
||||
) -> Option<CompletionItem> {
|
||||
) -> CompletionItem {
|
||||
let _p = profile::span("render_resolution");
|
||||
use hir::ModuleDef::*;
|
||||
|
||||
|
@ -161,10 +161,10 @@ fn render_resolution_(
|
|||
|
||||
let kind = match resolution {
|
||||
ScopeDef::ModuleDef(Function(func)) => {
|
||||
return Some(render_fn(ctx, import_to_add, Some(local_name), func));
|
||||
return render_fn(ctx, import_to_add, Some(local_name), func);
|
||||
}
|
||||
ScopeDef::ModuleDef(Variant(var)) if ctx.completion.pattern_ctx.is_none() => {
|
||||
return Some(render_variant(ctx, import_to_add, Some(local_name), var, None));
|
||||
return render_variant(ctx, import_to_add, Some(local_name), var, None);
|
||||
}
|
||||
ScopeDef::MacroDef(mac) => return render_macro(ctx, import_to_add, local_name, mac),
|
||||
ScopeDef::Unknown => {
|
||||
|
@ -176,7 +176,7 @@ fn render_resolution_(
|
|||
if let Some(import_to_add) = import_to_add {
|
||||
item.add_import(import_to_add);
|
||||
}
|
||||
return Some(item.build());
|
||||
return item.build();
|
||||
}
|
||||
|
||||
ScopeDef::ModuleDef(Variant(_)) => CompletionItemKind::SymbolKind(SymbolKind::Variant),
|
||||
|
@ -249,7 +249,7 @@ fn render_resolution_(
|
|||
if let Some(import_to_add) = import_to_add {
|
||||
item.add_import(import_to_add);
|
||||
}
|
||||
Some(item.build())
|
||||
item.build()
|
||||
}
|
||||
|
||||
fn scope_def_docs(db: &RootDatabase, resolution: ScopeDef) -> Option<hir::Documentation> {
|
||||
|
|
|
@ -19,7 +19,7 @@ pub(crate) fn render_macro(
|
|||
import_to_add: Option<ImportEdit>,
|
||||
name: hir::Name,
|
||||
macro_: hir::MacroDef,
|
||||
) -> Option<CompletionItem> {
|
||||
) -> CompletionItem {
|
||||
let _p = profile::span("render_macro");
|
||||
render(ctx, name, macro_, import_to_add)
|
||||
}
|
||||
|
@ -29,15 +29,15 @@ fn render(
|
|||
name: hir::Name,
|
||||
macro_: hir::MacroDef,
|
||||
import_to_add: Option<ImportEdit>,
|
||||
) -> Option<CompletionItem> {
|
||||
) -> CompletionItem {
|
||||
let db = completion.db;
|
||||
|
||||
let source_range = if completion.is_immediately_after_macro_bang() {
|
||||
cov_mark::hit!(completes_macro_call_if_cursor_at_bang_token);
|
||||
completion.token.parent().map(|it| it.text_range())
|
||||
completion.token.parent().map_or_else(|| ctx.source_range(), |it| it.text_range())
|
||||
} else {
|
||||
Some(ctx.source_range())
|
||||
}?;
|
||||
ctx.source_range()
|
||||
};
|
||||
|
||||
let name = name.to_smol_str();
|
||||
let docs = ctx.docs(macro_);
|
||||
|
@ -79,7 +79,7 @@ fn render(
|
|||
}
|
||||
};
|
||||
|
||||
Some(item.build())
|
||||
item.build()
|
||||
}
|
||||
|
||||
fn label(
|
||||
|
|
Loading…
Reference in a new issue