@@ -53,10 +53,20 @@ pub enum PpSourceMode {
53
53
PpmExpandedHygiene ,
54
54
}
55
55
56
+
57
+ #[ derive( Copy , PartialEq , Show ) ]
58
+ pub enum PpFlowGraphMode {
59
+ Default ,
60
+ /// Drops the labels from the edges in the flowgraph output. This
61
+ /// is mostly for use in the --xpretty flowgraph run-make tests,
62
+ /// since the labels are largely uninteresting in those cases and
63
+ /// have become a pain to maintain.
64
+ UnlabelledEdges ,
65
+ }
56
66
#[ derive( Copy , PartialEq , Show ) ]
57
67
pub enum PpMode {
58
68
PpmSource ( PpSourceMode ) ,
59
- PpmFlowGraph ,
69
+ PpmFlowGraph ( PpFlowGraphMode ) ,
60
70
}
61
71
62
72
pub fn parse_pretty ( sess : & Session ,
@@ -73,12 +83,13 @@ pub fn parse_pretty(sess: &Session,
73
83
( "expanded,identified" , _) => PpmSource ( PpmExpandedIdentified ) ,
74
84
( "expanded,hygiene" , _) => PpmSource ( PpmExpandedHygiene ) ,
75
85
( "identified" , _) => PpmSource ( PpmIdentified ) ,
76
- ( "flowgraph" , true ) => PpmFlowGraph ,
86
+ ( "flowgraph" , true ) => PpmFlowGraph ( PpFlowGraphMode :: Default ) ,
87
+ ( "flowgraph,unlabelled" , true ) => PpmFlowGraph ( PpFlowGraphMode :: UnlabelledEdges ) ,
77
88
_ => {
78
89
if extended {
79
90
sess. fatal ( format ! (
80
91
"argument to `xpretty` must be one of `normal`, \
81
- `expanded`, `flowgraph=<nodeid>`, `typed`, `identified`, \
92
+ `expanded`, `flowgraph[,unlabelled] =<nodeid>`, `typed`, `identified`, \
82
93
`expanded,identified`, or `everybody_loops`; got {}", name) . as_slice ( ) ) ;
83
94
} else {
84
95
sess. fatal ( format ! (
@@ -417,7 +428,7 @@ fn needs_ast_map(ppm: &PpMode, opt_uii: &Option<UserIdentifiedItem>) -> bool {
417
428
PpmSource ( PpmExpandedIdentified ) |
418
429
PpmSource ( PpmExpandedHygiene ) |
419
430
PpmSource ( PpmTyped ) |
420
- PpmFlowGraph => true
431
+ PpmFlowGraph ( _ ) => true
421
432
}
422
433
}
423
434
@@ -431,7 +442,7 @@ fn needs_expansion(ppm: &PpMode) -> bool {
431
442
PpmSource ( PpmExpandedIdentified ) |
432
443
PpmSource ( PpmExpandedHygiene ) |
433
444
PpmSource ( PpmTyped ) |
434
- PpmFlowGraph => true
445
+ PpmFlowGraph ( _ ) => true
435
446
}
436
447
}
437
448
@@ -589,7 +600,7 @@ pub fn pretty_print_input(sess: Session,
589
600
pp:: eof ( & mut pp_state. s )
590
601
} ) ,
591
602
592
- ( PpmFlowGraph , opt_uii) => {
603
+ ( PpmFlowGraph ( mode ) , opt_uii) => {
593
604
debug ! ( "pretty printing flow graph for {:?}" , opt_uii) ;
594
605
let uii = opt_uii. unwrap_or_else ( || {
595
606
sess. fatal ( & format ! ( "`pretty flowgraph=..` needs NodeId (int) or
@@ -613,7 +624,7 @@ pub fn pretty_print_input(sess: Session,
613
624
& arenas,
614
625
id,
615
626
resolve:: MakeGlobMap :: No ) ;
616
- print_flowgraph ( variants, analysis, code, out)
627
+ print_flowgraph ( variants, analysis, code, mode , out)
617
628
}
618
629
None => {
619
630
let message = format ! ( "--pretty=flowgraph needs \
@@ -635,20 +646,23 @@ pub fn pretty_print_input(sess: Session,
635
646
fn print_flowgraph < W : io:: Writer > ( variants : Vec < borrowck_dot:: Variant > ,
636
647
analysis : ty:: CrateAnalysis ,
637
648
code : blocks:: Code ,
649
+ mode : PpFlowGraphMode ,
638
650
mut out : W ) -> io:: IoResult < ( ) > {
639
651
let ty_cx = & analysis. ty_cx ;
640
652
let cfg = match code {
641
653
blocks:: BlockCode ( block) => cfg:: CFG :: new ( ty_cx, & * block) ,
642
654
blocks:: FnLikeCode ( fn_like) => cfg:: CFG :: new ( ty_cx, & * fn_like. body ( ) ) ,
643
655
} ;
656
+ let labelled_edges = mode != PpFlowGraphMode :: UnlabelledEdges ;
657
+ let lcfg = LabelledCFG {
658
+ ast_map : & ty_cx. map ,
659
+ cfg : & cfg,
660
+ name : format ! ( "node_{}" , code. id( ) ) ,
661
+ labelled_edges : labelled_edges,
662
+ } ;
644
663
645
664
match code {
646
665
_ if variants. len ( ) == 0 => {
647
- let lcfg = LabelledCFG {
648
- ast_map : & ty_cx. map ,
649
- cfg : & cfg,
650
- name : format ! ( "node_{}" , code. id( ) ) ,
651
- } ;
652
666
let r = dot:: render ( & lcfg, & mut out) ;
653
667
return expand_err_details ( r) ;
654
668
}
@@ -662,11 +676,6 @@ fn print_flowgraph<W:io::Writer>(variants: Vec<borrowck_dot::Variant>,
662
676
let ( bccx, analysis_data) =
663
677
borrowck:: build_borrowck_dataflow_data_for_fn ( ty_cx, fn_parts) ;
664
678
665
- let lcfg = LabelledCFG {
666
- ast_map : & ty_cx. map ,
667
- cfg : & cfg,
668
- name : format ! ( "node_{}" , code. id( ) ) ,
669
- } ;
670
679
let lcfg = borrowck_dot:: DataflowLabeller {
671
680
inner : lcfg,
672
681
variants : variants,
0 commit comments