Skip to content

Commit ebfa6c7

Browse files
committed
Change the --unpretty flag to -Z unpretty
-Z unpretty no longer requires -Z unstable-options. Also, I mildly changed the syntax of the flag to match the other -Z flags. All uses of the flag take the form `unpretty=something` where something can either `string` or `string=string` (see the help messages of the CLI).
1 parent 3bd4af8 commit ebfa6c7

File tree

8 files changed

+38
-27
lines changed

8 files changed

+38
-27
lines changed

src/librustc/session/config.rs

+24-12
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,8 @@ macro_rules! options {
778778
Some(::rustc_back::LinkerFlavor::one_of());
779779
pub const parse_optimization_fuel: Option<&'static str> =
780780
Some("crate=integer");
781+
pub const parse_unpretty: Option<&'static str> =
782+
Some("`string` or `string=string`");
781783
}
782784

783785
#[allow(dead_code)]
@@ -965,6 +967,17 @@ macro_rules! options {
965967
}
966968
}
967969
}
970+
971+
fn parse_unpretty(slot: &mut Option<String>, v: Option<&str>) -> bool {
972+
match v {
973+
None => false,
974+
Some(s) if s.split('=').count() <= 2 => {
975+
*slot = Some(s.to_string());
976+
true
977+
}
978+
_ => false,
979+
}
980+
}
968981
}
969982
) }
970983

@@ -1102,13 +1115,13 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
11021115
"write syntax and type analysis (in JSON format) information, in \
11031116
addition to normal output"),
11041117
flowgraph_print_loans: bool = (false, parse_bool, [UNTRACKED],
1105-
"include loan analysis data in --unpretty flowgraph output"),
1118+
"include loan analysis data in -Z unpretty flowgraph output"),
11061119
flowgraph_print_moves: bool = (false, parse_bool, [UNTRACKED],
1107-
"include move analysis data in --unpretty flowgraph output"),
1120+
"include move analysis data in -Z unpretty flowgraph output"),
11081121
flowgraph_print_assigns: bool = (false, parse_bool, [UNTRACKED],
1109-
"include assignment analysis data in --unpretty flowgraph output"),
1122+
"include assignment analysis data in -Z unpretty flowgraph output"),
11101123
flowgraph_print_all: bool = (false, parse_bool, [UNTRACKED],
1111-
"include all dataflow analysis data in --unpretty flowgraph output"),
1124+
"include all dataflow analysis data in -Z unpretty flowgraph output"),
11121125
print_region_graph: bool = (false, parse_bool, [UNTRACKED],
11131126
"prints region inference graph. \
11141127
Use with RUST_REGION_GRAPH=help for more info"),
@@ -1239,6 +1252,13 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
12391252
dep_info_omit_d_target: bool = (false, parse_bool, [TRACKED],
12401253
"in dep-info output, omit targets for tracking dependencies of the dep-info files \
12411254
themselves"),
1255+
unpretty: Option<String> = (None, parse_unpretty, [UNTRACKED],
1256+
"Present the input source, unstable (and less-pretty) variants;
1257+
valid types are any of the types for `--pretty`, as well as:
1258+
`flowgraph=<nodeid>` (graphviz formatted flowgraph for node),
1259+
`everybody_loops` (all function bodies replaced with `loop {}`),
1260+
`hir` (the HIR), `hir,identified`, or
1261+
`hir,typed` (HIR with types for each node)."),
12421262
}
12431263

12441264
pub fn default_lib_output() -> CrateType {
@@ -1512,14 +1532,6 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
15121532
`expanded` (crates expanded), or
15131533
`expanded,identified` (fully parenthesized, AST nodes with IDs).",
15141534
"TYPE"),
1515-
opt::opt("", "unpretty",
1516-
"Present the input source, unstable (and less-pretty) variants;
1517-
valid types are any of the types for `--pretty`, as well as:
1518-
`flowgraph=<nodeid>` (graphviz formatted flowgraph for node),
1519-
`everybody_loops` (all function bodies replaced with `loop {}`),
1520-
`hir` (the HIR), `hir,identified`, or
1521-
`hir,typed` (HIR with types for each node).",
1522-
"TYPE"),
15231535
]);
15241536
opts
15251537
}

