@@ -48,8 +48,6 @@ crate use self::types::Type::*;
4848crate use self :: types:: Visibility :: { Inherited , Public } ;
4949crate use self :: types:: * ;
5050
51- const FN_OUTPUT_NAME : & str = "Output" ;
52-
5351crate trait Clean < T > {
5452 fn clean ( & self , cx : & DocContext < ' _ > ) -> T ;
5553}
@@ -329,10 +327,9 @@ impl Clean<GenericBound> for (ty::PolyTraitRef<'_>, &[TypeBinding]) {
329327 . collect_referenced_late_bound_regions ( & poly_trait_ref)
330328 . into_iter ( )
331329 . filter_map ( |br| match br {
332- ty:: BrNamed ( _, name) => Some ( GenericParamDef {
333- name : name. to_string ( ) ,
334- kind : GenericParamDefKind :: Lifetime ,
335- } ) ,
330+ ty:: BrNamed ( _, name) => {
331+ Some ( GenericParamDef { name, kind : GenericParamDefKind :: Lifetime } )
332+ }
336333 _ => None ,
337334 } )
338335 . collect ( ) ;
@@ -546,7 +543,7 @@ impl<'tcx> Clean<Type> for ty::ProjectionTy<'tcx> {
546543 GenericBound :: Outlives ( _) => panic ! ( "cleaning a trait got a lifetime" ) ,
547544 } ;
548545 Type :: QPath {
549- name : cx. tcx . associated_item ( self . item_def_id ) . ident . name . clean ( cx ) ,
546+ name : cx. tcx . associated_item ( self . item_def_id ) . ident . name ,
550547 self_type : box self . self_ty ( ) . clean ( cx) ,
551548 trait_ : box trait_,
552549 }
@@ -556,14 +553,12 @@ impl<'tcx> Clean<Type> for ty::ProjectionTy<'tcx> {
556553impl Clean < GenericParamDef > for ty:: GenericParamDef {
557554 fn clean ( & self , cx : & DocContext < ' _ > ) -> GenericParamDef {
558555 let ( name, kind) = match self . kind {
559- ty:: GenericParamDefKind :: Lifetime => {
560- ( self . name . to_string ( ) , GenericParamDefKind :: Lifetime )
561- }
556+ ty:: GenericParamDefKind :: Lifetime => ( self . name , GenericParamDefKind :: Lifetime ) ,
562557 ty:: GenericParamDefKind :: Type { has_default, synthetic, .. } => {
563558 let default =
564559 if has_default { Some ( cx. tcx . type_of ( self . def_id ) . clean ( cx) ) } else { None } ;
565560 (
566- self . name . clean ( cx ) ,
561+ self . name ,
567562 GenericParamDefKind :: Type {
568563 did : self . def_id ,
569564 bounds : vec ! [ ] , // These are filled in from the where-clauses.
@@ -573,7 +568,7 @@ impl Clean<GenericParamDef> for ty::GenericParamDef {
573568 )
574569 }
575570 ty:: GenericParamDefKind :: Const { .. } => (
576- self . name . clean ( cx ) ,
571+ self . name ,
577572 GenericParamDefKind :: Const {
578573 did : self . def_id ,
579574 ty : cx. tcx . type_of ( self . def_id ) . clean ( cx) ,
@@ -599,14 +594,14 @@ impl Clean<GenericParamDef> for hir::GenericParam<'_> {
599594 for bound in bounds {
600595 s. push_str ( & format ! ( " + {}" , bound. name. ident( ) ) ) ;
601596 }
602- s
597+ Symbol :: intern ( & s )
603598 } else {
604- self . name . ident ( ) . to_string ( )
599+ self . name . ident ( ) . name
605600 } ;
606601 ( name, GenericParamDefKind :: Lifetime )
607602 }
608603 hir:: GenericParamKind :: Type { ref default, synthetic } => (
609- self . name . ident ( ) . name . clean ( cx ) ,
604+ self . name . ident ( ) . name ,
610605 GenericParamDefKind :: Type {
611606 did : cx. tcx . hir ( ) . local_def_id ( self . hir_id ) . to_def_id ( ) ,
612607 bounds : self . bounds . clean ( cx) ,
@@ -615,7 +610,7 @@ impl Clean<GenericParamDef> for hir::GenericParam<'_> {
615610 } ,
616611 ) ,
617612 hir:: GenericParamKind :: Const { ref ty } => (
618- self . name . ident ( ) . name . clean ( cx ) ,
613+ self . name . ident ( ) . name ,
619614 GenericParamDefKind :: Const {
620615 did : cx. tcx . hir ( ) . local_def_id ( self . hir_id ) . to_def_id ( ) ,
621616 ty : ty. clean ( cx) ,
@@ -730,7 +725,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx
730725 . collect :: < Vec < GenericParamDef > > ( ) ;
731726
732727 // param index -> [(DefId of trait, associated type name, type)]
733- let mut impl_trait_proj = FxHashMap :: < u32 , Vec < ( DefId , String , Ty < ' tcx > ) > > :: default ( ) ;
728+ let mut impl_trait_proj = FxHashMap :: < u32 , Vec < ( DefId , Symbol , Ty < ' tcx > ) > > :: default ( ) ;
734729
735730 let where_predicates = preds
736731 . predicates
@@ -778,11 +773,10 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx
778773 if let Some ( ( ( _, trait_did, name) , rhs) ) =
779774 proj. as_ref ( ) . and_then ( |( lhs, rhs) | Some ( ( lhs. projection ( ) ?, rhs) ) )
780775 {
781- impl_trait_proj. entry ( param_idx) . or_default ( ) . push ( (
782- trait_did,
783- name. to_string ( ) ,
784- rhs,
785- ) ) ;
776+ impl_trait_proj
777+ . entry ( param_idx)
778+ . or_default ( )
779+ . push ( ( trait_did, name, rhs) ) ;
786780 }
787781
788782 return None ;
@@ -800,7 +794,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx
800794 if let crate :: core:: ImplTraitParam :: ParamIndex ( idx) = param {
801795 if let Some ( proj) = impl_trait_proj. remove ( & idx) {
802796 for ( trait_did, name, rhs) in proj {
803- simplify:: merge_bounds ( cx, & mut bounds, trait_did, & name, & rhs. clean ( cx) ) ;
797+ simplify:: merge_bounds ( cx, & mut bounds, trait_did, name, & rhs. clean ( cx) ) ;
804798 }
805799 }
806800 } else {
@@ -936,9 +930,9 @@ impl<'a> Clean<Arguments> for (&'a [hir::Ty<'a>], &'a [Ident]) {
936930 . iter ( )
937931 . enumerate ( )
938932 . map ( |( i, ty) | {
939- let mut name = self . 1 . get ( i) . map ( |ident| ident. to_string ( ) ) . unwrap_or_default ( ) ;
933+ let mut name = self . 1 . get ( i) . map ( |ident| ident. name ) . unwrap_or ( kw :: Invalid ) ;
940934 if name. is_empty ( ) {
941- name = "_" . to_string ( ) ;
935+ name = kw :: Underscore ;
942936 }
943937 Argument { name, type_ : ty. clean ( cx) }
944938 } )
@@ -995,7 +989,7 @@ impl<'tcx> Clean<FnDecl> for (DefId, ty::PolyFnSig<'tcx>) {
995989 . iter ( )
996990 . map ( |t| Argument {
997991 type_ : t. clean ( cx) ,
998- name : names. next ( ) . map_or_else ( || String :: new ( ) , | name| name . to_string ( ) ) ,
992+ name : names. next ( ) . map ( |i| i . name ) . unwrap_or ( kw :: Invalid ) ,
999993 } )
1000994 . collect ( ) ,
1001995 } ,
@@ -1150,12 +1144,12 @@ impl Clean<Item> for ty::AssocItem {
11501144 } ;
11511145 let self_arg_ty = sig. input ( 0 ) . skip_binder ( ) ;
11521146 if self_arg_ty == self_ty {
1153- decl. inputs . values [ 0 ] . type_ = Generic ( String :: from ( "Self" ) ) ;
1147+ decl. inputs . values [ 0 ] . type_ = Generic ( kw :: SelfUpper ) ;
11541148 } else if let ty:: Ref ( _, ty, _) = * self_arg_ty. kind ( ) {
11551149 if ty == self_ty {
11561150 match decl. inputs . values [ 0 ] . type_ {
11571151 BorrowedRef { ref mut type_, .. } => {
1158- * * type_ = Generic ( String :: from ( "Self" ) )
1152+ * * type_ = Generic ( kw :: SelfUpper )
11591153 }
11601154 _ => unreachable ! ( ) ,
11611155 }
@@ -1210,7 +1204,7 @@ impl Clean<Item> for ty::AssocItem {
12101204 }
12111205 }
12121206 ty:: AssocKind :: Type => {
1213- let my_name = self . ident . name . clean ( cx ) ;
1207+ let my_name = self . ident . name ;
12141208
12151209 if let ty:: TraitContainer ( _) = self . container {
12161210 let bounds = cx. tcx . explicit_item_bounds ( self . def_id ) ;
@@ -1235,7 +1229,7 @@ impl Clean<Item> for ty::AssocItem {
12351229 _ => return None ,
12361230 }
12371231 match * * self_type {
1238- Generic ( ref s) if * s == "Self" => { }
1232+ Generic ( ref s) if * s == kw :: SelfUpper => { }
12391233 _ => return None ,
12401234 }
12411235 Some ( bounds)
@@ -1408,7 +1402,7 @@ fn clean_qpath(hir_ty: &hir::Ty<'_>, cx: &DocContext<'_>) -> Type {
14081402 segments : trait_segments. clean ( cx) ,
14091403 } ;
14101404 Type :: QPath {
1411- name : p. segments . last ( ) . expect ( "segments were empty" ) . ident . name . clean ( cx ) ,
1405+ name : p. segments . last ( ) . expect ( "segments were empty" ) . ident . name ,
14121406 self_type : box qself. clean ( cx) ,
14131407 trait_ : box resolve_type ( cx, trait_path, hir_id) ,
14141408 }
@@ -1422,7 +1416,7 @@ fn clean_qpath(hir_ty: &hir::Ty<'_>, cx: &DocContext<'_>) -> Type {
14221416 } ;
14231417 let trait_path = hir:: Path { span, res, segments : & [ ] } ;
14241418 Type :: QPath {
1425- name : segment. ident . name . clean ( cx ) ,
1419+ name : segment. ident . name ,
14261420 self_type : box qself. clean ( cx) ,
14271421 trait_ : box resolve_type ( cx, trait_path. clean ( cx) , hir_id) ,
14281422 }
@@ -1625,7 +1619,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
16251619 let mut bindings = vec ! [ ] ;
16261620 for pb in obj. projection_bounds ( ) {
16271621 bindings. push ( TypeBinding {
1628- name : cx. tcx . associated_item ( pb. item_def_id ( ) ) . ident . name . clean ( cx ) ,
1622+ name : cx. tcx . associated_item ( pb. item_def_id ( ) ) . ident . name ,
16291623 kind : TypeBindingKind :: Equality { ty : pb. skip_binder ( ) . ty . clean ( cx) } ,
16301624 } ) ;
16311625 }
@@ -1644,7 +1638,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
16441638 if let Some ( bounds) = cx. impl_trait_bounds . borrow_mut ( ) . remove ( & p. index . into ( ) ) {
16451639 ImplTrait ( bounds)
16461640 } else {
1647- Generic ( p. name . to_string ( ) )
1641+ Generic ( p. name )
16481642 }
16491643 }
16501644
@@ -1702,8 +1696,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
17021696 . tcx
17031697 . associated_item ( proj. projection_ty . item_def_id )
17041698 . ident
1705- . name
1706- . clean ( cx) ,
1699+ . name ,
17071700 kind : TypeBindingKind :: Equality {
17081701 ty : proj. ty . clean ( cx) ,
17091702 } ,
@@ -2339,7 +2332,7 @@ impl Clean<Item> for (&hir::MacroDef<'_>, Option<Symbol>) {
23392332
23402333impl Clean < TypeBinding > for hir:: TypeBinding < ' _ > {
23412334 fn clean ( & self , cx : & DocContext < ' _ > ) -> TypeBinding {
2342- TypeBinding { name : self . ident . name . clean ( cx ) , kind : self . kind . clean ( cx) }
2335+ TypeBinding { name : self . ident . name , kind : self . kind . clean ( cx) }
23432336 }
23442337}
23452338
0 commit comments