aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/completion/src/completions.rs22
-rw-r--r--crates/completion/src/render.rs8
2 files changed, 14 insertions, 16 deletions
diff --git a/crates/completion/src/completions.rs b/crates/completion/src/completions.rs
index b54771fcd..d59f5ca05 100644
--- a/crates/completion/src/completions.rs
+++ b/crates/completion/src/completions.rs
@@ -52,12 +52,12 @@ impl Completions {
52 } 52 }
53 53
54 pub(crate) fn add_field(&mut self, ctx: &CompletionContext, field: hir::Field, ty: &Type) { 54 pub(crate) fn add_field(&mut self, ctx: &CompletionContext, field: hir::Field, ty: &Type) {
55 let item = Render::new(ctx.into()).add_field(field, ty); 55 let item = Render::new(RenderContext::new(ctx)).add_field(field, ty);
56 self.add(item); 56 self.add(item);
57 } 57 }
58 58
59 pub(crate) fn add_tuple_field(&mut self, ctx: &CompletionContext, field: usize, ty: &Type) { 59 pub(crate) fn add_tuple_field(&mut self, ctx: &CompletionContext, field: usize, ty: &Type) {
60 let item = Render::new(ctx.into()).add_tuple_field(field, ty); 60 let item = Render::new(RenderContext::new(ctx)).add_tuple_field(field, ty);
61 self.add(item); 61 self.add(item);
62 } 62 }
63 63
@@ -67,7 +67,9 @@ impl Completions {
67 local_name: String, 67 local_name: String,
68 resolution: &ScopeDef, 68 resolution: &ScopeDef,
69 ) { 69 ) {
70 if let Some(item) = Render::new(ctx.into()).render_resolution(local_name, resolution) { 70 if let Some(item) =
71 Render::new(RenderContext::new(ctx)).render_resolution(local_name, resolution)
72 {
71 self.add(item); 73 self.add(item);
72 } 74 }
73 } 75 }
@@ -82,7 +84,7 @@ impl Completions {
82 Some(it) => it, 84 Some(it) => it,
83 None => return, 85 None => return,
84 }; 86 };
85 if let Some(item) = MacroRender::new(ctx.into(), name, macro_).render() { 87 if let Some(item) = MacroRender::new(RenderContext::new(ctx), name, macro_).render() {
86 self.add(item); 88 self.add(item);
87 } 89 }
88 } 90 }
@@ -93,18 +95,18 @@ impl Completions {
93 func: hir::Function, 95 func: hir::Function,
94 local_name: Option<String>, 96 local_name: Option<String>,
95 ) { 97 ) {
96 let item = FunctionRender::new(ctx.into(), local_name, func).render(); 98 let item = FunctionRender::new(RenderContext::new(ctx), local_name, func).render();
97 self.add(item) 99 self.add(item)
98 } 100 }
99 101
100 pub(crate) fn add_const(&mut self, ctx: &CompletionContext, constant: hir::Const) { 102 pub(crate) fn add_const(&mut self, ctx: &CompletionContext, constant: hir::Const) {
101 if let Some(item) = ConstRender::new(ctx.into(), constant).render() { 103 if let Some(item) = ConstRender::new(RenderContext::new(ctx), constant).render() {
102 self.add(item); 104 self.add(item);
103 } 105 }
104 } 106 }
105 107
106 pub(crate) fn add_type_alias(&mut self, ctx: &CompletionContext, type_alias: hir::TypeAlias) { 108 pub(crate) fn add_type_alias(&mut self, ctx: &CompletionContext, type_alias: hir::TypeAlias) {
107 if let Some(item) = TypeAliasRender::new(ctx.into(), type_alias).render() { 109 if let Some(item) = TypeAliasRender::new(RenderContext::new(ctx), type_alias).render() {
108 self.add(item) 110 self.add(item)
109 } 111 }
110 } 112 }
@@ -115,7 +117,8 @@ impl Completions {
115 variant: hir::EnumVariant, 117 variant: hir::EnumVariant,
116 path: ModPath, 118 path: ModPath,
117 ) { 119 ) {
118 let item = EnumVariantRender::new(ctx.into(), None, variant, Some(path)).render(); 120 let item =
121 EnumVariantRender::new(RenderContext::new(ctx), None, variant, Some(path)).render();
119 self.add(item); 122 self.add(item);
120 } 123 }
121 124
@@ -125,7 +128,8 @@ impl Completions {
125 variant: hir::EnumVariant, 128 variant: hir::EnumVariant,
126 local_name: Option<String>, 129 local_name: Option<String>,
127 ) { 130 ) {
128 let item = EnumVariantRender::new(ctx.into(), local_name, variant, None).render(); 131 let item =
132 EnumVariantRender::new(RenderContext::new(ctx), local_name, variant, None).render();
129 self.add(item); 133 self.add(item);
130 } 134 }
131} 135}
diff --git a/crates/completion/src/render.rs b/crates/completion/src/render.rs
index dd9edc514..dfba81734 100644
--- a/crates/completion/src/render.rs
+++ b/crates/completion/src/render.rs
@@ -36,7 +36,7 @@ pub(crate) struct RenderContext<'a> {
36} 36}
37 37
38impl<'a> RenderContext<'a> { 38impl<'a> RenderContext<'a> {
39 fn new(completion: &'a CompletionContext<'a>) -> RenderContext<'a> { 39 pub(crate) fn new(completion: &'a CompletionContext<'a>) -> RenderContext<'a> {
40 RenderContext { completion } 40 RenderContext { completion }
41 } 41 }
42 42
@@ -74,12 +74,6 @@ impl<'a> RenderContext<'a> {
74 } 74 }
75} 75}
76 76
77impl<'a> From<&'a CompletionContext<'a>> for RenderContext<'a> {
78 fn from(ctx: &'a CompletionContext<'a>) -> RenderContext<'a> {
79 RenderContext::new(ctx)
80 }
81}
82
83impl<'a> Render<'a> { 77impl<'a> Render<'a> {
84 pub(crate) fn new(ctx: RenderContext<'a>) -> Render<'a> { 78 pub(crate) fn new(ctx: RenderContext<'a>) -> Render<'a> {
85 Render { ctx } 79 Render { ctx }