@@ -188,9 +188,6 @@ impl Completions {
188188 resolution : hir:: ScopeDef ,
189189 doc_aliases : Vec < syntax:: SmolStr > ,
190190 ) {
191- if !ctx. check_stability ( resolution. attrs ( ctx. db ) . as_deref ( ) ) {
192- return ;
193- }
194191 let is_private_editable = match ctx. def_is_visible ( & resolution) {
195192 Visible :: Yes => false ,
196193 Visible :: Editable => true ,
@@ -216,9 +213,6 @@ impl Completions {
216213 local_name : hir:: Name ,
217214 resolution : hir:: ScopeDef ,
218215 ) {
219- if !ctx. check_stability ( resolution. attrs ( ctx. db ) . as_deref ( ) ) {
220- return ;
221- }
222216 let is_private_editable = match ctx. def_is_visible ( & resolution) {
223217 Visible :: Yes => false ,
224218 Visible :: Editable => true ,
@@ -241,7 +235,7 @@ impl Completions {
241235 path_ctx : & PathCompletionCtx ,
242236 e : hir:: Enum ,
243237 ) {
244- if !ctx. check_stability ( Some ( & e . attrs ( ctx . db ) ) ) {
238+ if !ctx. check_stability_and_hidden ( e ) {
245239 return ;
246240 }
247241 e. variants ( ctx. db )
@@ -257,9 +251,6 @@ impl Completions {
257251 local_name : hir:: Name ,
258252 doc_aliases : Vec < syntax:: SmolStr > ,
259253 ) {
260- if !ctx. check_stability ( Some ( & module. attrs ( ctx. db ) ) ) {
261- return ;
262- }
263254 self . add_path_resolution (
264255 ctx,
265256 path_ctx,
@@ -276,9 +267,6 @@ impl Completions {
276267 mac : hir:: Macro ,
277268 local_name : hir:: Name ,
278269 ) {
279- if !ctx. check_stability ( Some ( & mac. attrs ( ctx. db ) ) ) {
280- return ;
281- }
282270 let is_private_editable = match ctx. is_visible ( & mac) {
283271 Visible :: Yes => false ,
284272 Visible :: Editable => true ,
@@ -302,9 +290,6 @@ impl Completions {
302290 func : hir:: Function ,
303291 local_name : Option < hir:: Name > ,
304292 ) {
305- if !ctx. check_stability ( Some ( & func. attrs ( ctx. db ) ) ) {
306- return ;
307- }
308293 let is_private_editable = match ctx. is_visible ( & func) {
309294 Visible :: Yes => false ,
310295 Visible :: Editable => true ,
@@ -332,9 +317,6 @@ impl Completions {
332317 receiver : Option < SmolStr > ,
333318 local_name : Option < hir:: Name > ,
334319 ) {
335- if !ctx. check_stability ( Some ( & func. attrs ( ctx. db ) ) ) {
336- return ;
337- }
338320 let is_private_editable = match ctx. is_visible ( & func) {
339321 Visible :: Yes => false ,
340322 Visible :: Editable => true ,
@@ -362,9 +344,6 @@ impl Completions {
362344 func : hir:: Function ,
363345 import : LocatedImport ,
364346 ) {
365- if !ctx. check_stability ( Some ( & func. attrs ( ctx. db ) ) ) {
366- return ;
367- }
368347 let is_private_editable = match ctx. is_visible ( & func) {
369348 Visible :: Yes => false ,
370349 Visible :: Editable => true ,
@@ -387,9 +366,6 @@ impl Completions {
387366 }
388367
389368 pub ( crate ) fn add_const ( & mut self , ctx : & CompletionContext < ' _ > , konst : hir:: Const ) {
390- if !ctx. check_stability ( Some ( & konst. attrs ( ctx. db ) ) ) {
391- return ;
392- }
393369 let is_private_editable = match ctx. is_visible ( & konst) {
394370 Visible :: Yes => false ,
395371 Visible :: Editable => true ,
@@ -406,9 +382,6 @@ impl Completions {
406382 ctx : & CompletionContext < ' _ > ,
407383 type_alias : hir:: TypeAlias ,
408384 ) {
409- if !ctx. check_stability ( Some ( & type_alias. attrs ( ctx. db ) ) ) {
410- return ;
411- }
412385 let is_private_editable = match ctx. is_visible ( & type_alias) {
413386 Visible :: Yes => false ,
414387 Visible :: Editable => true ,
@@ -438,7 +411,7 @@ impl Completions {
438411 variant : hir:: Variant ,
439412 path : hir:: ModPath ,
440413 ) {
441- if !ctx. check_stability ( Some ( & variant. attrs ( ctx . db ) ) ) {
414+ if !ctx. check_stability_and_hidden ( variant) {
442415 return ;
443416 }
444417 if let Some ( builder) =
@@ -455,7 +428,7 @@ impl Completions {
455428 variant : hir:: Variant ,
456429 local_name : Option < hir:: Name > ,
457430 ) {
458- if !ctx. check_stability ( Some ( & variant. attrs ( ctx . db ) ) ) {
431+ if !ctx. check_stability_and_hidden ( variant) {
459432 return ;
460433 }
461434 if let PathCompletionCtx { kind : PathKind :: Pat { pat_ctx } , .. } = path_ctx {
@@ -479,9 +452,6 @@ impl Completions {
479452 field : hir:: Field ,
480453 ty : & hir:: Type ,
481454 ) {
482- if !ctx. check_stability ( Some ( & field. attrs ( ctx. db ) ) ) {
483- return ;
484- }
485455 let is_private_editable = match ctx. is_visible ( & field) {
486456 Visible :: Yes => false ,
487457 Visible :: Editable => true ,
@@ -506,12 +476,18 @@ impl Completions {
506476 path : Option < hir:: ModPath > ,
507477 local_name : Option < hir:: Name > ,
508478 ) {
509- if !ctx. check_stability ( Some ( & strukt. attrs ( ctx. db ) ) ) {
510- return ;
511- }
512- if let Some ( builder) =
513- render_struct_literal ( RenderContext :: new ( ctx) , path_ctx, strukt, path, local_name)
514- {
479+ let is_private_editable = match ctx. is_visible ( & strukt) {
480+ Visible :: Yes => false ,
481+ Visible :: Editable => true ,
482+ Visible :: No => return ,
483+ } ;
484+ if let Some ( builder) = render_struct_literal (
485+ RenderContext :: new ( ctx) . private_editable ( is_private_editable) ,
486+ path_ctx,
487+ strukt,
488+ path,
489+ local_name,
490+ ) {
515491 self . add ( builder. build ( ctx. db ) ) ;
516492 }
517493 }
@@ -523,10 +499,17 @@ impl Completions {
523499 path : Option < hir:: ModPath > ,
524500 local_name : Option < hir:: Name > ,
525501 ) {
526- if !ctx. check_stability ( Some ( & un. attrs ( ctx. db ) ) ) {
527- return ;
528- }
529- let item = render_union_literal ( RenderContext :: new ( ctx) , un, path, local_name) ;
502+ let is_private_editable = match ctx. is_visible ( & un) {
503+ Visible :: Yes => false ,
504+ Visible :: Editable => true ,
505+ Visible :: No => return ,
506+ } ;
507+ let item = render_union_literal (
508+ RenderContext :: new ( ctx) . private_editable ( is_private_editable) ,
509+ un,
510+ path,
511+ local_name,
512+ ) ;
530513 self . add_opt ( item) ;
531514 }
532515
@@ -571,7 +554,7 @@ impl Completions {
571554 variant : hir:: Variant ,
572555 local_name : Option < hir:: Name > ,
573556 ) {
574- if !ctx. check_stability ( Some ( & variant. attrs ( ctx . db ) ) ) {
557+ if !ctx. check_stability_and_hidden ( variant) {
575558 return ;
576559 }
577560 self . add_opt ( render_variant_pat (
@@ -591,7 +574,7 @@ impl Completions {
591574 variant : hir:: Variant ,
592575 path : hir:: ModPath ,
593576 ) {
594- if !ctx. check_stability ( Some ( & variant. attrs ( ctx . db ) ) ) {
577+ if !ctx. check_stability_and_hidden ( variant) {
595578 return ;
596579 }
597580 let path = Some ( & path) ;
@@ -612,10 +595,17 @@ impl Completions {
612595 strukt : hir:: Struct ,
613596 local_name : Option < hir:: Name > ,
614597 ) {
615- if !ctx. check_stability ( Some ( & strukt. attrs ( ctx. db ) ) ) {
616- return ;
617- }
618- self . add_opt ( render_struct_pat ( RenderContext :: new ( ctx) , pattern_ctx, strukt, local_name) ) ;
598+ let is_private_editable = match ctx. is_visible ( & strukt) {
599+ Visible :: Yes => false ,
600+ Visible :: Editable => true ,
601+ Visible :: No => return ,
602+ } ;
603+ self . add_opt ( render_struct_pat (
604+ RenderContext :: new ( ctx) . private_editable ( is_private_editable) ,
605+ pattern_ctx,
606+ strukt,
607+ local_name,
608+ ) ) ;
619609 }
620610
621611 pub ( crate ) fn suggest_name ( & mut self , ctx : & CompletionContext < ' _ > , name : & str ) {
0 commit comments