@@ -216,17 +216,15 @@ impl<'tcx> Clean<GenericBound> for ty::PolyTraitRef<'tcx> {
216
216
impl Clean < Lifetime > for hir:: Lifetime {
217
217
fn clean ( & self , cx : & mut DocContext < ' _ > ) -> Lifetime {
218
218
let def = cx. tcx . named_region ( self . hir_id ) ;
219
- match def {
220
- Some (
221
- rl:: Region :: EarlyBound ( _, node_id, _)
222
- | rl:: Region :: LateBound ( _, _, node_id, _)
223
- | rl:: Region :: Free ( _, node_id) ,
224
- ) => {
225
- if let Some ( lt) = cx. lt_substs . get ( & node_id) . cloned ( ) {
226
- return lt;
227
- }
219
+ if let Some (
220
+ rl:: Region :: EarlyBound ( _, node_id, _)
221
+ | rl:: Region :: LateBound ( _, _, node_id, _)
222
+ | rl:: Region :: Free ( _, node_id) ,
223
+ ) = def
224
+ {
225
+ if let Some ( lt) = cx. lt_substs . get ( & node_id) . cloned ( ) {
226
+ return lt;
228
227
}
229
- _ => { }
230
228
}
231
229
Lifetime ( self . name . ident ( ) . name )
232
230
}
@@ -828,7 +826,7 @@ impl<'a> Clean<Arguments> for (&'a [hir::Ty<'a>], hir::BodyId) {
828
826
. iter ( )
829
827
. enumerate ( )
830
828
. map ( |( i, ty) | Argument {
831
- name : name_from_pat ( & body. params [ i] . pat ) ,
829
+ name : name_from_pat ( body. params [ i] . pat ) ,
832
830
type_ : ty. clean ( cx) ,
833
831
} )
834
832
. collect ( ) ,
@@ -924,7 +922,7 @@ impl Clean<Item> for hir::TraitItem<'_> {
924
922
}
925
923
MethodItem ( m, None )
926
924
}
927
- hir:: TraitItemKind :: Fn ( ref sig, hir:: TraitFn :: Required ( ref names) ) => {
925
+ hir:: TraitItemKind :: Fn ( ref sig, hir:: TraitFn :: Required ( names) ) => {
928
926
let ( generics, decl) = enter_impl_trait ( cx, |cx| {
929
927
( self . generics . clean ( cx) , ( & * sig. decl , & names[ ..] ) . clean ( cx) )
930
928
} ) ;
@@ -936,7 +934,7 @@ impl Clean<Item> for hir::TraitItem<'_> {
936
934
}
937
935
TyMethodItem ( t)
938
936
}
939
- hir:: TraitItemKind :: Type ( ref bounds, ref default) => {
937
+ hir:: TraitItemKind :: Type ( bounds, ref default) => {
940
938
AssocTypeItem ( bounds. clean ( cx) , default. clean ( cx) )
941
939
}
942
940
} ;
@@ -1260,7 +1258,7 @@ fn clean_qpath(hir_ty: &hir::Ty<'_>, cx: &mut DocContext<'_>) -> Type {
1260
1258
let path = path. clean ( cx) ;
1261
1259
resolve_type ( cx, path)
1262
1260
}
1263
- hir:: QPath :: Resolved ( Some ( ref qself) , ref p) => {
1261
+ hir:: QPath :: Resolved ( Some ( ref qself) , p) => {
1264
1262
// Try to normalize `<X as Y>::T` to a type
1265
1263
let ty = hir_ty_to_ty ( cx. tcx , hir_ty) ;
1266
1264
if let Some ( normalized_value) = normalize ( cx, ty) {
@@ -1281,7 +1279,7 @@ fn clean_qpath(hir_ty: &hir::Ty<'_>, cx: &mut DocContext<'_>) -> Type {
1281
1279
trait_,
1282
1280
}
1283
1281
}
1284
- hir:: QPath :: TypeRelative ( ref qself, ref segment) => {
1282
+ hir:: QPath :: TypeRelative ( ref qself, segment) => {
1285
1283
let ty = hir_ty_to_ty ( cx. tcx , hir_ty) ;
1286
1284
let res = match ty. kind ( ) {
1287
1285
ty:: Projection ( proj) => Res :: Def ( DefKind :: Trait , proj. trait_ref ( cx. tcx ) . def_id ) ,
@@ -1337,7 +1335,7 @@ impl Clean<Type> for hir::Ty<'_> {
1337
1335
let length = print_const ( cx, ct. eval ( cx. tcx , param_env) ) ;
1338
1336
Array ( box ty. clean ( cx) , length)
1339
1337
}
1340
- TyKind :: Tup ( ref tys) => Tuple ( tys. clean ( cx) ) ,
1338
+ TyKind :: Tup ( tys) => Tuple ( tys. clean ( cx) ) ,
1341
1339
TyKind :: OpaqueDef ( item_id, _) => {
1342
1340
let item = cx. tcx . hir ( ) . item ( item_id) ;
1343
1341
if let hir:: ItemKind :: OpaqueTy ( ref ty) = item. kind {
@@ -1346,8 +1344,8 @@ impl Clean<Type> for hir::Ty<'_> {
1346
1344
unreachable ! ( )
1347
1345
}
1348
1346
}
1349
- TyKind :: Path ( _) => clean_qpath ( & self , cx) ,
1350
- TyKind :: TraitObject ( ref bounds, ref lifetime, _) => {
1347
+ TyKind :: Path ( _) => clean_qpath ( self , cx) ,
1348
+ TyKind :: TraitObject ( bounds, ref lifetime, _) => {
1351
1349
let bounds = bounds. iter ( ) . map ( |bound| bound. clean ( cx) ) . collect ( ) ;
1352
1350
let lifetime = if !lifetime. is_elided ( ) { Some ( lifetime. clean ( cx) ) } else { None } ;
1353
1351
DynTrait ( bounds, lifetime)
@@ -1441,7 +1439,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
1441
1439
let path = external_path ( cx, did, false , vec ! [ ] , InternalSubsts :: empty ( ) ) ;
1442
1440
ResolvedPath { path, did }
1443
1441
}
1444
- ty:: Dynamic ( ref obj, ref reg) => {
1442
+ ty:: Dynamic ( obj, ref reg) => {
1445
1443
// HACK: pick the first `did` as the `did` of the trait object. Someone
1446
1444
// might want to implement "native" support for marker-trait-only
1447
1445
// trait objects.
@@ -1481,9 +1479,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
1481
1479
1482
1480
DynTrait ( bounds, lifetime)
1483
1481
}
1484
- ty:: Tuple ( ref t) => {
1485
- Tuple ( t. iter ( ) . map ( |t| t. expect_ty ( ) ) . collect :: < Vec < _ > > ( ) . clean ( cx) )
1486
- }
1482
+ ty:: Tuple ( t) => Tuple ( t. iter ( ) . map ( |t| t. expect_ty ( ) ) . collect :: < Vec < _ > > ( ) . clean ( cx) ) ,
1487
1483
1488
1484
ty:: Projection ( ref data) => data. clean ( cx) ,
1489
1485
@@ -1821,9 +1817,9 @@ impl Clean<Vec<Item>> for (&hir::Item<'_>, Option<Symbol>) {
1821
1817
clean_fn_or_proc_macro ( item, sig, generics, body_id, & mut name, cx)
1822
1818
}
1823
1819
ItemKind :: Macro ( ref macro_def) => MacroItem ( Macro {
1824
- source : display_macro_source ( cx, name, & macro_def, def_id, & item. vis ) ,
1820
+ source : display_macro_source ( cx, name, macro_def, def_id, & item. vis ) ,
1825
1821
} ) ,
1826
- ItemKind :: Trait ( is_auto, unsafety, ref generics, ref bounds, ref item_ids) => {
1822
+ ItemKind :: Trait ( is_auto, unsafety, ref generics, bounds, item_ids) => {
1827
1823
let items = item_ids
1828
1824
. iter ( )
1829
1825
. map ( |ti| cx. tcx . hir ( ) . trait_item ( ti. id ) . clean ( cx) )
@@ -2065,10 +2061,10 @@ impl Clean<Item> for (&hir::ForeignItem<'_>, Option<Symbol>) {
2065
2061
let def_id = item. def_id . to_def_id ( ) ;
2066
2062
cx. with_param_env ( def_id, |cx| {
2067
2063
let kind = match item. kind {
2068
- hir:: ForeignItemKind :: Fn ( ref decl, ref names, ref generics) => {
2064
+ hir:: ForeignItemKind :: Fn ( decl, names, ref generics) => {
2069
2065
let abi = cx. tcx . hir ( ) . get_foreign_abi ( item. hir_id ( ) ) ;
2070
2066
let ( generics, decl) = enter_impl_trait ( cx, |cx| {
2071
- ( generics. clean ( cx) , ( & * * decl, & names[ ..] ) . clean ( cx) )
2067
+ ( generics. clean ( cx) , ( & * decl, & names[ ..] ) . clean ( cx) )
2072
2068
} ) ;
2073
2069
ForeignFunctionItem ( Function {
2074
2070
decl,
@@ -2113,7 +2109,7 @@ impl Clean<TypeBindingKind> for hir::TypeBindingKind<'_> {
2113
2109
hir:: TypeBindingKind :: Equality { ref ty } => {
2114
2110
TypeBindingKind :: Equality { ty : ty. clean ( cx) }
2115
2111
}
2116
- hir:: TypeBindingKind :: Constraint { ref bounds } => {
2112
+ hir:: TypeBindingKind :: Constraint { bounds } => {
2117
2113
TypeBindingKind :: Constraint { bounds : bounds. iter ( ) . map ( |b| b. clean ( cx) ) . collect ( ) }
2118
2114
}
2119
2115
}
0 commit comments