@@ -9,7 +9,6 @@ use hir_def::{
9
9
adt:: StructKind ,
10
10
adt:: VariantData ,
11
11
builtin_type:: BuiltinType ,
12
- docs:: Documentation ,
13
12
expr:: { BindingAnnotation , Pat , PatId } ,
14
13
import_map,
15
14
lang_item:: LangItemTarget ,
@@ -20,7 +19,7 @@ use hir_def::{
20
19
type_ref:: { Mutability , TypeRef } ,
21
20
AdtId , AssocContainerId , ConstId , DefWithBodyId , EnumId , FunctionId , GenericDefId , HasModule ,
22
21
ImplId , LocalEnumVariantId , LocalFieldId , LocalModuleId , Lookup , ModuleId , StaticId , StructId ,
23
- TraitId , TypeAliasId , TypeParamId , UnionId , VariantId ,
22
+ TraitId , TypeAliasId , TypeParamId , UnionId ,
24
23
} ;
25
24
use hir_expand:: {
26
25
diagnostics:: DiagnosticSink ,
@@ -43,9 +42,8 @@ use tt::{Ident, Leaf, Literal, TokenTree};
43
42
44
43
use crate :: {
45
44
db:: { DefDatabase , HirDatabase } ,
46
- doc_links:: Resolvable ,
47
45
has_source:: HasSource ,
48
- HirDisplay , InFile , Name ,
46
+ AttrDef , HirDisplay , InFile , Name ,
49
47
} ;
50
48
51
49
/// hir::Crate describes a single crate. It's the main interface with which
@@ -1741,127 +1739,10 @@ impl ScopeDef {
1741
1739
}
1742
1740
}
1743
1741
1744
- #[ derive( Clone , Copy , Debug , PartialEq , Eq , Hash ) ]
1745
- pub enum AttrDef {
1746
- Module ( Module ) ,
1747
- Field ( Field ) ,
1748
- Adt ( Adt ) ,
1749
- Function ( Function ) ,
1750
- EnumVariant ( EnumVariant ) ,
1751
- Static ( Static ) ,
1752
- Const ( Const ) ,
1753
- Trait ( Trait ) ,
1754
- TypeAlias ( TypeAlias ) ,
1755
- MacroDef ( MacroDef ) ,
1756
- }
1757
-
1758
- impl_from ! (
1759
- Module ,
1760
- Field ,
1761
- Adt ( Struct , Enum , Union ) ,
1762
- EnumVariant ,
1763
- Static ,
1764
- Const ,
1765
- Function ,
1766
- Trait ,
1767
- TypeAlias ,
1768
- MacroDef
1769
- for AttrDef
1770
- ) ;
1771
-
1772
- pub trait HasAttrs {
1773
- fn attrs ( self , db : & dyn HirDatabase ) -> Attrs ;
1774
- fn docs ( self , db : & dyn HirDatabase ) -> Option < Documentation > ;
1775
- }
1776
-
1777
- impl < T : Into < AttrDef > > HasAttrs for T {
1778
- fn attrs ( self , db : & dyn HirDatabase ) -> Attrs {
1779
- let def: AttrDef = self . into ( ) ;
1780
- db. attrs ( def. into ( ) )
1781
- }
1782
- fn docs ( self , db : & dyn HirDatabase ) -> Option < Documentation > {
1783
- let def: AttrDef = self . into ( ) ;
1784
- db. documentation ( def. into ( ) )
1785
- }
1786
- }
1787
-
1788
1742
pub trait HasVisibility {
1789
1743
fn visibility ( & self , db : & dyn HirDatabase ) -> Visibility ;
1790
1744
fn is_visible_from ( & self , db : & dyn HirDatabase , module : Module ) -> bool {
1791
1745
let vis = self . visibility ( db) ;
1792
1746
vis. is_visible_from ( db. upcast ( ) , module. id )
1793
1747
}
1794
1748
}
1795
-
1796
- impl Resolvable for ModuleDef {
1797
- fn resolver < D : DefDatabase + HirDatabase > ( & self , db : & D ) -> Option < Resolver > {
1798
- Some ( match self {
1799
- ModuleDef :: Module ( m) => ModuleId :: from ( m. clone ( ) ) . resolver ( db) ,
1800
- ModuleDef :: Function ( f) => FunctionId :: from ( f. clone ( ) ) . resolver ( db) ,
1801
- ModuleDef :: Adt ( adt) => AdtId :: from ( adt. clone ( ) ) . resolver ( db) ,
1802
- ModuleDef :: EnumVariant ( ev) => {
1803
- GenericDefId :: from ( GenericDef :: from ( ev. clone ( ) ) ) . resolver ( db)
1804
- }
1805
- ModuleDef :: Const ( c) => GenericDefId :: from ( GenericDef :: from ( c. clone ( ) ) ) . resolver ( db) ,
1806
- ModuleDef :: Static ( s) => StaticId :: from ( s. clone ( ) ) . resolver ( db) ,
1807
- ModuleDef :: Trait ( t) => TraitId :: from ( t. clone ( ) ) . resolver ( db) ,
1808
- ModuleDef :: TypeAlias ( t) => ModuleId :: from ( t. module ( db) ) . resolver ( db) ,
1809
- // FIXME: This should be a resolver relative to `std/core`
1810
- ModuleDef :: BuiltinType ( _t) => None ?,
1811
- } )
1812
- }
1813
-
1814
- fn try_into_module_def ( self ) -> Option < ModuleDef > {
1815
- Some ( self )
1816
- }
1817
- }
1818
-
1819
- impl Resolvable for TypeParam {
1820
- fn resolver < D : DefDatabase + HirDatabase > ( & self , db : & D ) -> Option < Resolver > {
1821
- Some ( Into :: < ModuleId > :: into ( self . module ( db) ) . resolver ( db) )
1822
- }
1823
-
1824
- fn try_into_module_def ( self ) -> Option < ModuleDef > {
1825
- None
1826
- }
1827
- }
1828
-
1829
- impl Resolvable for MacroDef {
1830
- fn resolver < D : DefDatabase + HirDatabase > ( & self , db : & D ) -> Option < Resolver > {
1831
- Some ( Into :: < ModuleId > :: into ( self . module ( db) ?) . resolver ( db) )
1832
- }
1833
-
1834
- fn try_into_module_def ( self ) -> Option < ModuleDef > {
1835
- None
1836
- }
1837
- }
1838
-
1839
- impl Resolvable for Field {
1840
- fn resolver < D : DefDatabase + HirDatabase > ( & self , db : & D ) -> Option < Resolver > {
1841
- Some ( Into :: < VariantId > :: into ( Into :: < VariantDef > :: into ( self . parent_def ( db) ) ) . resolver ( db) )
1842
- }
1843
-
1844
- fn try_into_module_def ( self ) -> Option < ModuleDef > {
1845
- None
1846
- }
1847
- }
1848
-
1849
- impl Resolvable for ImplDef {
1850
- fn resolver < D : DefDatabase + HirDatabase > ( & self , db : & D ) -> Option < Resolver > {
1851
- Some ( Into :: < ModuleId > :: into ( self . module ( db) ) . resolver ( db) )
1852
- }
1853
-
1854
- fn try_into_module_def ( self ) -> Option < ModuleDef > {
1855
- None
1856
- }
1857
- }
1858
-
1859
- impl Resolvable for Local {
1860
- fn resolver < D : DefDatabase + HirDatabase > ( & self , db : & D ) -> Option < Resolver > {
1861
- Some ( Into :: < ModuleId > :: into ( self . module ( db) ) . resolver ( db) )
1862
- }
1863
-
1864
- fn try_into_module_def ( self ) -> Option < ModuleDef > {
1865
- None
1866
- }
1867
- }
0 commit comments