@@ -63,13 +63,13 @@ use crate::{BlockId, Lookup, attr::Attrs, db::DefDatabase};
63
63
pub ( crate ) use crate :: item_tree:: lower:: { lower_use_tree, visibility_from_ast} ;
64
64
65
65
#[ derive( Copy , Clone , Eq , PartialEq ) ]
66
- pub struct RawVisibilityId ( u32 ) ;
66
+ pub ( crate ) struct RawVisibilityId ( u32 ) ;
67
67
68
68
impl RawVisibilityId {
69
- pub const PUB : Self = RawVisibilityId ( u32:: MAX ) ;
70
- pub const PRIV_IMPLICIT : Self = RawVisibilityId ( u32:: MAX - 1 ) ;
71
- pub const PRIV_EXPLICIT : Self = RawVisibilityId ( u32:: MAX - 2 ) ;
72
- pub const PUB_CRATE : Self = RawVisibilityId ( u32:: MAX - 3 ) ;
69
+ const PUB : Self = RawVisibilityId ( u32:: MAX ) ;
70
+ const PRIV_IMPLICIT : Self = RawVisibilityId ( u32:: MAX - 1 ) ;
71
+ const PRIV_EXPLICIT : Self = RawVisibilityId ( u32:: MAX - 2 ) ;
72
+ const PUB_CRATE : Self = RawVisibilityId ( u32:: MAX - 3 ) ;
73
73
}
74
74
75
75
impl fmt:: Debug for RawVisibilityId {
@@ -188,12 +188,12 @@ impl ItemTree {
188
188
}
189
189
190
190
/// Returns the inner attributes of the source file.
191
- pub fn top_level_raw_attrs ( & self ) -> & RawAttrs {
191
+ pub ( crate ) fn top_level_raw_attrs ( & self ) -> & RawAttrs {
192
192
& self . top_attrs
193
193
}
194
194
195
195
/// Returns the inner attributes of the source file.
196
- pub fn top_level_attrs ( & self , db : & dyn DefDatabase , krate : Crate ) -> Attrs {
196
+ pub ( crate ) fn top_level_attrs ( & self , db : & dyn DefDatabase , krate : Crate ) -> Attrs {
197
197
Attrs :: expand_cfg_attr ( db, krate, self . top_attrs . clone ( ) )
198
198
}
199
199
@@ -278,17 +278,12 @@ pub struct ItemTreeDataStats {
278
278
}
279
279
280
280
/// Trait implemented by all nodes in the item tree.
281
- pub trait ItemTreeNode : Clone {
281
+ pub ( crate ) trait ItemTreeNode : Clone {
282
282
type Source : AstIdNode ;
283
-
284
- fn ast_id ( & self ) -> FileAstId < Self :: Source > ;
285
-
286
- /// Looks up an instance of `Self` in an item tree.
287
- fn lookup ( tree : & ItemTree , index : FileAstId < Self :: Source > ) -> & Self ;
288
283
}
289
284
290
285
#[ allow( type_alias_bounds) ]
291
- pub type ItemTreeAstId < T : ItemTreeNode > = FileAstId < T :: Source > ;
286
+ pub ( crate ) type ItemTreeAstId < T : ItemTreeNode > = FileAstId < T :: Source > ;
292
287
293
288
/// Identifies a particular [`ItemTree`].
294
289
#[ derive( Debug , PartialEq , Eq , Clone , Copy , Hash ) ]
@@ -298,11 +293,11 @@ pub struct TreeId {
298
293
}
299
294
300
295
impl TreeId {
301
- pub fn new ( file : HirFileId , block : Option < BlockId > ) -> Self {
296
+ pub ( crate ) fn new ( file : HirFileId , block : Option < BlockId > ) -> Self {
302
297
Self { file, block }
303
298
}
304
299
305
- pub fn item_tree ( & self , db : & dyn DefDatabase ) -> Arc < ItemTree > {
300
+ pub ( crate ) fn item_tree ( & self , db : & dyn DefDatabase ) -> Arc < ItemTree > {
306
301
match self . block {
307
302
Some ( block) => db. block_item_tree ( block) ,
308
303
None => db. file_item_tree ( self . file ) ,
@@ -314,7 +309,7 @@ impl TreeId {
314
309
self . file
315
310
}
316
311
317
- pub fn is_block ( self ) -> bool {
312
+ pub ( crate ) fn is_block ( self ) -> bool {
318
313
self . block . is_some ( )
319
314
}
320
315
}
@@ -347,17 +342,6 @@ macro_rules! mod_items {
347
342
$(
348
343
impl ItemTreeNode for $typ {
349
344
type Source = $ast;
350
-
351
- fn ast_id( & self ) -> FileAstId <$ast> {
352
- self . ast_id
353
- }
354
-
355
- fn lookup( tree: & ItemTree , index: FileAstId <$ast>) -> & Self {
356
- match & tree. data[ & index. upcast( ) ] {
357
- ModItem :: $typ( item) => item,
358
- _ => panic!( "expected item of type `{}` at index `{:?}`" , stringify!( $typ) , index) ,
359
- }
360
- }
361
345
}
362
346
363
347
impl Index <FileAstId <$ast>> for ItemTree {
@@ -430,9 +414,9 @@ impl Index<RawVisibilityId> for ItemTree {
430
414
431
415
#[ derive( Debug , Clone , Eq , PartialEq ) ]
432
416
pub struct Use {
433
- pub visibility : RawVisibilityId ,
434
- pub ast_id : FileAstId < ast:: Use > ,
435
- pub use_tree : UseTree ,
417
+ pub ( crate ) visibility : RawVisibilityId ,
418
+ pub ( crate ) ast_id : FileAstId < ast:: Use > ,
419
+ pub ( crate ) use_tree : UseTree ,
436
420
}
437
421
438
422
#[ derive( Debug , Clone , Eq , PartialEq ) ]
@@ -494,7 +478,7 @@ pub enum UseTreeKind {
494
478
pub struct ExternCrate {
495
479
pub name : Name ,
496
480
pub alias : Option < ImportAlias > ,
497
- pub visibility : RawVisibilityId ,
481
+ pub ( crate ) visibility : RawVisibilityId ,
498
482
pub ast_id : FileAstId < ast:: ExternCrate > ,
499
483
}
500
484
@@ -507,29 +491,29 @@ pub struct ExternBlock {
507
491
#[ derive( Debug , Clone , Eq , PartialEq ) ]
508
492
pub struct Function {
509
493
pub name : Name ,
510
- pub visibility : RawVisibilityId ,
494
+ pub ( crate ) visibility : RawVisibilityId ,
511
495
pub ast_id : FileAstId < ast:: Fn > ,
512
496
}
513
497
514
498
#[ derive( Debug , Clone , Eq , PartialEq ) ]
515
499
pub struct Struct {
516
500
pub name : Name ,
517
- pub visibility : RawVisibilityId ,
501
+ pub ( crate ) visibility : RawVisibilityId ,
518
502
pub shape : FieldsShape ,
519
503
pub ast_id : FileAstId < ast:: Struct > ,
520
504
}
521
505
522
506
#[ derive( Debug , Clone , Eq , PartialEq ) ]
523
507
pub struct Union {
524
508
pub name : Name ,
525
- pub visibility : RawVisibilityId ,
509
+ pub ( crate ) visibility : RawVisibilityId ,
526
510
pub ast_id : FileAstId < ast:: Union > ,
527
511
}
528
512
529
513
#[ derive( Debug , Clone , Eq , PartialEq ) ]
530
514
pub struct Enum {
531
515
pub name : Name ,
532
- pub visibility : RawVisibilityId ,
516
+ pub ( crate ) visibility : RawVisibilityId ,
533
517
pub ast_id : FileAstId < ast:: Enum > ,
534
518
}
535
519
@@ -568,28 +552,28 @@ impl VisibilityExplicitness {
568
552
pub struct Const {
569
553
/// `None` for `const _: () = ();`
570
554
pub name : Option < Name > ,
571
- pub visibility : RawVisibilityId ,
555
+ pub ( crate ) visibility : RawVisibilityId ,
572
556
pub ast_id : FileAstId < ast:: Const > ,
573
557
}
574
558
575
559
#[ derive( Debug , Clone , Eq , PartialEq ) ]
576
560
pub struct Static {
577
561
pub name : Name ,
578
- pub visibility : RawVisibilityId ,
562
+ pub ( crate ) visibility : RawVisibilityId ,
579
563
pub ast_id : FileAstId < ast:: Static > ,
580
564
}
581
565
582
566
#[ derive( Debug , Clone , Eq , PartialEq ) ]
583
567
pub struct Trait {
584
568
pub name : Name ,
585
- pub visibility : RawVisibilityId ,
569
+ pub ( crate ) visibility : RawVisibilityId ,
586
570
pub ast_id : FileAstId < ast:: Trait > ,
587
571
}
588
572
589
573
#[ derive( Debug , Clone , Eq , PartialEq ) ]
590
574
pub struct TraitAlias {
591
575
pub name : Name ,
592
- pub visibility : RawVisibilityId ,
576
+ pub ( crate ) visibility : RawVisibilityId ,
593
577
pub ast_id : FileAstId < ast:: TraitAlias > ,
594
578
}
595
579
@@ -601,14 +585,14 @@ pub struct Impl {
601
585
#[ derive( Debug , Clone , PartialEq , Eq ) ]
602
586
pub struct TypeAlias {
603
587
pub name : Name ,
604
- pub visibility : RawVisibilityId ,
588
+ pub ( crate ) visibility : RawVisibilityId ,
605
589
pub ast_id : FileAstId < ast:: TypeAlias > ,
606
590
}
607
591
608
592
#[ derive( Debug , Clone , Eq , PartialEq ) ]
609
593
pub struct Mod {
610
594
pub name : Name ,
611
- pub visibility : RawVisibilityId ,
595
+ pub ( crate ) visibility : RawVisibilityId ,
612
596
pub ( crate ) kind : ModKind ,
613
597
pub ast_id : FileAstId < ast:: Module > ,
614
598
}
@@ -641,7 +625,7 @@ pub struct MacroRules {
641
625
#[ derive( Debug , Clone , Eq , PartialEq ) ]
642
626
pub struct Macro2 {
643
627
pub name : Name ,
644
- pub visibility : RawVisibilityId ,
628
+ pub ( crate ) visibility : RawVisibilityId ,
645
629
pub ast_id : FileAstId < ast:: MacroDef > ,
646
630
}
647
631
0 commit comments