@@ -63,13 +63,13 @@ use crate::{BlockId, Lookup, attr::Attrs, db::DefDatabase};
6363pub ( crate ) use crate :: item_tree:: lower:: { lower_use_tree, visibility_from_ast} ;
6464
6565#[ derive( Copy , Clone , Eq , PartialEq ) ]
66- pub struct RawVisibilityId ( u32 ) ;
66+ pub ( crate ) struct RawVisibilityId ( u32 ) ;
6767
6868impl 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 ) ;
7373}
7474
7575impl fmt:: Debug for RawVisibilityId {
@@ -188,12 +188,12 @@ impl ItemTree {
188188 }
189189
190190 /// 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 {
192192 & self . top_attrs
193193 }
194194
195195 /// 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 {
197197 Attrs :: expand_cfg_attr ( db, krate, self . top_attrs . clone ( ) )
198198 }
199199
@@ -278,17 +278,12 @@ pub struct ItemTreeDataStats {
278278}
279279
280280/// Trait implemented by all nodes in the item tree.
281- pub trait ItemTreeNode : Clone {
281+ pub ( crate ) trait ItemTreeNode : Clone {
282282 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 ;
288283}
289284
290285#[ allow( type_alias_bounds) ]
291- pub type ItemTreeAstId < T : ItemTreeNode > = FileAstId < T :: Source > ;
286+ pub ( crate ) type ItemTreeAstId < T : ItemTreeNode > = FileAstId < T :: Source > ;
292287
293288/// Identifies a particular [`ItemTree`].
294289#[ derive( Debug , PartialEq , Eq , Clone , Copy , Hash ) ]
@@ -298,11 +293,11 @@ pub struct TreeId {
298293}
299294
300295impl TreeId {
301- pub fn new ( file : HirFileId , block : Option < BlockId > ) -> Self {
296+ pub ( crate ) fn new ( file : HirFileId , block : Option < BlockId > ) -> Self {
302297 Self { file, block }
303298 }
304299
305- pub fn item_tree ( & self , db : & dyn DefDatabase ) -> Arc < ItemTree > {
300+ pub ( crate ) fn item_tree ( & self , db : & dyn DefDatabase ) -> Arc < ItemTree > {
306301 match self . block {
307302 Some ( block) => db. block_item_tree ( block) ,
308303 None => db. file_item_tree ( self . file ) ,
@@ -314,7 +309,7 @@ impl TreeId {
314309 self . file
315310 }
316311
317- pub fn is_block ( self ) -> bool {
312+ pub ( crate ) fn is_block ( self ) -> bool {
318313 self . block . is_some ( )
319314 }
320315}
@@ -347,17 +342,6 @@ macro_rules! mod_items {
347342 $(
348343 impl ItemTreeNode for $typ {
349344 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- }
361345 }
362346
363347 impl Index <FileAstId <$ast>> for ItemTree {
@@ -430,9 +414,9 @@ impl Index<RawVisibilityId> for ItemTree {
430414
431415#[ derive( Debug , Clone , Eq , PartialEq ) ]
432416pub 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 ,
436420}
437421
438422#[ derive( Debug , Clone , Eq , PartialEq ) ]
@@ -494,7 +478,7 @@ pub enum UseTreeKind {
494478pub struct ExternCrate {
495479 pub name : Name ,
496480 pub alias : Option < ImportAlias > ,
497- pub visibility : RawVisibilityId ,
481+ pub ( crate ) visibility : RawVisibilityId ,
498482 pub ast_id : FileAstId < ast:: ExternCrate > ,
499483}
500484
@@ -507,29 +491,29 @@ pub struct ExternBlock {
507491#[ derive( Debug , Clone , Eq , PartialEq ) ]
508492pub struct Function {
509493 pub name : Name ,
510- pub visibility : RawVisibilityId ,
494+ pub ( crate ) visibility : RawVisibilityId ,
511495 pub ast_id : FileAstId < ast:: Fn > ,
512496}
513497
514498#[ derive( Debug , Clone , Eq , PartialEq ) ]
515499pub struct Struct {
516500 pub name : Name ,
517- pub visibility : RawVisibilityId ,
501+ pub ( crate ) visibility : RawVisibilityId ,
518502 pub shape : FieldsShape ,
519503 pub ast_id : FileAstId < ast:: Struct > ,
520504}
521505
522506#[ derive( Debug , Clone , Eq , PartialEq ) ]
523507pub struct Union {
524508 pub name : Name ,
525- pub visibility : RawVisibilityId ,
509+ pub ( crate ) visibility : RawVisibilityId ,
526510 pub ast_id : FileAstId < ast:: Union > ,
527511}
528512
529513#[ derive( Debug , Clone , Eq , PartialEq ) ]
530514pub struct Enum {
531515 pub name : Name ,
532- pub visibility : RawVisibilityId ,
516+ pub ( crate ) visibility : RawVisibilityId ,
533517 pub ast_id : FileAstId < ast:: Enum > ,
534518}
535519
@@ -568,28 +552,28 @@ impl VisibilityExplicitness {
568552pub struct Const {
569553 /// `None` for `const _: () = ();`
570554 pub name : Option < Name > ,
571- pub visibility : RawVisibilityId ,
555+ pub ( crate ) visibility : RawVisibilityId ,
572556 pub ast_id : FileAstId < ast:: Const > ,
573557}
574558
575559#[ derive( Debug , Clone , Eq , PartialEq ) ]
576560pub struct Static {
577561 pub name : Name ,
578- pub visibility : RawVisibilityId ,
562+ pub ( crate ) visibility : RawVisibilityId ,
579563 pub ast_id : FileAstId < ast:: Static > ,
580564}
581565
582566#[ derive( Debug , Clone , Eq , PartialEq ) ]
583567pub struct Trait {
584568 pub name : Name ,
585- pub visibility : RawVisibilityId ,
569+ pub ( crate ) visibility : RawVisibilityId ,
586570 pub ast_id : FileAstId < ast:: Trait > ,
587571}
588572
589573#[ derive( Debug , Clone , Eq , PartialEq ) ]
590574pub struct TraitAlias {
591575 pub name : Name ,
592- pub visibility : RawVisibilityId ,
576+ pub ( crate ) visibility : RawVisibilityId ,
593577 pub ast_id : FileAstId < ast:: TraitAlias > ,
594578}
595579
@@ -601,14 +585,14 @@ pub struct Impl {
601585#[ derive( Debug , Clone , PartialEq , Eq ) ]
602586pub struct TypeAlias {
603587 pub name : Name ,
604- pub visibility : RawVisibilityId ,
588+ pub ( crate ) visibility : RawVisibilityId ,
605589 pub ast_id : FileAstId < ast:: TypeAlias > ,
606590}
607591
608592#[ derive( Debug , Clone , Eq , PartialEq ) ]
609593pub struct Mod {
610594 pub name : Name ,
611- pub visibility : RawVisibilityId ,
595+ pub ( crate ) visibility : RawVisibilityId ,
612596 pub ( crate ) kind : ModKind ,
613597 pub ast_id : FileAstId < ast:: Module > ,
614598}
@@ -641,7 +625,7 @@ pub struct MacroRules {
641625#[ derive( Debug , Clone , Eq , PartialEq ) ]
642626pub struct Macro2 {
643627 pub name : Name ,
644- pub visibility : RawVisibilityId ,
628+ pub ( crate ) visibility : RawVisibilityId ,
645629 pub ast_id : FileAstId < ast:: MacroDef > ,
646630}
647631
0 commit comments