@@ -51,6 +51,7 @@ use rustc_hir::def::CtorKind;
51
51
use rustc_hir:: def_id:: DefId ;
52
52
use rustc_hir:: Mutability ;
53
53
use rustc_middle:: middle:: stability;
54
+ use rustc_middle:: ty:: TyCtxt ;
54
55
use rustc_span:: symbol:: { kw, sym, Symbol } ;
55
56
use serde:: ser:: SerializeSeq ;
56
57
use serde:: { Serialize , Serializer } ;
@@ -1067,13 +1068,13 @@ fn render_assoc_items(
1067
1068
return ;
1068
1069
}
1069
1070
if !traits. is_empty ( ) {
1070
- let deref_impl = traits
1071
- . iter ( )
1072
- . find ( |t| t . inner_impl ( ) . trait_ . def_id_full ( cache ) == cache . deref_trait_did ) ;
1071
+ let deref_impl = traits. iter ( ) . find ( |t| {
1072
+ t . inner_impl ( ) . trait_ . def_id_full ( cache ) == cx . tcx ( ) . lang_items ( ) . deref_trait ( )
1073
+ } ) ;
1073
1074
if let Some ( impl_) = deref_impl {
1074
- let has_deref_mut = traits
1075
- . iter ( )
1076
- . any ( |t| t . inner_impl ( ) . trait_ . def_id_full ( cache ) == cache . deref_mut_trait_did ) ;
1075
+ let has_deref_mut = traits. iter ( ) . any ( |t| {
1076
+ t . inner_impl ( ) . trait_ . def_id_full ( cache ) == cx . tcx ( ) . lang_items ( ) . deref_mut_trait ( )
1077
+ } ) ;
1077
1078
render_deref_methods ( w, cx, impl_, containing_item, has_deref_mut) ;
1078
1079
}
1079
1080
let ( synthetic, concrete) : ( Vec < & & Impl > , Vec < & & Impl > ) =
@@ -1163,7 +1164,7 @@ fn render_deref_methods(
1163
1164
}
1164
1165
}
1165
1166
1166
- fn should_render_item ( item : & clean:: Item , deref_mut_ : bool , cache : & Cache ) -> bool {
1167
+ fn should_render_item ( item : & clean:: Item , deref_mut_ : bool , tcx : TyCtxt < ' _ > ) -> bool {
1167
1168
let self_type_opt = match * item. kind {
1168
1169
clean:: MethodItem ( ref method, _) => method. decl . self_type ( ) ,
1169
1170
clean:: TyMethodItem ( ref method) => method. decl . self_type ( ) ,
@@ -1177,7 +1178,7 @@ fn should_render_item(item: &clean::Item, deref_mut_: bool, cache: &Cache) -> bo
1177
1178
( mutability == Mutability :: Mut , false , false )
1178
1179
}
1179
1180
SelfTy :: SelfExplicit ( clean:: ResolvedPath { did, .. } ) => {
1180
- ( false , Some ( did) == cache . owned_box_did , false )
1181
+ ( false , Some ( did) == tcx . lang_items ( ) . owned_box ( ) , false )
1181
1182
}
1182
1183
SelfTy :: SelfValue => ( false , false , true ) ,
1183
1184
_ => ( false , false , false ) ,
@@ -1300,7 +1301,7 @@ fn render_impl(
1300
1301
&& match render_mode {
1301
1302
RenderMode :: Normal => true ,
1302
1303
RenderMode :: ForDeref { mut_ : deref_mut_ } => {
1303
- should_render_item ( & item, deref_mut_, cx. cache ( ) )
1304
+ should_render_item ( & item, deref_mut_, cx. tcx ( ) )
1304
1305
}
1305
1306
} ;
1306
1307
@@ -1798,13 +1799,13 @@ fn get_methods(
1798
1799
for_deref : bool ,
1799
1800
used_links : & mut FxHashSet < String > ,
1800
1801
deref_mut : bool ,
1801
- cache : & Cache ,
1802
+ tcx : TyCtxt < ' _ > ,
1802
1803
) -> Vec < String > {
1803
1804
i. items
1804
1805
. iter ( )
1805
1806
. filter_map ( |item| match item. name {
1806
1807
Some ( ref name) if !name. is_empty ( ) && item. is_method ( ) => {
1807
- if !for_deref || should_render_item ( item, deref_mut, cache ) {
1808
+ if !for_deref || should_render_item ( item, deref_mut, tcx ) {
1808
1809
Some ( format ! (
1809
1810
"<a href=\" #{}\" >{}</a>" ,
1810
1811
get_next_url( used_links, format!( "method.{}" , name) ) ,
@@ -1866,7 +1867,9 @@ fn sidebar_assoc_items(cx: &Context<'_>, out: &mut Buffer, it: &clean::Item) {
1866
1867
let mut ret = v
1867
1868
. iter ( )
1868
1869
. filter ( |i| i. inner_impl ( ) . trait_ . is_none ( ) )
1869
- . flat_map ( move |i| get_methods ( i. inner_impl ( ) , false , used_links_bor, false , cache) )
1870
+ . flat_map ( move |i| {
1871
+ get_methods ( i. inner_impl ( ) , false , used_links_bor, false , cx. tcx ( ) )
1872
+ } )
1870
1873
. collect :: < Vec < _ > > ( ) ;
1871
1874
if !ret. is_empty ( ) {
1872
1875
// We want links' order to be reproducible so we don't use unstable sort.
@@ -1884,11 +1887,9 @@ fn sidebar_assoc_items(cx: &Context<'_>, out: &mut Buffer, it: &clean::Item) {
1884
1887
}
1885
1888
1886
1889
if v. iter ( ) . any ( |i| i. inner_impl ( ) . trait_ . is_some ( ) ) {
1887
- if let Some ( impl_) = v
1888
- . iter ( )
1889
- . filter ( |i| i. inner_impl ( ) . trait_ . is_some ( ) )
1890
- . find ( |i| i. inner_impl ( ) . trait_ . def_id_full ( cache) == cache. deref_trait_did )
1891
- {
1890
+ if let Some ( impl_) = v. iter ( ) . filter ( |i| i. inner_impl ( ) . trait_ . is_some ( ) ) . find ( |i| {
1891
+ i. inner_impl ( ) . trait_ . def_id_full ( cache) == cx. tcx ( ) . lang_items ( ) . deref_trait ( )
1892
+ } ) {
1892
1893
sidebar_deref_methods ( cx, out, impl_, v) ;
1893
1894
}
1894
1895
@@ -1986,10 +1987,9 @@ fn sidebar_deref_methods(cx: &Context<'_>, out: &mut Buffer, impl_: &Impl, v: &V
1986
1987
}
1987
1988
}
1988
1989
}
1989
- let deref_mut = v
1990
- . iter ( )
1991
- . filter ( |i| i. inner_impl ( ) . trait_ . is_some ( ) )
1992
- . any ( |i| i. inner_impl ( ) . trait_ . def_id_full ( c) == c. deref_mut_trait_did ) ;
1990
+ let deref_mut = v. iter ( ) . filter ( |i| i. inner_impl ( ) . trait_ . is_some ( ) ) . any ( |i| {
1991
+ i. inner_impl ( ) . trait_ . def_id_full ( c) == cx. tcx ( ) . lang_items ( ) . deref_mut_trait ( )
1992
+ } ) ;
1993
1993
let inner_impl = target
1994
1994
. def_id_full ( c)
1995
1995
. or_else ( || {
@@ -2002,7 +2002,9 @@ fn sidebar_deref_methods(cx: &Context<'_>, out: &mut Buffer, impl_: &Impl, v: &V
2002
2002
let mut ret = impls
2003
2003
. iter ( )
2004
2004
. filter ( |i| i. inner_impl ( ) . trait_ . is_none ( ) )
2005
- . flat_map ( |i| get_methods ( i. inner_impl ( ) , true , & mut used_links, deref_mut, c) )
2005
+ . flat_map ( |i| {
2006
+ get_methods ( i. inner_impl ( ) , true , & mut used_links, deref_mut, cx. tcx ( ) )
2007
+ } )
2006
2008
. collect :: < Vec < _ > > ( ) ;
2007
2009
if !ret. is_empty ( ) {
2008
2010
write ! (
0 commit comments