diff options
author | Nick Spain <[email protected]> | 2021-01-01 06:26:39 +0000 |
---|---|---|
committer | Nick Spain <[email protected]> | 2021-01-02 10:53:52 +0000 |
commit | 7bfec89cf969aa630f184f7d4a66e8e12a423d2f (patch) | |
tree | 33ec5670269ef176c903db752aaadb16314ecb9a /crates/completion/src/render/const_.rs | |
parent | 3f1b3df65bee923e5de0652ea4b676530da29127 (diff) |
Make the result of Const, FunctionRender and TypeAliasRender constructors optional
They use source() which now returns an Option so they need to too.
Diffstat (limited to 'crates/completion/src/render/const_.rs')
-rw-r--r-- | crates/completion/src/render/const_.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/crates/completion/src/render/const_.rs b/crates/completion/src/render/const_.rs index 648a1afc5..ce924f309 100644 --- a/crates/completion/src/render/const_.rs +++ b/crates/completion/src/render/const_.rs | |||
@@ -15,7 +15,7 @@ pub(crate) fn render_const<'a>( | |||
15 | ctx: RenderContext<'a>, | 15 | ctx: RenderContext<'a>, |
16 | const_: hir::Const, | 16 | const_: hir::Const, |
17 | ) -> Option<CompletionItem> { | 17 | ) -> Option<CompletionItem> { |
18 | ConstRender::new(ctx, const_).render() | 18 | ConstRender::new(ctx, const_)?.render() |
19 | } | 19 | } |
20 | 20 | ||
21 | #[derive(Debug)] | 21 | #[derive(Debug)] |
@@ -26,10 +26,9 @@ struct ConstRender<'a> { | |||
26 | } | 26 | } |
27 | 27 | ||
28 | impl<'a> ConstRender<'a> { | 28 | impl<'a> ConstRender<'a> { |
29 | fn new(ctx: RenderContext<'a>, const_: hir::Const) -> ConstRender<'a> { | 29 | fn new(ctx: RenderContext<'a>, const_: hir::Const) -> Option<ConstRender<'a>> { |
30 | #[allow(deprecated)] | 30 | let ast_node = const_.source(ctx.db())?.value; |
31 | let ast_node = const_.source_old(ctx.db()).value; | 31 | Some(ConstRender { ctx, const_, ast_node }) |
32 | ConstRender { ctx, const_, ast_node } | ||
33 | } | 32 | } |
34 | 33 | ||
35 | fn render(self) -> Option<CompletionItem> { | 34 | fn render(self) -> Option<CompletionItem> { |