@@ -119,6 +119,16 @@ where
119
119
}
120
120
}
121
121
122
+ impl < I , T , U > FromWithTcx < I > for Vec < U >
123
+ where
124
+ I : IntoIterator < Item = T > ,
125
+ U : FromWithTcx < T > ,
126
+ {
127
+ fn from_tcx ( f : I , tcx : TyCtxt < ' _ > ) -> Vec < U > {
128
+ f. into_iter ( ) . map ( |x| x. into_tcx ( tcx) ) . collect ( )
129
+ }
130
+ }
131
+
122
132
pub ( crate ) fn from_deprecation ( deprecation : rustc_attr:: Deprecation ) -> Deprecation {
123
133
#[ rustfmt:: skip]
124
134
let rustc_attr:: Deprecation { since, note, is_since_rustc_version : _, suggestion : _ } = deprecation;
@@ -130,11 +140,11 @@ impl FromWithTcx<clean::GenericArgs> for GenericArgs {
130
140
use clean:: GenericArgs :: * ;
131
141
match args {
132
142
AngleBracketed { args, bindings } => GenericArgs :: AngleBracketed {
133
- args : args. into_vec ( ) . into_iter ( ) . map ( |a| a . into_tcx ( tcx) ) . collect ( ) ,
134
- bindings : bindings. into_iter ( ) . map ( |a| a . into_tcx ( tcx) ) . collect ( ) ,
143
+ args : args. into_vec ( ) . into_tcx ( tcx) ,
144
+ bindings : bindings. into_tcx ( tcx) ,
135
145
} ,
136
146
Parenthesized { inputs, output } => GenericArgs :: Parenthesized {
137
- inputs : inputs. into_vec ( ) . into_iter ( ) . map ( |a| a . into_tcx ( tcx) ) . collect ( ) ,
147
+ inputs : inputs. into_vec ( ) . into_tcx ( tcx) ,
138
148
output : output. map ( |a| ( * a) . into_tcx ( tcx) ) ,
139
149
} ,
140
150
}
@@ -177,9 +187,7 @@ impl FromWithTcx<clean::TypeBindingKind> for TypeBindingKind {
177
187
use clean:: TypeBindingKind :: * ;
178
188
match kind {
179
189
Equality { term } => TypeBindingKind :: Equality ( term. into_tcx ( tcx) ) ,
180
- Constraint { bounds } => {
181
- TypeBindingKind :: Constraint ( bounds. into_iter ( ) . map ( |a| a. into_tcx ( tcx) ) . collect ( ) )
182
- }
190
+ Constraint { bounds } => TypeBindingKind :: Constraint ( bounds. into_tcx ( tcx) ) ,
183
191
}
184
192
}
185
193
}
@@ -260,12 +268,12 @@ fn from_clean_item(item: clean::Item, tcx: TyCtxt<'_>) -> ItemEnum {
260
268
}
261
269
TyAssocTypeItem ( g, b) => ItemEnum :: AssocType {
262
270
generics : ( * g) . into_tcx ( tcx) ,
263
- bounds : b. into_iter ( ) . map ( |x| x . into_tcx ( tcx) ) . collect ( ) ,
271
+ bounds : b. into_tcx ( tcx) ,
264
272
default : None ,
265
273
} ,
266
274
AssocTypeItem ( t, b) => ItemEnum :: AssocType {
267
275
generics : t. generics . into_tcx ( tcx) ,
268
- bounds : b. into_iter ( ) . map ( |x| x . into_tcx ( tcx) ) . collect ( ) ,
276
+ bounds : b. into_tcx ( tcx) ,
269
277
default : Some ( t. item_type . unwrap_or ( t. type_ ) . into_tcx ( tcx) ) ,
270
278
} ,
271
279
// `convert_item` early returns `None` for stripped items and keywords.
@@ -354,12 +362,8 @@ fn convert_lifetime(l: clean::Lifetime) -> String {
354
362
impl FromWithTcx < clean:: Generics > for Generics {
355
363
fn from_tcx ( generics : clean:: Generics , tcx : TyCtxt < ' _ > ) -> Self {
356
364
Generics {
357
- params : generics. params . into_iter ( ) . map ( |x| x. into_tcx ( tcx) ) . collect ( ) ,
358
- where_predicates : generics
359
- . where_predicates
360
- . into_iter ( )
361
- . map ( |x| x. into_tcx ( tcx) )
362
- . collect ( ) ,
365
+ params : generics. params . into_tcx ( tcx) ,
366
+ where_predicates : generics. where_predicates . into_tcx ( tcx) ,
363
367
}
364
368
}
365
369
}
@@ -381,7 +385,7 @@ impl FromWithTcx<clean::GenericParamDefKind> for GenericParamDefKind {
381
385
outlives : outlives. into_iter ( ) . map ( convert_lifetime) . collect ( ) ,
382
386
} ,
383
387
Type { did : _, bounds, default, synthetic } => GenericParamDefKind :: Type {
384
- bounds : bounds. into_iter ( ) . map ( |x| x . into_tcx ( tcx) ) . collect ( ) ,
388
+ bounds : bounds. into_tcx ( tcx) ,
385
389
default : default. map ( |x| ( * x) . into_tcx ( tcx) ) ,
386
390
synthetic,
387
391
} ,
@@ -399,7 +403,7 @@ impl FromWithTcx<clean::WherePredicate> for WherePredicate {
399
403
match predicate {
400
404
BoundPredicate { ty, bounds, bound_params } => WherePredicate :: BoundPredicate {
401
405
type_ : ty. into_tcx ( tcx) ,
402
- bounds : bounds. into_iter ( ) . map ( |x| x . into_tcx ( tcx) ) . collect ( ) ,
406
+ bounds : bounds. into_tcx ( tcx) ,
403
407
generic_params : bound_params
404
408
. into_iter ( )
405
409
. map ( |x| GenericParamDef {
@@ -409,8 +413,8 @@ impl FromWithTcx<clean::WherePredicate> for WherePredicate {
409
413
. collect ( ) ,
410
414
} ,
411
415
RegionPredicate { lifetime, bounds } => WherePredicate :: RegionPredicate {
412
- lifetime : convert_lifetime ( lifetime)
413
- bounds: bounds. into_iter ( ) . map ( |x| x . into_tcx ( tcx) ) . collect ( ) ,
416
+ lifetime : convert_lifetime ( lifetime) ,
417
+ bounds : bounds. into_tcx ( tcx) ,
414
418
} ,
415
419
EqPredicate { lhs, rhs } => {
416
420
WherePredicate :: EqPredicate { lhs : lhs. into_tcx ( tcx) , rhs : rhs. into_tcx ( tcx) }
@@ -428,7 +432,7 @@ impl FromWithTcx<clean::GenericBound> for GenericBound {
428
432
let trait_ = clean:: Type :: Path { path : trait_ } . into_tcx ( tcx) ;
429
433
GenericBound :: TraitBound {
430
434
trait_,
431
- generic_params : generic_params. into_iter ( ) . map ( |x| x . into_tcx ( tcx) ) . collect ( ) ,
435
+ generic_params : generic_params. into_tcx ( tcx) ,
432
436
modifier : from_trait_bound_modifier ( modifier) ,
433
437
}
434
438
}
@@ -464,15 +468,15 @@ impl FromWithTcx<clean::Type> for Type {
464
468
} ,
465
469
clean:: Type :: DynTrait ( bounds, lt) => Type :: DynTrait ( DynTrait {
466
470
lifetime : lt. map ( convert_lifetime) ,
467
- traits : bounds. into_iter ( ) . map ( |t| t . into_tcx ( tcx) ) . collect ( ) ,
471
+ traits : bounds. into_tcx ( tcx) ,
468
472
} ) ,
469
473
Generic ( s) => Type :: Generic ( s. to_string ( ) ) ,
470
474
Primitive ( p) => Type :: Primitive ( p. as_sym ( ) . to_string ( ) ) ,
471
475
BareFunction ( f) => Type :: FunctionPointer ( Box :: new ( ( * f) . into_tcx ( tcx) ) ) ,
472
- Tuple ( t) => Type :: Tuple ( t. into_iter ( ) . map ( |x| x . into_tcx ( tcx) ) . collect ( ) ) ,
476
+ Tuple ( t) => Type :: Tuple ( t. into_tcx ( tcx) ) ,
473
477
Slice ( t) => Type :: Slice ( Box :: new ( ( * t) . into_tcx ( tcx) ) ) ,
474
478
Array ( t, s) => Type :: Array { type_ : Box :: new ( ( * t) . into_tcx ( tcx) ) , len : s } ,
475
- ImplTrait ( g) => Type :: ImplTrait ( g. into_iter ( ) . map ( |x| x . into_tcx ( tcx) ) . collect ( ) ) ,
479
+ ImplTrait ( g) => Type :: ImplTrait ( g. into_tcx ( tcx) ) ,
476
480
Infer => Type :: Infer ,
477
481
RawPointer ( mutability, type_) => Type :: RawPointer {
478
482
mutable : mutability == ast:: Mutability :: Mut ,
@@ -516,7 +520,7 @@ impl FromWithTcx<clean::BareFunctionDecl> for FunctionPointer {
516
520
async_ : false ,
517
521
abi : convert_abi ( abi) ,
518
522
} ,
519
- generic_params : generic_params. into_iter ( ) . map ( |x| x . into_tcx ( tcx) ) . collect ( ) ,
523
+ generic_params : generic_params. into_tcx ( tcx) ,
520
524
decl : decl. into_tcx ( tcx) ,
521
525
}
522
526
}
@@ -550,7 +554,7 @@ impl FromWithTcx<clean::Trait> for Trait {
550
554
is_unsafe,
551
555
items : ids ( items, tcx) ,
552
556
generics : generics. into_tcx ( tcx) ,
553
- bounds : bounds. into_iter ( ) . map ( |x| x . into_tcx ( tcx) ) . collect ( ) ,
557
+ bounds : bounds. into_tcx ( tcx) ,
554
558
implementations : Vec :: new ( ) , // Added in JsonRenderer::item
555
559
}
556
560
}
@@ -563,7 +567,7 @@ impl FromWithTcx<clean::PolyTrait> for PolyTrait {
563
567
) -> Self {
564
568
PolyTrait {
565
569
trait_ : clean:: Type :: Path { path : trait_ } . into_tcx ( tcx) ,
566
- generic_params : generic_params. into_iter ( ) . map ( |x| x . into_tcx ( tcx) ) . collect ( ) ,
570
+ generic_params : generic_params. into_tcx ( tcx) ,
567
571
}
568
572
}
569
573
}
@@ -730,10 +734,7 @@ impl FromWithTcx<Box<clean::Typedef>> for Typedef {
730
734
731
735
impl FromWithTcx < clean:: OpaqueTy > for OpaqueTy {
732
736
fn from_tcx ( opaque : clean:: OpaqueTy , tcx : TyCtxt < ' _ > ) -> Self {
733
- OpaqueTy {
734
- bounds : opaque. bounds . into_iter ( ) . map ( |x| x. into_tcx ( tcx) ) . collect ( ) ,
735
- generics : opaque. generics . into_tcx ( tcx) ,
736
- }
737
+ OpaqueTy { bounds : opaque. bounds . into_tcx ( tcx) , generics : opaque. generics . into_tcx ( tcx) }
737
738
}
738
739
}
739
740
@@ -749,10 +750,7 @@ impl FromWithTcx<clean::Static> for Static {
749
750
750
751
impl FromWithTcx < clean:: TraitAlias > for TraitAlias {
751
752
fn from_tcx ( alias : clean:: TraitAlias , tcx : TyCtxt < ' _ > ) -> Self {
752
- TraitAlias {
753
- generics : alias. generics . into_tcx ( tcx) ,
754
- params : alias. bounds . into_iter ( ) . map ( |x| x. into_tcx ( tcx) ) . collect ( ) ,
755
- }
753
+ TraitAlias { generics : alias. generics . into_tcx ( tcx) , params : alias. bounds . into_tcx ( tcx) }
756
754
}
757
755
}
758
756
0 commit comments