@@ -747,7 +747,6 @@ pub enum SelfTy {
747
747
SelfStatic ,
748
748
SelfValue ,
749
749
SelfBorrowed ( Option < Lifetime > , Mutability ) ,
750
- SelfOwned ,
751
750
SelfExplicit ( Type ) ,
752
751
}
753
752
@@ -971,28 +970,27 @@ impl Clean<Item> for ty::Method {
971
970
fn clean ( & self ) -> Item {
972
971
let cx = get_cx ( ) ;
973
972
let ( self_, sig) = match self . explicit_self {
974
- ty:: StaticExplicitSelfCategory => ( ast:: SelfStatic . clean ( ) , self . fty . sig . clone ( ) ) ,
973
+ ty:: StaticExplicitSelfCategory => ( ast:: SelfStatic . clean ( ) ,
974
+ self . fty . sig . clone ( ) ) ,
975
975
s => {
976
976
let sig = ty:: FnSig {
977
977
inputs : Vec :: from_slice ( self . fty . sig . inputs . slice_from ( 1 ) ) ,
978
978
..self . fty . sig . clone ( )
979
979
} ;
980
980
let s = match s {
981
+ ty:: ByValueExplicitSelfCategory => SelfValue ,
981
982
ty:: ByReferenceExplicitSelfCategory ( ..) => {
982
983
match ty:: get ( self . fty . sig . inputs [ 0 ] ) . sty {
983
984
ty:: ty_rptr( r, mt) => {
984
985
SelfBorrowed ( r. clean ( ) , mt. mutbl . clean ( ) )
985
986
}
986
- _ => {
987
- // FIXME(pcwalton): This is wrong.
988
- SelfStatic
989
- }
987
+ _ => unreachable ! ( ) ,
990
988
}
991
989
}
992
- _ => {
993
- // FIXME(pcwalton): This is wrong.
994
- SelfStatic
990
+ ty:: ByBoxExplicitSelfCategory => {
991
+ SelfExplicit ( self . fty . sig . inputs [ 0 ] . clean ( ) )
995
992
}
993
+ ty:: StaticExplicitSelfCategory => unreachable ! ( ) ,
996
994
} ;
997
995
( s, sig)
998
996
}
@@ -1213,8 +1211,18 @@ impl Clean<Type> for ty::t {
1213
1211
ty:: ty_float( ast:: TyF32 ) => Primitive ( F32 ) ,
1214
1212
ty:: ty_float( ast:: TyF64 ) => Primitive ( F64 ) ,
1215
1213
ty:: ty_str => Primitive ( Str ) ,
1216
- ty:: ty_box( t) => Managed ( box t. clean ( ) ) ,
1217
- ty:: ty_uniq( t) => Unique ( box t. clean ( ) ) ,
1214
+ ty:: ty_box( t) => {
1215
+ let gc_did = get_cx ( ) . tcx_opt ( ) . and_then ( |tcx| {
1216
+ tcx. lang_items . gc ( )
1217
+ } ) ;
1218
+ lang_struct ( gc_did, t, "Gc" , Managed )
1219
+ }
1220
+ ty:: ty_uniq( t) => {
1221
+ let box_did = get_cx ( ) . tcx_opt ( ) . and_then ( |tcx| {
1222
+ tcx. lang_items . owned_box ( )
1223
+ } ) ;
1224
+ lang_struct ( box_did, t, "Box" , Unique )
1225
+ }
1218
1226
ty:: ty_vec( mt, None ) => Vector ( box mt. ty . clean ( ) ) ,
1219
1227
ty:: ty_vec( mt, Some ( i) ) => FixedVector ( box mt. ty . clean ( ) ,
1220
1228
format ! ( "{}" , i) ) ,
@@ -2094,3 +2102,29 @@ impl Clean<Stability> for attr::Stability {
2094
2102
}
2095
2103
}
2096
2104
}
2105
+
2106
+ fn lang_struct ( did : Option < ast:: DefId > , t : ty:: t , name : & str ,
2107
+ fallback : fn ( Box < Type > ) -> Type ) -> Type {
2108
+ let did = match did {
2109
+ Some ( did) => did,
2110
+ None => return fallback ( box t. clean ( ) ) ,
2111
+ } ;
2112
+ let fqn = csearch:: get_item_path ( get_cx ( ) . tcx ( ) , did) ;
2113
+ let fqn: Vec < String > = fqn. move_iter ( ) . map ( |i| {
2114
+ i. to_string ( )
2115
+ } ) . collect ( ) ;
2116
+ get_cx ( ) . external_paths . borrow_mut ( ) . get_mut_ref ( )
2117
+ . insert ( did, ( fqn, TypeStruct ) ) ;
2118
+ ResolvedPath {
2119
+ typarams : None ,
2120
+ did : did,
2121
+ path : Path {
2122
+ global : false ,
2123
+ segments : vec ! [ PathSegment {
2124
+ name: name. to_string( ) ,
2125
+ lifetimes: vec![ ] ,
2126
+ types: vec![ t. clean( ) ] ,
2127
+ } ] ,
2128
+ } ,
2129
+ }
2130
+ }
0 commit comments