@@ -462,6 +462,7 @@ impl Clean<TyParam> for ty::TypeParameterDef {
462
462
fn clean ( & self , cx : & DocContext ) -> TyParam {
463
463
cx. external_typarams . borrow_mut ( ) . as_mut ( ) . unwrap ( )
464
464
. insert ( self . def_id , self . ident . clean ( cx) ) ;
465
+
465
466
TyParam {
466
467
name : self . ident . clean ( cx) ,
467
468
did : self . def_id ,
@@ -473,26 +474,25 @@ impl Clean<TyParam> for ty::TypeParameterDef {
473
474
474
475
#[ deriving( Clone , Encodable , Decodable , PartialEq ) ]
475
476
pub enum TyParamBound {
476
- RegionBound , // FIXME(#16518) -- need to include name of actual region
477
+ RegionBound ( Lifetime ) ,
478
+ UnboxedFnBound ( UnboxedFnType ) ,
477
479
TraitBound ( Type )
478
480
}
479
481
480
482
impl Clean < TyParamBound > for ast:: TyParamBound {
481
483
fn clean ( & self , cx : & DocContext ) -> TyParamBound {
482
484
match * self {
483
- ast:: RegionTyParamBound ( _) => RegionBound ,
484
- ast:: UnboxedFnTyParamBound ( _) => {
485
- // FIXME(pcwalton): Wrong.
486
- RegionBound
487
- }
485
+ ast:: RegionTyParamBound ( lt) => RegionBound ( lt. clean ( cx) ) ,
486
+ ast:: UnboxedFnTyParamBound ( ref ty) => { UnboxedFnBound ( ty. clean ( cx) ) } ,
488
487
ast:: TraitTyParamBound ( ref t) => TraitBound ( t. clean ( cx) ) ,
489
488
}
490
489
}
491
490
}
492
491
493
492
impl Clean < Vec < TyParamBound > > for ty:: ExistentialBounds {
494
493
fn clean ( & self , cx : & DocContext ) -> Vec < TyParamBound > {
495
- let mut vec = vec ! ( RegionBound ) ;
494
+ let mut vec = vec ! [ ] ;
495
+ self . region_bound . clean ( cx) . map ( |b| vec. push ( RegionBound ( b) ) ) ;
496
496
for bb in self . builtin_bounds . iter ( ) {
497
497
vec. push ( bb. clean ( cx) ) ;
498
498
}
@@ -521,7 +521,7 @@ impl Clean<TyParamBound> for ty::BuiltinBound {
521
521
fn clean ( & self , cx : & DocContext ) -> TyParamBound {
522
522
let tcx = match cx. tcx_opt ( ) {
523
523
Some ( tcx) => tcx,
524
- None => return RegionBound ,
524
+ None => return RegionBound ( Lifetime :: statik ( ) )
525
525
} ;
526
526
let empty = subst:: Substs :: empty ( ) ;
527
527
let ( did, path) = match * self {
@@ -554,7 +554,7 @@ impl Clean<TyParamBound> for ty::TraitRef {
554
554
fn clean ( & self , cx : & DocContext ) -> TyParamBound {
555
555
let tcx = match cx. tcx_opt ( ) {
556
556
Some ( tcx) => tcx,
557
- None => return RegionBound ,
557
+ None => return RegionBound ( Lifetime :: statik ( ) )
558
558
} ;
559
559
let fqn = csearch:: get_item_path ( tcx, self . def_id ) ;
560
560
let fqn = fqn. into_iter ( ) . map ( |i| i. to_string ( ) )
@@ -582,19 +582,37 @@ impl Clean<Vec<TyParamBound>> for ty::ParamBounds {
582
582
for t in self . trait_bounds . iter ( ) {
583
583
v. push ( t. clean ( cx) ) ;
584
584
}
585
+ for r in self . region_bounds . iter ( ) . filter_map ( |r| r. clean ( cx) ) {
586
+ v. push ( RegionBound ( r) ) ;
587
+ }
585
588
return v;
586
589
}
587
590
}
588
591
589
592
impl Clean < Option < Vec < TyParamBound > > > for subst:: Substs {
590
593
fn clean ( & self , cx : & DocContext ) -> Option < Vec < TyParamBound > > {
591
594
let mut v = Vec :: new ( ) ;
592
- v. extend ( self . regions ( ) . iter ( ) . map ( |_| RegionBound ) ) ;
595
+ v. extend ( self . regions ( ) . iter ( ) . filter_map ( |r| r . clean ( cx ) ) . map ( RegionBound ) ) ;
593
596
v. extend ( self . types . iter ( ) . map ( |t| TraitBound ( t. clean ( cx) ) ) ) ;
594
597
if v. len ( ) > 0 { Some ( v) } else { None }
595
598
}
596
599
}
597
600
601
+ #[ deriving( Clone , Encodable , Decodable , PartialEq ) ]
602
+ pub struct UnboxedFnType {
603
+ pub path : Path ,
604
+ pub decl : FnDecl
605
+ }
606
+
607
+ impl Clean < UnboxedFnType > for ast:: UnboxedFnBound {
608
+ fn clean ( & self , cx : & DocContext ) -> UnboxedFnType {
609
+ UnboxedFnType {
610
+ path : self . path . clean ( cx) ,
611
+ decl : self . decl . clean ( cx)
612
+ }
613
+ }
614
+ }
615
+
598
616
#[ deriving( Clone , Encodable , Decodable , PartialEq ) ]
599
617
pub struct Lifetime ( String ) ;
600
618
@@ -604,6 +622,10 @@ impl Lifetime {
604
622
let s: & ' a str = s. as_slice ( ) ;
605
623
return s;
606
624
}
625
+
626
+ pub fn statik ( ) -> Lifetime {
627
+ Lifetime ( "'static" . to_string ( ) )
628
+ }
607
629
}
608
630
609
631
impl Clean < Lifetime > for ast:: Lifetime {
@@ -627,7 +649,7 @@ impl Clean<Lifetime> for ty::RegionParameterDef {
627
649
impl Clean < Option < Lifetime > > for ty:: Region {
628
650
fn clean ( & self , cx : & DocContext ) -> Option < Lifetime > {
629
651
match * self {
630
- ty:: ReStatic => Some ( Lifetime ( "'static" . to_string ( ) ) ) ,
652
+ ty:: ReStatic => Some ( Lifetime :: statik ( ) ) ,
631
653
ty:: ReLateBound ( _, ty:: BrNamed ( _, name) ) =>
632
654
Some ( Lifetime ( token:: get_name ( name) . get ( ) . to_string ( ) ) ) ,
633
655
ty:: ReEarlyBound ( _, _, _, name) => Some ( Lifetime ( name. clean ( cx) ) ) ,
0 commit comments