@@ -425,3 +425,138 @@ BraceStructTypeFoldableImpl! {
425
425
obligations
426
426
} where T : TypeFoldable <' tcx>
427
427
}
428
+
429
+ impl < ' tcx > fmt:: Display for traits:: WhereClauseAtom < ' tcx > {
430
+ fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
431
+ use traits:: WhereClauseAtom :: * ;
432
+
433
+ match self {
434
+ Implemented ( trait_ref) => write ! ( fmt, "Implemented({})" , trait_ref) ,
435
+ ProjectionEq ( projection) => write ! ( fmt, "ProjectionEq({})" , projection) ,
436
+ }
437
+ }
438
+ }
439
+
440
+ impl < ' tcx > fmt:: Display for traits:: DomainGoal < ' tcx > {
441
+ fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
442
+ use traits:: DomainGoal :: * ;
443
+ use traits:: WhereClauseAtom :: * ;
444
+
445
+ match self {
446
+ Holds ( wc) => write ! ( fmt, "{}" , wc) ,
447
+ WellFormed ( Implemented ( trait_ref) ) => write ! ( fmt, "WellFormed({})" , trait_ref) ,
448
+ WellFormed ( ProjectionEq ( projection) ) => write ! ( fmt, "WellFormed({})" , projection) ,
449
+ FromEnv ( Implemented ( trait_ref) ) => write ! ( fmt, "FromEnv({})" , trait_ref) ,
450
+ FromEnv ( ProjectionEq ( projection) ) => write ! ( fmt, "FromEnv({})" , projection) ,
451
+ WellFormedTy ( ty) => write ! ( fmt, "WellFormed({})" , ty) ,
452
+ FromEnvTy ( ty) => write ! ( fmt, "FromEnv({})" , ty) ,
453
+ RegionOutlives ( predicate) => write ! ( fmt, "RegionOutlives({})" , predicate) ,
454
+ TypeOutlives ( predicate) => write ! ( fmt, "TypeOutlives({})" , predicate) ,
455
+ }
456
+ }
457
+ }
458
+
459
+ impl fmt:: Display for traits:: QuantifierKind {
460
+ fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
461
+ use traits:: QuantifierKind :: * ;
462
+
463
+ match self {
464
+ Universal => write ! ( fmt, "forall" ) ,
465
+ Existential => write ! ( fmt, "exists" ) ,
466
+ }
467
+ }
468
+ }
469
+
470
+ impl < ' tcx > fmt:: Display for traits:: Goal < ' tcx > {
471
+ fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
472
+ use traits:: Goal :: * ;
473
+
474
+ match self {
475
+ Implies ( hypotheses, goal) => {
476
+ write ! ( fmt, "if (" ) ?;
477
+ for ( index, hyp) in hypotheses. iter ( ) . enumerate ( ) {
478
+ if index > 0 {
479
+ write ! ( fmt, ", " ) ?;
480
+ }
481
+ write ! ( fmt, "{}" , hyp) ?;
482
+ }
483
+ write ! ( fmt, ") {{ {} }}" , goal)
484
+ }
485
+ And ( goal1, goal2) => write ! ( fmt, "({} && {})" , goal1, goal2) ,
486
+ Not ( goal) => write ! ( fmt, "not {{ {} }}" , goal) ,
487
+ DomainGoal ( goal) => write ! ( fmt, "{}" , goal) ,
488
+ Quantified ( qkind, goal) => {
489
+ // FIXME: appropriate binder names
490
+ write ! ( fmt, "{}<> {{ {} }}" , qkind, goal. skip_binder( ) )
491
+ }
492
+ }
493
+ }
494
+ }
495
+
496
+ impl < ' tcx > fmt:: Display for traits:: Clause < ' tcx > {
497
+ fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
498
+ use traits:: Clause :: * ;
499
+
500
+ match self {
501
+ Implies ( hypotheses, goal) => {
502
+ write ! ( fmt, "{}" , goal) ?;
503
+ if !hypotheses. is_empty ( ) {
504
+ write ! ( fmt, " :- " ) ?;
505
+ for ( index, condition) in hypotheses. iter ( ) . enumerate ( ) {
506
+ if index > 0 {
507
+ write ! ( fmt, ", " ) ?;
508
+ }
509
+ write ! ( fmt, "{}" , condition) ?;
510
+ }
511
+ }
512
+ write ! ( fmt, "." )
513
+ }
514
+ DomainGoal ( domain_goal) => write ! ( fmt, "{}." , domain_goal) ,
515
+ ForAll ( clause) => {
516
+ // FIXME: appropriate binder names
517
+ write ! ( fmt, "forall<> {{ {} }}" , clause. skip_binder( ) )
518
+ }
519
+ }
520
+ }
521
+ }
522
+
523
+ EnumTypeFoldableImpl ! {
524
+ impl <' tcx> TypeFoldable <' tcx> for traits:: WhereClauseAtom <' tcx> {
525
+ ( traits:: WhereClauseAtom :: Implemented ) ( trait_ref) ,
526
+ ( traits:: WhereClauseAtom :: ProjectionEq ) ( projection) ,
527
+ }
528
+ }
529
+
530
+ EnumTypeFoldableImpl ! {
531
+ impl <' tcx> TypeFoldable <' tcx> for traits:: DomainGoal <' tcx> {
532
+ ( traits:: DomainGoal :: Holds ) ( wc) ,
533
+ ( traits:: DomainGoal :: WellFormed ) ( wc) ,
534
+ ( traits:: DomainGoal :: FromEnv ) ( wc) ,
535
+ ( traits:: DomainGoal :: WellFormedTy ) ( ty) ,
536
+ ( traits:: DomainGoal :: FromEnvTy ) ( ty) ,
537
+ ( traits:: DomainGoal :: RegionOutlives ) ( predicate) ,
538
+ ( traits:: DomainGoal :: TypeOutlives ) ( predicate) ,
539
+ }
540
+ }
541
+
542
+ CloneTypeFoldableImpls ! {
543
+ traits:: QuantifierKind ,
544
+ }
545
+
546
+ EnumTypeFoldableImpl ! {
547
+ impl <' tcx> TypeFoldable <' tcx> for traits:: Goal <' tcx> {
548
+ ( traits:: Goal :: Implies ) ( hypotheses, goal) ,
549
+ ( traits:: Goal :: And ) ( goal1, goal2) ,
550
+ ( traits:: Goal :: Not ) ( goal) ,
551
+ ( traits:: Goal :: DomainGoal ) ( domain_goal) ,
552
+ ( traits:: Goal :: Quantified ) ( qkind, goal) ,
553
+ }
554
+ }
555
+
556
+ EnumTypeFoldableImpl ! {
557
+ impl <' tcx> TypeFoldable <' tcx> for traits:: Clause <' tcx> {
558
+ ( traits:: Clause :: Implies ) ( hypotheses, goal) ,
559
+ ( traits:: Clause :: DomainGoal ) ( domain_goal) ,
560
+ ( traits:: Clause :: ForAll ) ( clause) ,
561
+ }
562
+ }
0 commit comments