@@ -37,7 +37,8 @@ use crate::clean::inline;
3737use crate :: clean:: types:: Type :: { QPath , ResolvedPath } ;
3838use crate :: clean:: Clean ;
3939use crate :: core:: DocContext ;
40- use crate :: formats:: cache:: cache;
40+ use crate :: doctree;
41+ use crate :: formats:: cache:: Cache ;
4142use crate :: formats:: item_type:: ItemType ;
4243use crate :: html:: render:: cache:: ExternalLocation ;
4344
@@ -169,8 +170,8 @@ impl Item {
169170 self . attrs . collapsed_doc_value ( )
170171 }
171172
172- crate fn links ( & self ) -> Vec < RenderedLink > {
173- self . attrs . links ( & self . def_id . krate )
173+ crate fn links ( & self , cache : & Cache ) -> Vec < RenderedLink > {
174+ self . attrs . links ( & self . def_id . krate , cache )
174175 }
175176
176177 crate fn is_crate ( & self ) -> bool {
@@ -826,7 +827,7 @@ impl Attributes {
826827 /// Gets links as a vector
827828 ///
828829 /// Cache must be populated before call
829- crate fn links ( & self , krate : & CrateNum ) -> Vec < RenderedLink > {
830+ crate fn links ( & self , krate : & CrateNum , cache : & Cache ) -> Vec < RenderedLink > {
830831 use crate :: html:: format:: href;
831832 use crate :: html:: render:: CURRENT_DEPTH ;
832833
@@ -835,7 +836,7 @@ impl Attributes {
835836 . filter_map ( |ItemLink { link : s, link_text, did, fragment } | {
836837 match * did {
837838 Some ( did) => {
838- if let Some ( ( mut href, ..) ) = href ( did) {
839+ if let Some ( ( mut href, ..) ) = href ( did, cache ) {
839840 if let Some ( ref fragment) = * fragment {
840841 href. push ( '#' ) ;
841842 href. push_str ( fragment) ;
@@ -851,7 +852,6 @@ impl Attributes {
851852 }
852853 None => {
853854 if let Some ( ref fragment) = * fragment {
854- let cache = cache ( ) ;
855855 let url = match cache. extern_locations . get ( krate) {
856856 Some ( & ( _, _, ExternalLocation :: Local ) ) => {
857857 let depth = CURRENT_DEPTH . with ( |l| l. get ( ) ) ;
@@ -958,7 +958,7 @@ impl GenericBound {
958958 crate fn is_sized_bound ( & self , cx : & DocContext < ' _ > ) -> bool {
959959 use rustc_hir:: TraitBoundModifier as TBM ;
960960 if let GenericBound :: TraitBound ( PolyTrait { ref trait_, .. } , TBM :: None ) = * self {
961- if trait_. def_id ( ) == cx. tcx . lang_items ( ) . sized_trait ( ) {
961+ if trait_. def_id ( & cx . cache ) == cx. tcx . lang_items ( ) . sized_trait ( ) {
962962 return true ;
963963 }
964964 }
@@ -1171,9 +1171,9 @@ crate enum FnRetTy {
11711171}
11721172
11731173impl GetDefId for FnRetTy {
1174- fn def_id ( & self ) -> Option < DefId > {
1174+ fn def_id ( & self , cache : & Cache ) -> Option < DefId > {
11751175 match * self {
1176- Return ( ref ty) => ty. def_id ( ) ,
1176+ Return ( ref ty) => ty. def_id ( cache ) ,
11771177 DefaultReturn => None ,
11781178 }
11791179 }
@@ -1299,12 +1299,12 @@ crate enum TypeKind {
12991299}
13001300
13011301crate trait GetDefId {
1302- fn def_id ( & self ) -> Option < DefId > ;
1302+ fn def_id ( & self , cache : & Cache ) -> Option < DefId > ;
13031303}
13041304
13051305impl < T : GetDefId > GetDefId for Option < T > {
1306- fn def_id ( & self ) -> Option < DefId > {
1307- self . as_ref ( ) . and_then ( |d| d. def_id ( ) )
1306+ fn def_id ( & self , cache : & Cache ) -> Option < DefId > {
1307+ self . as_ref ( ) . and_then ( |d| d. def_id ( cache ) )
13081308 }
13091309}
13101310
@@ -1394,27 +1394,27 @@ impl Type {
13941394}
13951395
13961396impl GetDefId for Type {
1397- fn def_id ( & self ) -> Option < DefId > {
1397+ fn def_id ( & self , cache : & Cache ) -> Option < DefId > {
13981398 match * self {
13991399 ResolvedPath { did, .. } => Some ( did) ,
1400- Primitive ( p) => cache ( ) . primitive_locations . get ( & p) . cloned ( ) ,
1400+ Primitive ( p) => cache. primitive_locations . get ( & p) . cloned ( ) ,
14011401 BorrowedRef { type_ : box Generic ( ..) , .. } => {
1402- Primitive ( PrimitiveType :: Reference ) . def_id ( )
1402+ Primitive ( PrimitiveType :: Reference ) . def_id ( cache )
14031403 }
1404- BorrowedRef { ref type_, .. } => type_. def_id ( ) ,
1404+ BorrowedRef { ref type_, .. } => type_. def_id ( cache ) ,
14051405 Tuple ( ref tys) => {
14061406 if tys. is_empty ( ) {
1407- Primitive ( PrimitiveType :: Unit ) . def_id ( )
1407+ Primitive ( PrimitiveType :: Unit ) . def_id ( cache )
14081408 } else {
1409- Primitive ( PrimitiveType :: Tuple ) . def_id ( )
1409+ Primitive ( PrimitiveType :: Tuple ) . def_id ( cache )
14101410 }
14111411 }
1412- BareFunction ( ..) => Primitive ( PrimitiveType :: Fn ) . def_id ( ) ,
1413- Never => Primitive ( PrimitiveType :: Never ) . def_id ( ) ,
1414- Slice ( ..) => Primitive ( PrimitiveType :: Slice ) . def_id ( ) ,
1415- Array ( ..) => Primitive ( PrimitiveType :: Array ) . def_id ( ) ,
1416- RawPointer ( ..) => Primitive ( PrimitiveType :: RawPointer ) . def_id ( ) ,
1417- QPath { ref self_type, .. } => self_type. def_id ( ) ,
1412+ BareFunction ( ..) => Primitive ( PrimitiveType :: Fn ) . def_id ( cache ) ,
1413+ Never => Primitive ( PrimitiveType :: Never ) . def_id ( cache ) ,
1414+ Slice ( ..) => Primitive ( PrimitiveType :: Slice ) . def_id ( cache ) ,
1415+ Array ( ..) => Primitive ( PrimitiveType :: Array ) . def_id ( cache ) ,
1416+ RawPointer ( ..) => Primitive ( PrimitiveType :: RawPointer ) . def_id ( cache ) ,
1417+ QPath { ref self_type, .. } => self_type. def_id ( cache ) ,
14181418 _ => None ,
14191419 }
14201420 }
@@ -1814,8 +1814,8 @@ crate struct Typedef {
18141814}
18151815
18161816impl GetDefId for Typedef {
1817- fn def_id ( & self ) -> Option < DefId > {
1818- self . type_ . def_id ( )
1817+ fn def_id ( & self , cache : & Cache ) -> Option < DefId > {
1818+ self . type_ . def_id ( cache )
18191819 }
18201820}
18211821
0 commit comments