@@ -188,9 +188,6 @@ impl Completions {
188
188
resolution : hir:: ScopeDef ,
189
189
doc_aliases : Vec < syntax:: SmolStr > ,
190
190
) {
191
- if !ctx. check_stability ( resolution. attrs ( ctx. db ) . as_deref ( ) ) {
192
- return ;
193
- }
194
191
let is_private_editable = match ctx. def_is_visible ( & resolution) {
195
192
Visible :: Yes => false ,
196
193
Visible :: Editable => true ,
@@ -216,9 +213,6 @@ impl Completions {
216
213
local_name : hir:: Name ,
217
214
resolution : hir:: ScopeDef ,
218
215
) {
219
- if !ctx. check_stability ( resolution. attrs ( ctx. db ) . as_deref ( ) ) {
220
- return ;
221
- }
222
216
let is_private_editable = match ctx. def_is_visible ( & resolution) {
223
217
Visible :: Yes => false ,
224
218
Visible :: Editable => true ,
@@ -241,7 +235,7 @@ impl Completions {
241
235
path_ctx : & PathCompletionCtx ,
242
236
e : hir:: Enum ,
243
237
) {
244
- if !ctx. check_stability ( Some ( & e . attrs ( ctx . db ) ) ) {
238
+ if !ctx. check_stability_and_hidden ( e ) {
245
239
return ;
246
240
}
247
241
e. variants ( ctx. db )
@@ -257,9 +251,6 @@ impl Completions {
257
251
local_name : hir:: Name ,
258
252
doc_aliases : Vec < syntax:: SmolStr > ,
259
253
) {
260
- if !ctx. check_stability ( Some ( & module. attrs ( ctx. db ) ) ) {
261
- return ;
262
- }
263
254
self . add_path_resolution (
264
255
ctx,
265
256
path_ctx,
@@ -276,9 +267,6 @@ impl Completions {
276
267
mac : hir:: Macro ,
277
268
local_name : hir:: Name ,
278
269
) {
279
- if !ctx. check_stability ( Some ( & mac. attrs ( ctx. db ) ) ) {
280
- return ;
281
- }
282
270
let is_private_editable = match ctx. is_visible ( & mac) {
283
271
Visible :: Yes => false ,
284
272
Visible :: Editable => true ,
@@ -302,9 +290,6 @@ impl Completions {
302
290
func : hir:: Function ,
303
291
local_name : Option < hir:: Name > ,
304
292
) {
305
- if !ctx. check_stability ( Some ( & func. attrs ( ctx. db ) ) ) {
306
- return ;
307
- }
308
293
let is_private_editable = match ctx. is_visible ( & func) {
309
294
Visible :: Yes => false ,
310
295
Visible :: Editable => true ,
@@ -332,9 +317,6 @@ impl Completions {
332
317
receiver : Option < SmolStr > ,
333
318
local_name : Option < hir:: Name > ,
334
319
) {
335
- if !ctx. check_stability ( Some ( & func. attrs ( ctx. db ) ) ) {
336
- return ;
337
- }
338
320
let is_private_editable = match ctx. is_visible ( & func) {
339
321
Visible :: Yes => false ,
340
322
Visible :: Editable => true ,
@@ -362,9 +344,6 @@ impl Completions {
362
344
func : hir:: Function ,
363
345
import : LocatedImport ,
364
346
) {
365
- if !ctx. check_stability ( Some ( & func. attrs ( ctx. db ) ) ) {
366
- return ;
367
- }
368
347
let is_private_editable = match ctx. is_visible ( & func) {
369
348
Visible :: Yes => false ,
370
349
Visible :: Editable => true ,
@@ -387,9 +366,6 @@ impl Completions {
387
366
}
388
367
389
368
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
- }
393
369
let is_private_editable = match ctx. is_visible ( & konst) {
394
370
Visible :: Yes => false ,
395
371
Visible :: Editable => true ,
@@ -406,9 +382,6 @@ impl Completions {
406
382
ctx : & CompletionContext < ' _ > ,
407
383
type_alias : hir:: TypeAlias ,
408
384
) {
409
- if !ctx. check_stability ( Some ( & type_alias. attrs ( ctx. db ) ) ) {
410
- return ;
411
- }
412
385
let is_private_editable = match ctx. is_visible ( & type_alias) {
413
386
Visible :: Yes => false ,
414
387
Visible :: Editable => true ,
@@ -438,7 +411,7 @@ impl Completions {
438
411
variant : hir:: Variant ,
439
412
path : hir:: ModPath ,
440
413
) {
441
- if !ctx. check_stability ( Some ( & variant. attrs ( ctx . db ) ) ) {
414
+ if !ctx. check_stability_and_hidden ( variant) {
442
415
return ;
443
416
}
444
417
if let Some ( builder) =
@@ -455,7 +428,7 @@ impl Completions {
455
428
variant : hir:: Variant ,
456
429
local_name : Option < hir:: Name > ,
457
430
) {
458
- if !ctx. check_stability ( Some ( & variant. attrs ( ctx . db ) ) ) {
431
+ if !ctx. check_stability_and_hidden ( variant) {
459
432
return ;
460
433
}
461
434
if let PathCompletionCtx { kind : PathKind :: Pat { pat_ctx } , .. } = path_ctx {
@@ -479,9 +452,6 @@ impl Completions {
479
452
field : hir:: Field ,
480
453
ty : & hir:: Type ,
481
454
) {
482
- if !ctx. check_stability ( Some ( & field. attrs ( ctx. db ) ) ) {
483
- return ;
484
- }
485
455
let is_private_editable = match ctx. is_visible ( & field) {
486
456
Visible :: Yes => false ,
487
457
Visible :: Editable => true ,
@@ -506,12 +476,18 @@ impl Completions {
506
476
path : Option < hir:: ModPath > ,
507
477
local_name : Option < hir:: Name > ,
508
478
) {
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
+ ) {
515
491
self . add ( builder. build ( ctx. db ) ) ;
516
492
}
517
493
}
@@ -523,10 +499,17 @@ impl Completions {
523
499
path : Option < hir:: ModPath > ,
524
500
local_name : Option < hir:: Name > ,
525
501
) {
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
+ ) ;
530
513
self . add_opt ( item) ;
531
514
}
532
515
@@ -571,7 +554,7 @@ impl Completions {
571
554
variant : hir:: Variant ,
572
555
local_name : Option < hir:: Name > ,
573
556
) {
574
- if !ctx. check_stability ( Some ( & variant. attrs ( ctx . db ) ) ) {
557
+ if !ctx. check_stability_and_hidden ( variant) {
575
558
return ;
576
559
}
577
560
self . add_opt ( render_variant_pat (
@@ -591,7 +574,7 @@ impl Completions {
591
574
variant : hir:: Variant ,
592
575
path : hir:: ModPath ,
593
576
) {
594
- if !ctx. check_stability ( Some ( & variant. attrs ( ctx . db ) ) ) {
577
+ if !ctx. check_stability_and_hidden ( variant) {
595
578
return ;
596
579
}
597
580
let path = Some ( & path) ;
@@ -612,10 +595,17 @@ impl Completions {
612
595
strukt : hir:: Struct ,
613
596
local_name : Option < hir:: Name > ,
614
597
) {
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
+ ) ) ;
619
609
}
620
610
621
611
pub ( crate ) fn suggest_name ( & mut self , ctx : & CompletionContext < ' _ > , name : & str ) {
0 commit comments