src/librustc_driver/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,9 @@ fn parse_pretty(sess: &Session,
292292
} else {
293293
None
294294
};
295-
if pretty.is_none() && sess.unstable_options() {
296-
matches.opt_str("unpretty").map(|a| {
295+
296+
if pretty.is_none() {
297+
sess.opts.debugging_opts.unpretty.as_ref().map(|a| {
297298
// extended with unstable pretty-print variants
298299
pretty::parse_pretty(sess, &a, true)
299300
})

src/librustc_driver/pretty.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pub enum PpSourceMode {
6666
pub enum PpFlowGraphMode {
6767
Default,
6868
/// Drops the labels from the edges in the flowgraph output. This
69-
/// is mostly for use in the --unpretty flowgraph run-make tests,
69+
/// is mostly for use in the -Z unpretty flowgraph run-make tests,
7070
/// since the labels are largely uninteresting in those cases and
7171
/// have become a pain to maintain.
7272
UnlabelledEdges,
@@ -1006,7 +1006,7 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
10061006
move |annotation, _| {
10071007
debug!("pretty printing source code {:?}", s);
10081008
let sess = annotation.sess();
1009-
let hir_map = annotation.hir_map().expect("--unpretty missing HIR map");
1009+
let hir_map = annotation.hir_map().expect("-Z unpretty missing HIR map");
10101010
let mut pp_state = pprust_hir::State::new_from_input(sess.codemap(),
10111011
&sess.parse_sess,
10121012
src_name,
@@ -1019,7 +1019,7 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
10191019
pp_state.print_node(node)?;
10201020
pp_state.s.space()?;
10211021
let path = annotation.node_path(node_id)
1022-
.expect("--unpretty missing node paths");
1022+
.expect("-Z unpretty missing node paths");
10231023
pp_state.synth_comment(path)?;
10241024
pp_state.s.hardbreak()?;
10251025
}
@@ -1071,7 +1071,7 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session,
10711071
ofile: Option<&Path>) {
10721072
let nodeid = if let Some(uii) = uii {
10731073
debug!("pretty printing for {:?}", uii);
1074-
Some(uii.to_one_node_id("--unpretty", sess, &hir_map))
1074+
Some(uii.to_one_node_id("-Z unpretty", sess, &hir_map))
10751075
} else {
10761076
debug!("pretty printing for whole crate");
10771077
None

src/test/compile-fail/issue-37665.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// compile-flags: -Z unstable-options --unpretty=mir
11+
// compile-flags: -Z unpretty=mir
1212
// ignore-cloudabi no std::path
1313

1414
use std::path::MAIN_SEPARATOR;

src/test/compile-fail/mir-unpretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// compile-flags: -Z unstable-options --unpretty=mir
11+
// compile-flags: -Z unpretty=mir
1212

1313
fn main() {
1414
let x: () = 0; //~ ERROR: mismatched types

src/test/run-make/hir-tree/Makefile

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@
44
# the string constant we would expect to see.
55

66
all:
7-
$(RUSTC) -o $(TMPDIR)/input.hir -Z unstable-options \
8-
--unpretty=hir-tree input.rs
7+
$(RUSTC) -o $(TMPDIR)/input.hir -Z unpretty=hir-tree input.rs
98
$(CGREP) '"Hello, Rustaceans!\n"' < $(TMPDIR)/input.hir
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
-include ../tools.mk
22

33
all:
4-
$(RUSTC) -o $(TMPDIR)/foo.out -Z unstable-options --unpretty hir=foo input.rs
5-
$(RUSTC) -o $(TMPDIR)/nest_foo.out -Z unstable-options --unpretty hir=nest::foo input.rs
6-
$(RUSTC) -o $(TMPDIR)/foo_method.out -Z unstable-options --unpretty hir=foo_method input.rs
4+
$(RUSTC) -o $(TMPDIR)/foo.out -Z unpretty=hir=foo input.rs
5+
$(RUSTC) -o $(TMPDIR)/nest_foo.out -Z unpretty=hir=nest::foo input.rs
6+
$(RUSTC) -o $(TMPDIR)/foo_method.out -Z unpretty=hir=foo_method input.rs
77
diff -u $(TMPDIR)/foo.out foo.pp
88
diff -u $(TMPDIR)/nest_foo.out nest_foo.pp
99
diff -u $(TMPDIR)/foo_method.out foo_method.pp

src/tools/compiletest/src/runtest.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,7 @@ impl<'test> TestCx<'test> {
466466
let mut rustc = Command::new(&self.config.rustc_path);
467467
rustc
468468
.arg("-")
469-
.arg("-Zunstable-options")
470-
.args(&["--unpretty", &pretty_type])
469+
.args(&["-Z", &format!("unpretty={}", pretty_type)])
471470
.args(&["--target", &self.config.target])
472471
.arg("-L")
473472
.arg(&aux_dir)

0 commit comments

Comments
 (0)