Skip to content

Commit 1eb280e

Browse files
committed
Remove unpretty=flowgraph.
1 parent 463b197 commit 1eb280e

File tree

3 files changed

+14
-182
lines changed

3 files changed

+14
-182
lines changed

src/librustc/session/config.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,14 +1268,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
12681268
save_analysis: bool = (false, parse_bool, [UNTRACKED],
12691269
"write syntax and type analysis (in JSON format) information, in \
12701270
addition to normal output"),
1271-
flowgraph_print_loans: bool = (false, parse_bool, [UNTRACKED],
1272-
"include loan analysis data in -Z unpretty flowgraph output"),
1273-
flowgraph_print_moves: bool = (false, parse_bool, [UNTRACKED],
1274-
"include move analysis data in -Z unpretty flowgraph output"),
1275-
flowgraph_print_assigns: bool = (false, parse_bool, [UNTRACKED],
1276-
"include assignment analysis data in -Z unpretty flowgraph output"),
1277-
flowgraph_print_all: bool = (false, parse_bool, [UNTRACKED],
1278-
"include all dataflow analysis data in -Z unpretty flowgraph output"),
12791271
print_region_graph: bool = (false, parse_bool, [UNTRACKED],
12801272
"prints region inference graph. \
12811273
Use with RUST_REGION_GRAPH=help for more info"),
@@ -1424,8 +1416,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
14241416
valid types are any of the types for `--pretty`, as well as:
14251417
`expanded`, `expanded,identified`,
14261418
`expanded,hygiene` (with internal representations),
1427-
`flowgraph=<nodeid>` (graphviz formatted flowgraph for node),
1428-
`flowgraph,unlabelled=<nodeid>` (unlabelled graphviz formatted flowgraph for node),
14291419
`everybody_loops` (all function bodies replaced with `loop {}`),
14301420
`hir` (the HIR), `hir,identified`,
14311421
`hir,typed` (HIR with types for each node),

src/librustc/session/config/tests.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -589,14 +589,6 @@ fn test_debugging_options_tracking_hash() {
589589
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
590590
opts.debugging_opts.save_analysis = true;
591591
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
592-
opts.debugging_opts.flowgraph_print_loans = true;
593-
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
594-
opts.debugging_opts.flowgraph_print_moves = true;
595-
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
596-
opts.debugging_opts.flowgraph_print_assigns = true;
597-
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
598-
opts.debugging_opts.flowgraph_print_all = true;
599-
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
600592
opts.debugging_opts.print_region_graph = true;
601593
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
602594
opts.debugging_opts.parse_only = true;

src/librustc_driver/pretty.rs

Lines changed: 14 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,23 @@
22
33
use rustc::hir;
44
use rustc::hir::map as hir_map;
5-
use rustc::hir::map::blocks;
65
use rustc::hir::print as pprust_hir;
76
use rustc::hir::def_id::LOCAL_CRATE;
87
use rustc::session::Session;
98
use rustc::session::config::Input;
109
use rustc::ty::{self, TyCtxt};
1110
use rustc::util::common::ErrorReported;
1211
use rustc_interface::util::ReplaceBodyWithLoop;
13-
use rustc_ast_borrowck as borrowck;
14-
use rustc_ast_borrowck::graphviz as borrowck_dot;
15-
use rustc_ast_borrowck::cfg::{self, graphviz::LabelledCFG};
1612
use rustc_mir::util::{write_mir_pretty, write_mir_graphviz};
1713

1814
use syntax::ast;
1915
use syntax::mut_visit::MutVisitor;
2016
use syntax::print::{pprust};
2117
use syntax_pos::FileName;
2218

23-
use graphviz as dot;
24-
2519
use std::cell::Cell;
2620
use std::fs::File;
27-
use std::io::{self, Write};
21+
use std::io::Write;
2822
use std::option;
2923
use std::path::Path;
3024
use std::str::FromStr;
@@ -48,21 +42,11 @@ pub enum PpSourceMode {
4842
PpmTyped,
4943
}
5044

51-
#[derive(Copy, Clone, PartialEq, Debug)]
52-
pub enum PpFlowGraphMode {
53-
Default,
54-
/// Drops the labels from the edges in the flowgraph output. This
55-
/// is mostly for use in the -Z unpretty flowgraph run-make tests,
56-
/// since the labels are largely uninteresting in those cases and
57-
/// have become a pain to maintain.
58-
UnlabelledEdges,
59-
}
6045
#[derive(Copy, Clone, PartialEq, Debug)]
6146
pub enum PpMode {
6247
PpmSource(PpSourceMode),
6348
PpmHir(PpSourceMode),
6449
PpmHirTree(PpSourceMode),
65-
PpmFlowGraph(PpFlowGraphMode),
6650
PpmMir,
6751
PpmMirCFG,
6852
}
@@ -80,15 +64,14 @@ impl PpMode {
8064
PpmHir(_) |
8165
PpmHirTree(_) |
8266
PpmMir |
83-
PpmMirCFG |
84-
PpmFlowGraph(_) => true,
67+
PpmMirCFG => true,
8568
PpmSource(PpmTyped) => panic!("invalid state"),
8669
}
8770
}
8871

8972
pub fn needs_analysis(&self) -> bool {
9073
match *self {
91-
PpmMir | PpmMirCFG | PpmFlowGraph(_) => true,
74+
PpmMir | PpmMirCFG => true,
9275
_ => false,
9376
}
9477
}
@@ -114,15 +97,13 @@ pub fn parse_pretty(sess: &Session,
11497
("hir-tree", true) => PpmHirTree(PpmNormal),
11598
("mir", true) => PpmMir,
11699
("mir-cfg", true) => PpmMirCFG,
117-
("flowgraph", true) => PpmFlowGraph(PpFlowGraphMode::Default),
118-
("flowgraph,unlabelled", true) => PpmFlowGraph(PpFlowGraphMode::UnlabelledEdges),
119100
_ => {
120101
if extended {
121102
sess.fatal(&format!("argument to `unpretty` must be one of `normal`, \
122-
`expanded`, `flowgraph[,unlabelled]=<nodeid>`, \
123-
`identified`, `expanded,identified`, `everybody_loops`, \
124-
`hir`, `hir,identified`, `hir,typed`, `hir-tree`, \
125-
`mir` or `mir-cfg`; got {}",
103+
`expanded`, `identified`, `expanded,identified`, \
104+
`everybody_loops`, `hir`, `hir,identified`, \
105+
`hir,typed`, `hir-tree`, `mir` or `mir-cfg`; \
106+
got {}",
126107
name));
127108
} else {
128109
sess.fatal(&format!("argument to `pretty` must be one of `normal`, `expanded`, \
@@ -501,24 +482,6 @@ impl<'a, 'tcx> pprust_hir::PpAnn for TypedAnnotation<'a, 'tcx> {
501482
}
502483
}
503484

504-
fn gather_flowgraph_variants(sess: &Session) -> Vec<borrowck_dot::Variant> {
505-
let print_loans = sess.opts.debugging_opts.flowgraph_print_loans;
506-
let print_moves = sess.opts.debugging_opts.flowgraph_print_moves;
507-
let print_assigns = sess.opts.debugging_opts.flowgraph_print_assigns;
508-
let print_all = sess.opts.debugging_opts.flowgraph_print_all;
509-
let mut variants = Vec::new();
510-
if print_all || print_loans {
511-
variants.push(borrowck_dot::Loans);
512-
}
513-
if print_all || print_moves {
514-
variants.push(borrowck_dot::Moves);
515-
}
516-
if print_all || print_assigns {
517-
variants.push(borrowck_dot::Assigns);
518-
}
519-
variants
520-
}
521-
522485
#[derive(Clone, Debug)]
523486
pub enum UserIdentifiedItem {
524487
ItemViaNode(ast::NodeId),
@@ -609,81 +572,6 @@ impl UserIdentifiedItem {
609572
}
610573
}
611574

612-
fn print_flowgraph<'tcx, W: Write>(
613-
variants: Vec<borrowck_dot::Variant>,
614-
tcx: TyCtxt<'tcx>,
615-
code: blocks::Code<'tcx>,
616-
mode: PpFlowGraphMode,
617-
mut out: W,
618-
) -> io::Result<()> {
619-
let body_id = match code {
620-
blocks::Code::Expr(expr) => {
621-
// Find the function this expression is from.
622-
let mut hir_id = expr.hir_id;
623-
loop {
624-
let node = tcx.hir().get(hir_id);
625-
if let Some(n) = hir::map::blocks::FnLikeNode::from_node(node) {
626-
break n.body();
627-
}
628-
let parent = tcx.hir().get_parent_node(hir_id);
629-
assert_ne!(hir_id, parent);
630-
hir_id = parent;
631-
}
632-
}
633-
blocks::Code::FnLike(fn_like) => fn_like.body(),
634-
};
635-
let body = tcx.hir().body(body_id);
636-
let cfg = cfg::CFG::new(tcx, &body);
637-
let labelled_edges = mode != PpFlowGraphMode::UnlabelledEdges;
638-
let hir_id = code.id();
639-
// We have to disassemble the hir_id because name must be ASCII
640-
// alphanumeric. This does not appear in the rendered graph, so it does not
641-
// have to be user friendly.
642-
let name = format!(
643-
"hir_id_{}_{}",
644-
hir_id.owner.index(),
645-
hir_id.local_id.index(),
646-
);
647-
let lcfg = LabelledCFG {
648-
tcx,
649-
cfg: &cfg,
650-
name,
651-
labelled_edges,
652-
};
653-
654-
match code {
655-
_ if variants.is_empty() => {
656-
let r = dot::render(&lcfg, &mut out);
657-
return expand_err_details(r);
658-
}
659-
blocks::Code::Expr(_) => {
660-
tcx.sess.err("--pretty flowgraph with -Z flowgraph-print annotations requires \
661-
fn-like node id.");
662-
return Ok(());
663-
}
664-
blocks::Code::FnLike(fn_like) => {
665-
let (bccx, analysis_data) =
666-
borrowck::build_borrowck_dataflow_data_for_fn(tcx, fn_like.body(), &cfg);
667-
668-
let lcfg = borrowck_dot::DataflowLabeller {
669-
inner: lcfg,
670-
variants,
671-
borrowck_ctxt: &bccx,
672-
analysis_data: &analysis_data,
673-
};
674-
let r = dot::render(&lcfg, &mut out);
675-
return expand_err_details(r);
676-
}
677-
}
678-
679-
fn expand_err_details(r: io::Result<()>) -> io::Result<()> {
680-
r.map_err(|ioerr| {
681-
io::Error::new(io::ErrorKind::Other,
682-
format!("graphviz::render failed: {}", ioerr))
683-
})
684-
}
685-
}
686-
687575
pub fn visit_crate(sess: &Session, krate: &mut ast::Crate, ppm: PpMode) {
688576
if let PpmSource(PpmEveryBodyLoops) = ppm {
689577
ReplaceBodyWithLoop::new(sess).visit_crate(krate);
@@ -872,55 +760,17 @@ fn print_with_analysis(
872760

873761
tcx.analysis(LOCAL_CRATE)?;
874762

875-
let mut print = || match ppm {
763+
match ppm {
876764
PpmMir | PpmMirCFG => {
877-
if let Some(nodeid) = nodeid {
878-
let def_id = tcx.hir().local_def_id_from_node_id(nodeid);
879-
match ppm {
880-
PpmMir => write_mir_pretty(tcx, Some(def_id), &mut out),
881-
PpmMirCFG => write_mir_graphviz(tcx, Some(def_id), &mut out),
882-
_ => unreachable!(),
883-
}?;
884-
} else {
885-
match ppm {
886-
PpmMir => write_mir_pretty(tcx, None, &mut out),
887-
PpmMirCFG => write_mir_graphviz(tcx, None, &mut out),
888-
_ => unreachable!(),
889-
}?;
890-
}
891-
Ok(())
892-
}
893-
PpmFlowGraph(mode) => {
894-
let nodeid =
895-
nodeid.expect("`pretty flowgraph=..` needs NodeId (int) or unique path \
896-
suffix (b::c::d)");
897-
let hir_id = tcx.hir().node_to_hir_id(nodeid);
898-
let node = tcx.hir().find(hir_id).unwrap_or_else(|| {
899-
tcx.sess.fatal(&format!("`--pretty=flowgraph` couldn't find ID: {}", nodeid))
900-
});
901-
902-
match blocks::Code::from_node(&tcx.hir(), hir_id) {
903-
Some(code) => {
904-
let variants = gather_flowgraph_variants(tcx.sess);
905-
906-
let out: &mut dyn Write = &mut out;
907-
908-
print_flowgraph(variants, tcx, code, mode, out)
909-
}
910-
None => {
911-
let message = format!("`--pretty=flowgraph` needs block, fn, or method; \
912-
got {:?}",
913-
node);
914-
915-
let hir_id = tcx.hir().node_to_hir_id(nodeid);
916-
tcx.sess.span_fatal(tcx.hir().span(hir_id), &message)
917-
}
765+
let def_id = nodeid.map(|nid| tcx.hir().local_def_id_from_node_id(nid));
766+
match ppm {
767+
PpmMir => write_mir_pretty(tcx, def_id, &mut out),
768+
PpmMirCFG => write_mir_graphviz(tcx, def_id, &mut out),
769+
_ => unreachable!(),
918770
}
919771
}
920772
_ => unreachable!(),
921-
};
922-
923-
print().unwrap();
773+
}.unwrap();
924774

925775
write_output(out, ofile);
926776

0 commit comments

Comments
 (0)