mirror of
				https://github.com/rust-lang/rust-analyzer.git
				synced 2025-10-31 20:09:01 +00:00 
			
		
		
		
	Remove dead code
This commit is contained in:
		
							parent
							
								
									23eef0c4ea
								
							
						
					
					
						commit
						2448abdb55
					
				
					 2 changed files with 35 additions and 51 deletions
				
			
		|  | @ -63,13 +63,13 @@ use crate::{BlockId, Lookup, attr::Attrs, db::DefDatabase}; | |||
| pub(crate) use crate::item_tree::lower::{lower_use_tree, visibility_from_ast}; | ||||
| 
 | ||||
| #[derive(Copy, Clone, Eq, PartialEq)] | ||||
| pub struct RawVisibilityId(u32); | ||||
| pub(crate) struct RawVisibilityId(u32); | ||||
| 
 | ||||
| impl RawVisibilityId { | ||||
|     pub const PUB: Self = RawVisibilityId(u32::MAX); | ||||
|     pub const PRIV_IMPLICIT: Self = RawVisibilityId(u32::MAX - 1); | ||||
|     pub const PRIV_EXPLICIT: Self = RawVisibilityId(u32::MAX - 2); | ||||
|     pub const PUB_CRATE: Self = RawVisibilityId(u32::MAX - 3); | ||||
|     const PUB: Self = RawVisibilityId(u32::MAX); | ||||
|     const PRIV_IMPLICIT: Self = RawVisibilityId(u32::MAX - 1); | ||||
|     const PRIV_EXPLICIT: Self = RawVisibilityId(u32::MAX - 2); | ||||
|     const PUB_CRATE: Self = RawVisibilityId(u32::MAX - 3); | ||||
| } | ||||
| 
 | ||||
