@@ -90,6 +90,16 @@ impl<'a, T: fmt::Display> fmt::Display for CommaSep<'a, T> {
90
90
}
91
91
}
92
92
93
+ impl < ' a , T : fmt:: Debug > fmt:: Debug for CommaSep < ' a , T > {
94
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
95
+ for ( i, item) in self . 0 . iter ( ) . enumerate ( ) {
96
+ if i != 0 { write ! ( f, ", " ) ?; }
97
+ fmt:: Debug :: fmt ( item, f) ?;
98
+ }
99
+ Ok ( ( ) )
100
+ }
101
+ }
102
+
93
103
impl < ' a > fmt:: Display for TyParamBounds < ' a > {
94
104
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
95
105
let & TyParamBounds ( bounds) = self ;
@@ -165,7 +175,7 @@ impl<'a> fmt::Display for WhereClause<'a> {
165
175
if f. alternate ( ) {
166
176
clause. push_str ( " where " ) ;
167
177
} else {
168
- clause. push_str ( " <span class=' where fmt-newline' >where " ) ;
178
+ clause. push_str ( " <span class=\" where fmt-newline\" >where " ) ;
169
179
}
170
180
for ( i, pred) in gens. where_predicates . iter ( ) . enumerate ( ) {
171
181
if i > 0 {
@@ -449,8 +459,8 @@ fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
449
459
} else {
450
460
root. push_str ( & seg. name ) ;
451
461
root. push_str ( "/" ) ;
452
- write ! ( w, "<a class=' mod'
453
- href=' {}index.html' >{}</a>::" ,
462
+ write ! ( w, "<a class=\" mod\"
463
+ href=\" {}index.html\" >{}</a>::" ,
454
464
root,
455
465
seg. name) ?;
456
466
}
@@ -491,7 +501,7 @@ fn primitive_link(f: &mut fmt::Formatter,
491
501
Some ( & def_id) if def_id. is_local ( ) => {
492
502
let len = CURRENT_LOCATION_KEY . with ( |s| s. borrow ( ) . len ( ) ) ;
493
503
let len = if len == 0 { 0 } else { len - 1 } ;
494
- write ! ( f, "<a class=' primitive' href=' {}primitive.{}.html' >" ,
504
+ write ! ( f, "<a class=\" primitive\" href=\" {}primitive.{}.html\" >" ,
495
505
repeat( "../" ) . take( len) . collect:: <String >( ) ,
496
506
prim. to_url_str( ) ) ?;
497
507
needs_termination = true ;
@@ -508,7 +518,7 @@ fn primitive_link(f: &mut fmt::Formatter,
508
518
( .., render:: Unknown ) => None ,
509
519
} ;
510
520
if let Some ( ( cname, root) ) = loc {
511
- write ! ( f, "<a class=' primitive' href=' {}{}/primitive.{}.html' >" ,
521
+ write ! ( f, "<a class=\" primitive\" href=\" {}{}/primitive.{}.html\" >" ,
512
522
root,
513
523
cname,
514
524
prim. to_url_str( ) ) ?;
@@ -550,7 +560,7 @@ impl<'a> fmt::Display for HRef<'a> {
550
560
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
551
561
match href ( self . did ) {
552
562
Some ( ( url, shortty, fqp) ) => if !f. alternate ( ) {
553
- write ! ( f, "<a class='{}' href='{}' title=' {} {}' >{}</a>" ,
563
+ write ! ( f, "<a class=\" {} \" href=\" {} \" title=\" {} {}\" >{}</a>" ,
554
564
shortty, url, shortty, fqp. join( "::" ) , self . text)
555
565
} else {
556
566
write ! ( f, "{}" , self . text)
@@ -560,7 +570,8 @@ impl<'a> fmt::Display for HRef<'a> {
560
570
}
561
571
}
562
572
563
- fn fmt_type ( t : & clean:: Type , f : & mut fmt:: Formatter , use_absolute : bool ) -> fmt:: Result {
573
+ fn fmt_type ( t : & clean:: Type , f : & mut fmt:: Formatter , use_absolute : bool ,
574
+ is_not_debug : bool ) -> fmt:: Result {
564
575
match * t {
565
576
clean:: Generic ( ref name) => {
566
577
f. write_str ( name)
@@ -571,7 +582,8 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
571
582
tybounds ( f, typarams)
572
583
}
573
584
clean:: Infer => write ! ( f, "_" ) ,
574
- clean:: Primitive ( prim) => primitive_link ( f, prim, prim. as_str ( ) ) ,
585
+ clean:: Primitive ( prim) if is_not_debug => primitive_link ( f, prim, prim. as_str ( ) ) ,
586
+ clean:: Primitive ( prim) => write ! ( f, "{}" , prim. as_str( ) ) ,
575
587
clean:: BareFunction ( ref decl) => {
576
588
if f. alternate ( ) {
577
589
write ! ( f, "{}{}fn{:#}{:#}" ,
@@ -589,26 +601,30 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
589
601
}
590
602
clean:: Tuple ( ref typs) => {
591
603
match & typs[ ..] {
592
- & [ ] => primitive_link ( f, PrimitiveType :: Tuple , "()" ) ,
593
- & [ ref one] => {
604
+ & [ ] if is_not_debug => primitive_link ( f, PrimitiveType :: Tuple , "()" ) ,
605
+ & [ ] => write ! ( f, "()" ) ,
606
+ & [ ref one] if is_not_debug => {
594
607
primitive_link ( f, PrimitiveType :: Tuple , "(" ) ?;
595
608
//carry f.alternate() into this display w/o branching manually
596
609
fmt:: Display :: fmt ( one, f) ?;
597
610
primitive_link ( f, PrimitiveType :: Tuple , ",)" )
598
611
}
599
- many => {
612
+ & [ ref one] => write ! ( f, "({:?},)" , one) ,
613
+ many if is_not_debug => {
600
614
primitive_link ( f, PrimitiveType :: Tuple , "(" ) ?;
601
615
fmt:: Display :: fmt ( & CommaSep ( & many) , f) ?;
602
616
primitive_link ( f, PrimitiveType :: Tuple , ")" )
603
617
}
618
+ many => write ! ( f, "({:?})" , & CommaSep ( & many) ) ,
604
619
}
605
620
}
606
- clean:: Vector ( ref t) => {
621
+ clean:: Vector ( ref t) if is_not_debug => {
607
622
primitive_link ( f, PrimitiveType :: Slice , & format ! ( "[" ) ) ?;
608
623
fmt:: Display :: fmt ( t, f) ?;
609
624
primitive_link ( f, PrimitiveType :: Slice , & format ! ( "]" ) )
610
625
}
611
- clean:: FixedVector ( ref t, ref s) => {
626
+ clean:: Vector ( ref t) => write ! ( f, "[{:?}]" , t) ,
627
+ clean:: FixedVector ( ref t, ref s) if is_not_debug => {
612
628
primitive_link ( f, PrimitiveType :: Array , "[" ) ?;
613
629
fmt:: Display :: fmt ( t, f) ?;
614
630
if f. alternate ( ) {
@@ -619,10 +635,17 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
619
635
& format ! ( "; {}]" , Escape ( s) ) )
620
636
}
621
637
}
638
+ clean:: FixedVector ( ref t, ref s) => {
639
+ if f. alternate ( ) {
640
+ write ! ( f, "[{:?}; {}]" , t, s)
641
+ } else {
642
+ write ! ( f, "[{:?}; {}]" , t, Escape ( s) )
643
+ }
644
+ }
622
645
clean:: Never => f. write_str ( "!" ) ,
623
646
clean:: RawPointer ( m, ref t) => {
624
647
match * * t {
625
- clean:: Generic ( _) | clean:: ResolvedPath { is_generic : true , ..} => {
648
+ clean:: Generic ( _) | clean:: ResolvedPath { is_generic : true , ..} if is_not_debug => {
626
649
if f. alternate ( ) {
627
650
primitive_link ( f, clean:: PrimitiveType :: RawPointer ,
628
651
& format ! ( "*{}{:#}" , RawMutableSpace ( m) , t) )
@@ -631,11 +654,21 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
631
654
& format ! ( "*{}{}" , RawMutableSpace ( m) , t) )
632
655
}
633
656
}
634
- _ => {
657
+ clean:: Generic ( _) | clean:: ResolvedPath { is_generic : true , ..} => {
658
+ if f. alternate ( ) {
659
+ write ! ( f, "*{}{:#?}" , RawMutableSpace ( m) , t)
660
+ } else {
661
+ write ! ( f, "*{}{:?}" , RawMutableSpace ( m) , t)
662
+ }
663
+ }
664
+ _ if is_not_debug => {
635
665
primitive_link ( f, clean:: PrimitiveType :: RawPointer ,
636
666
& format ! ( "*{}" , RawMutableSpace ( m) ) ) ?;
637
667
fmt:: Display :: fmt ( t, f)
638
668
}
669
+ _ => {
670
+ write ! ( f, "*{}{:?}" , RawMutableSpace ( m) , t)
671
+ }
639
672
}
640
673
}
641
674
clean:: BorrowedRef { lifetime : ref l, mutability, type_ : ref ty} => {
@@ -647,15 +680,23 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
647
680
match * * ty {
648
681
clean:: Vector ( ref bt) => { // BorrowedRef{ ... Vector(T) } is &[T]
649
682
match * * bt {
650
- clean:: Generic ( _) =>
683
+ clean:: Generic ( _) if is_not_debug => {
651
684
if f. alternate ( ) {
652
685
primitive_link ( f, PrimitiveType :: Slice ,
653
686
& format ! ( "&{}{}[{:#}]" , lt, m, * * bt) )
654
687
} else {
655
688
primitive_link ( f, PrimitiveType :: Slice ,
656
689
& format ! ( "&{}{}[{}]" , lt, m, * * bt) )
657
- } ,
658
- _ => {
690
+ }
691
+ }
692
+ clean:: Generic ( _) => {
693
+ if f. alternate ( ) {
694
+ write ! ( f, "&{}{}[{:#?}]" , lt, m, * * bt)
695
+ } else {
696
+ write ! ( f, "&{}{}[{:?}]" , lt, m, * * bt)
697
+ }
698
+ }
699
+ _ if is_not_debug => {
659
700
if f. alternate ( ) {
660
701
primitive_link ( f, PrimitiveType :: Slice ,
661
702
& format ! ( "&{}{}[" , lt, m) ) ?;
@@ -667,15 +708,26 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
667
708
}
668
709
primitive_link ( f, PrimitiveType :: Slice , "]" )
669
710
}
711
+ _ => {
712
+ if f. alternate ( ) {
713
+ write ! ( f, "&{}{}[{:#?}]" , lt, m, * * bt)
714
+ } else {
715
+ write ! ( f, "&{}{}[{:?}]" , lt, m, * * bt)
716
+ }
717
+ }
670
718
}
671
719
}
672
720
_ => {
673
721
if f. alternate ( ) {
674
722
write ! ( f, "&{}{}" , lt, m) ?;
675
- fmt_type ( & ty, f, use_absolute)
723
+ fmt_type ( & ty, f, use_absolute, is_not_debug )
676
724
} else {
677
- write ! ( f, "&{}{}" , lt, m) ?;
678
- fmt_type ( & ty, f, use_absolute)
725
+ if is_not_debug {
726
+ write ! ( f, "&{}{}" , lt, m) ?;
727
+ } else {
728
+ write ! ( f, "&{}{}" , lt, m) ?;
729
+ }
730
+ fmt_type ( & ty, f, use_absolute, is_not_debug)
679
731
}
680
732
}
681
733
}
@@ -723,9 +775,17 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
723
775
}
724
776
clean:: QPath { ref name, ref self_type, ref trait_ } => {
725
777
if f. alternate ( ) {
726
- write ! ( f, "<{:#} as {:#}>::{}" , self_type, trait_, name)
778
+ if is_not_debug {
779
+ write ! ( f, "<{:#} as {:#}>::{}" , self_type, trait_, name)
780
+ } else {
781
+ write ! ( f, "<{:#?} as {:#?}>::{}" , self_type, trait_, name)
782
+ }
727
783
} else {
728
- write ! ( f, "<{} as {}>::{}" , self_type, trait_, name)
784
+ if is_not_debug {
785
+ write ! ( f, "<{} as {}>::{}" , self_type, trait_, name)
786
+ } else {
787
+ write ! ( f, "<{:?} as {:?}>::{}" , self_type, trait_, name)
788
+ }
729
789
}
730
790
}
731
791
clean:: Unique ( ..) => {
@@ -736,7 +796,13 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
736
796
737
797
impl fmt:: Display for clean:: Type {
738
798
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
739
- fmt_type ( self , f, false )
799
+ fmt_type ( self , f, false , true )
800
+ }
801
+ }
802
+
803
+ impl fmt:: Debug for clean:: Type {
804
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
805
+ fmt_type ( self , f, false , false )
740
806
}
741
807
}
742
808
@@ -777,7 +843,7 @@ fn fmt_impl(i: &clean::Impl,
777
843
plain. push_str ( " for " ) ;
778
844
}
779
845
780
- fmt_type ( & i. for_ , f, use_absolute) ?;
846
+ fmt_type ( & i. for_ , f, use_absolute, true ) ?;
781
847
plain. push_str ( & format ! ( "{:#}" , i. for_) ) ;
782
848
783
849
fmt:: Display :: fmt ( & WhereClause ( & i. generics , plain. len ( ) + 1 ) , f) ?;
0 commit comments