Skip to content

Commit 22edf2e

Browse files
bors[bot]Veykril
andauthored
Merge #11186
11186: minor: Simplify r=Veykril a=Veykril bors r+ Co-authored-by: Lukas Wirth <[email protected]>
2 parents 7409880 + 5fbdf20 commit 22edf2e

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

crates/ide_completion/src/completions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl Completions {
9090
cov_mark::hit!(qualified_path_doc_hidden);
9191
return;
9292
}
93-
self.add_opt(render_resolution(RenderContext::new(ctx), local_name, resolution));
93+
self.add(render_resolution(RenderContext::new(ctx), local_name, resolution));
9494
}
9595

9696
pub(crate) fn add_macro(
@@ -103,7 +103,7 @@ impl Completions {
103103
Some(it) => it,
104104
None => return,
105105
};
106-
self.add_opt(render_macro(RenderContext::new(ctx), None, name, macro_));
106+
self.add(render_macro(RenderContext::new(ctx), None, name, macro_));
107107
}
108108

109109
pub(crate) fn add_function(

crates/ide_completion/src/render.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ pub(crate) fn render_resolution(
130130
ctx: RenderContext<'_>,
131131
local_name: hir::Name,
132132
resolution: ScopeDef,
133-
) -> Option<CompletionItem> {
133+
) -> CompletionItem {
134134
render_resolution_(ctx, local_name, None, resolution)
135135
}
136136

@@ -145,26 +145,26 @@ pub(crate) fn render_resolution_with_import(
145145
ScopeDef::ModuleDef(hir::ModuleDef::TypeAlias(t)) => t.name(ctx.completion.db),
146146
_ => item_name(ctx.db(), import_edit.import.original_item)?,
147147
};
148-
render_resolution_(ctx, local_name, Some(import_edit), resolution)
148+
Some(render_resolution_(ctx, local_name, Some(import_edit), resolution))
149149
}
150150

151151
fn render_resolution_(
152152
ctx: RenderContext<'_>,
153153
local_name: hir::Name,
154154
import_to_add: Option<ImportEdit>,
155155
resolution: ScopeDef,
156-
) -> Option<CompletionItem> {
156+
) -> CompletionItem {
157157
let _p = profile::span("render_resolution");
158158
use hir::ModuleDef::*;
159159

160160
let db = ctx.db();
161161

162162
let kind = match resolution {
163163
ScopeDef::ModuleDef(Function(func)) => {
164-
return Some(render_fn(ctx, import_to_add, Some(local_name), func));
164+
return render_fn(ctx, import_to_add, Some(local_name), func);
165165
}
166166
ScopeDef::ModuleDef(Variant(var)) if ctx.completion.pattern_ctx.is_none() => {
167-
return Some(render_variant(ctx, import_to_add, Some(local_name), var, None));
167+
return render_variant(ctx, import_to_add, Some(local_name), var, None);
168168
}
169169
ScopeDef::MacroDef(mac) => return render_macro(ctx, import_to_add, local_name, mac),
170170
ScopeDef::Unknown => {
@@ -176,7 +176,7 @@ fn render_resolution_(
176176
if let Some(import_to_add) = import_to_add {
177177
item.add_import(import_to_add);
178178
}
179-
return Some(item.build());
179+
return item.build();
180180
}
181181

182182
ScopeDef::ModuleDef(Variant(_)) => CompletionItemKind::SymbolKind(SymbolKind::Variant),
@@ -249,7 +249,7 @@ fn render_resolution_(
249249
if let Some(import_to_add) = import_to_add {
250250
item.add_import(import_to_add);
251251
}
252-
Some(item.build())
252+
item.build()
253253
}
254254

255255
fn scope_def_docs(db: &RootDatabase, resolution: ScopeDef) -> Option<hir::Documentation> {

crates/ide_completion/src/render/macro_.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub(crate) fn render_macro(
1919
import_to_add: Option<ImportEdit>,
2020
name: hir::Name,
2121
macro_: hir::MacroDef,
22-
) -> Option<CompletionItem> {
22+
) -> CompletionItem {
2323
let _p = profile::span("render_macro");
2424
render(ctx, name, macro_, import_to_add)
2525
}
@@ -29,15 +29,15 @@ fn render(
2929
name: hir::Name,
3030
macro_: hir::MacroDef,
3131
import_to_add: Option<ImportEdit>,
32-
) -> Option<CompletionItem> {
32+
) -> CompletionItem {
3333
let db = completion.db;
3434

3535
let source_range = if completion.is_immediately_after_macro_bang() {
3636
cov_mark::hit!(completes_macro_call_if_cursor_at_bang_token);
37-
completion.token.parent().map(|it| it.text_range())
37+
completion.token.parent().map_or_else(|| ctx.source_range(), |it| it.text_range())
3838
} else {
39-
Some(ctx.source_range())
40-
}?;
39+
ctx.source_range()
40+
};
4141

4242
let name = name.to_smol_str();
4343
let docs = ctx.docs(macro_);
@@ -79,7 +79,7 @@ fn render(
7979
}
8080
};
8181

82-
Some(item.build())
82+
item.build()
8383
}
8484

8585
fn label(

0 commit comments

Comments
 (0)