| impl fmt::Debug for RawVisibilityId { | ||||
|  | @ -188,12 +188,12 @@ impl ItemTree { | |||
|     } | ||||
| 
 | ||||
|     /// Returns the inner attributes of the source file.
 | ||||
|     pub fn top_level_raw_attrs(&self) -> &RawAttrs { | ||||
|     pub(crate) fn top_level_raw_attrs(&self) -> &RawAttrs { | ||||
|         &self.top_attrs | ||||
|     } | ||||
| 
 | ||||
|     /// Returns the inner attributes of the source file.
 | ||||
|     pub fn top_level_attrs(&self, db: &dyn DefDatabase, krate: Crate) -> Attrs { | ||||
|     pub(crate) fn top_level_attrs(&self, db: &dyn DefDatabase, krate: Crate) -> Attrs { | ||||
|         Attrs::expand_cfg_attr(db, krate, self.top_attrs.clone()) | ||||
|     } | ||||
| 
 | ||||
|  | @ -278,17 +278,12 @@ pub struct ItemTreeDataStats { | |||
| } | ||||
| 
 | ||||
| /// Trait implemented by all nodes in the item tree.
 | ||||
| pub trait ItemTreeNode: Clone { | ||||
| pub(crate) trait ItemTreeNode: Clone { | ||||
|     type Source: AstIdNode; | ||||
| 
 | ||||
|     fn ast_id(&self) -> FileAstId<Self::Source>; | ||||
| 
 | ||||
|     /// Looks up an instance of `Self` in an item tree.
 | ||||
|     fn lookup(tree: &ItemTree, index: FileAstId<Self::Source>) -> &Self; | ||||
| } | ||||
| 
 | ||||
| #[allow(type_alias_bounds)] | ||||
| pub type ItemTreeAstId<T: ItemTreeNode> = FileAstId<T::Source>; | ||||
| pub(crate) type ItemTreeAstId<T: ItemTreeNode> = FileAstId<T::Source>; | ||||
| 
 | ||||
| /// Identifies a particular [`ItemTree`].
 | ||||
| #[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)] | ||||
|  | @ -298,11 +293,11 @@ pub struct TreeId { | |||
| } | ||||
| 
 | ||||
| impl TreeId { | ||||
|     pub fn new(file: HirFileId, block: Option<BlockId>) -> Self { | ||||
|     pub(crate) fn new(file: HirFileId, block: Option<BlockId>) -> Self { | ||||
|         Self { file, block } | ||||
|     } | ||||
| 
 | ||||
|     pub fn item_tree(&self, db: &dyn DefDatabase) -> Arc<ItemTree> { | ||||
|     pub(crate) fn item_tree(&self, db: &dyn DefDatabase) -> Arc<ItemTree> { | ||||
|         match self.block { | ||||
|             Some(block) => db.block_item_tree(block), | ||||
|             None => db.file_item_tree(self.file), | ||||
|  | @ -314,7 +309,7 @@ impl TreeId { | |||
|         self.file | ||||
|     } | ||||
| 
 | ||||
|     pub fn is_block(self) -> bool { | ||||
|     pub(crate) fn is_block(self) -> bool { | ||||
|         self.block.is_some() | ||||
|     } | ||||
| } | ||||
|  | @ -347,17 +342,6 @@ macro_rules! mod_items { | |||
|         $( | ||||
|             impl ItemTreeNode for $typ { | ||||
|                 type Source = $ast; | ||||
| 
 | ||||
|                 fn ast_id(&self) -> FileAstId<$ast> { | ||||
|                     self.ast_id | ||||
|                 } | ||||
| 
 | ||||
|                 fn lookup(tree: &ItemTree, index: FileAstId<$ast>) -> &Self { | ||||
|                     match &tree.data[&index.upcast()] { | ||||
|                         ModItem::$typ(item) => item, | ||||
|                         _ => panic!("expected item of type `{}` at index `{:?}`", stringify!($typ), index), | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|             impl Index<FileAstId<$ast>> for ItemTree { | ||||
|  | @ -430,9 +414,9 @@ impl Index<RawVisibilityId> for ItemTree { | |||
| 
 | ||||
| #[derive(Debug, Clone, Eq, PartialEq)] | ||||
| pub struct Use { | ||||
|     pub visibility: RawVisibilityId, | ||||
|     pub ast_id: FileAstId<ast::Use>, | ||||
|     pub use_tree: UseTree, | ||||
|     pub(crate) visibility: RawVisibilityId, | ||||
|     pub(crate) ast_id: FileAstId<ast::Use>, | ||||
|     pub(crate) use_tree: UseTree, | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug, Clone, Eq, PartialEq)] | ||||
|  | @ -494,7 +478,7 @@ pub enum UseTreeKind { | |||
| pub struct ExternCrate { | ||||
|     pub name: Name, | ||||
|     pub alias: Option<ImportAlias>, | ||||
|     pub visibility: RawVisibilityId, | ||||
|     pub(crate) visibility: RawVisibilityId, | ||||
|     pub ast_id: FileAstId<ast::ExternCrate>, | ||||
| } | ||||
| 
 | ||||
|  | @ -507,14 +491,14 @@ pub struct ExternBlock { | |||
| #[derive(Debug, Clone, Eq, PartialEq)] | ||||
| pub struct Function { | ||||
|     pub name: Name, | ||||
|     pub visibility: RawVisibilityId, | ||||
|     pub(crate) visibility: RawVisibilityId, | ||||
|     pub ast_id: FileAstId<ast::Fn>, | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug, Clone, Eq, PartialEq)] | ||||
| pub struct Struct { | ||||
|     pub name: Name, | ||||
|     pub visibility: RawVisibilityId, | ||||
|     pub(crate) visibility: RawVisibilityId, | ||||
|     pub shape: FieldsShape, | ||||
|     pub ast_id: FileAstId<ast::Struct>, | ||||
| } | ||||
|  | @ -522,14 +506,14 @@ pub struct Struct { | |||
| #[derive(Debug, Clone, Eq, PartialEq)] | ||||
| pub struct Union { | ||||
|     pub name: Name, | ||||
|     pub visibility: RawVisibilityId, | ||||
|     pub(crate) visibility: RawVisibilityId, | ||||
|     pub ast_id: FileAstId<ast::Union>, | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug, Clone, Eq, PartialEq)] | ||||
| pub struct Enum { | ||||
|     pub name: Name, | ||||
|     pub visibility: RawVisibilityId, | ||||
|     pub(crate) visibility: RawVisibilityId, | ||||
|     pub ast_id: FileAstId<ast::Enum>, | ||||
| } | ||||
| 
 | ||||
|  | @ -568,28 +552,28 @@ impl VisibilityExplicitness { | |||
| pub struct Const { | ||||
|     /// `None` for `const _: () = ();`
 | ||||
|     pub name: Option<Name>, | ||||
|     pub visibility: RawVisibilityId, | ||||
|     pub(crate) visibility: RawVisibilityId, | ||||
|     pub ast_id: FileAstId<ast::Const>, | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug, Clone, Eq, PartialEq)] | ||||
| pub struct Static { | ||||
|     pub name: Name, | ||||
|     pub visibility: RawVisibilityId, | ||||
|     pub(crate) visibility: RawVisibilityId, | ||||
|     pub ast_id: FileAstId<ast::Static>, | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug, Clone, Eq, PartialEq)] | ||||
| pub struct Trait { | ||||
|     pub name: Name, | ||||
|     pub visibility: RawVisibilityId, | ||||
|     pub(crate) visibility: RawVisibilityId, | ||||
|     pub ast_id: FileAstId<ast::Trait>, | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug, Clone, Eq, PartialEq)] | ||||
| pub struct TraitAlias { | ||||
|     pub name: Name, | ||||
|     pub visibility: RawVisibilityId, | ||||
|     pub(crate) visibility: RawVisibilityId, | ||||
|     pub ast_id: FileAstId<ast::TraitAlias>, | ||||
| } | ||||
| 
 | ||||
|  | @ -601,14 +585,14 @@ pub struct Impl { | |||
| #[derive(Debug, Clone, PartialEq, Eq)] | ||||
| pub struct TypeAlias { | ||||
|     pub name: Name, | ||||
|     pub visibility: RawVisibilityId, | ||||
|     pub(crate) visibility: RawVisibilityId, | ||||
|     pub ast_id: FileAstId<ast::TypeAlias>, | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug, Clone, Eq, PartialEq)] | ||||
| pub struct Mod { | ||||
|     pub name: Name, | ||||
|     pub visibility: RawVisibilityId, | ||||
|     pub(crate) visibility: RawVisibilityId, | ||||
|     pub(crate) kind: ModKind, | ||||
|     pub ast_id: FileAstId<ast::Module>, | ||||
| } | ||||
|  | @ -641,7 +625,7 @@ pub struct MacroRules { | |||
| #[derive(Debug, Clone, Eq, PartialEq)] | ||||
| pub struct Macro2 { | ||||
|     pub name: Name, | ||||
|     pub visibility: RawVisibilityId, | ||||
|     pub(crate) visibility: RawVisibilityId, | ||||
|     pub ast_id: FileAstId<ast::MacroDef>, | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -35,8 +35,8 @@ use crate::{ | |||
|     db::DefDatabase, | ||||
|     item_scope::{GlobId, ImportId, ImportOrExternCrate, PerNsGlobImports}, | ||||
|     item_tree::{ | ||||
|         self, FieldsShape, ImportAlias, ImportKind, ItemTree, ItemTreeAstId, ItemTreeNode, Macro2, | ||||
|         MacroCall, MacroRules, Mod, ModItemId, ModKind, TreeId, UseTreeKind, | ||||
|         self, FieldsShape, ImportAlias, ImportKind, ItemTree, ItemTreeAstId, Macro2, MacroCall, | ||||
|         MacroRules, Mod, ModItemId, ModKind, TreeId, UseTreeKind, | ||||
|     }, | ||||
|     macro_call_as_call_id, | ||||
|     nameres::{ | ||||
|  | @ -1436,9 +1436,9 @@ impl DefCollector<'_> { | |||
| 
 | ||||
|                         let item_tree = tree.item_tree(self.db); | ||||
|                         let ast_adt_id: FileAstId<ast::Adt> = match *mod_item { | ||||
|                             ModItemId::Struct(strukt) => item_tree[strukt].ast_id().upcast(), | ||||
|                             ModItemId::Union(union) => item_tree[union].ast_id().upcast(), | ||||
|                             ModItemId::Enum(enum_) => item_tree[enum_].ast_id().upcast(), | ||||
|                             ModItemId::Struct(strukt) => item_tree[strukt].ast_id.upcast(), | ||||
|                             ModItemId::Union(union) => item_tree[union].ast_id.upcast(), | ||||
|                             ModItemId::Enum(enum_) => item_tree[enum_].ast_id.upcast(), | ||||
|                             _ => { | ||||
|                                 let diag = DefDiagnostic::invalid_derive_target( | ||||
|                                     directive.module_id, | ||||
|  | @ -1889,7 +1889,7 @@ impl ModCollector<'_, '_> { | |||
|                         if let Some(proc_macro) = attrs.parse_proc_macro_decl(&it.name) { | ||||
|                             self.def_collector.export_proc_macro( | ||||
|                                 proc_macro, | ||||
|                                 InFile::new(self.file_id(), self.item_tree[id].ast_id()), | ||||
|                                 InFile::new(self.file_id(), self.item_tree[id].ast_id), | ||||
|                                 fn_id, | ||||
|                             ); | ||||
|                         } | ||||
|  | @ -2369,7 +2369,7 @@ impl ModCollector<'_, '_> { | |||
|         } | ||||
|         .intern(self.def_collector.db); | ||||
|         self.def_collector.def_map.macro_def_to_macro_id.insert( | ||||
|             InFile::new(self.file_id(), self.item_tree[id].ast_id()).erase(), | ||||
|             InFile::new(self.file_id(), self.item_tree[id].ast_id).erase(), | ||||
|             macro_id.into(), | ||||
|         ); | ||||
|         self.def_collector.define_macro_rules( | ||||
|  | @ -2437,7 +2437,7 @@ impl ModCollector<'_, '_> { | |||
|         } | ||||
|         .intern(self.def_collector.db); | ||||
|         self.def_collector.def_map.macro_def_to_macro_id.insert( | ||||
|             InFile::new(self.file_id(), self.item_tree[id].ast_id()).erase(), | ||||
|             InFile::new(self.file_id(), self.item_tree[id].ast_id).erase(), | ||||
|             macro_id.into(), | ||||
|         ); | ||||
|         self.def_collector.define_macro_def( | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lukas Wirth
						Lukas Wirth