Skip to content

Commit 150f2ba

Browse files
authored
Rollup merge of rust-lang#47440 - mark-i-m:zunpretty, r=nikomatsakis
Change the --unpretty flag to -Z unpretty First PR 😄 ! -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). Fix rust-lang#47395 r? @nikomatsakis EDIT: apparently rust-highfive doesn't see edits...
2 parents 0c9b3ec + ebfa6c7 commit 150f2ba

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

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

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

src/librustc_driver/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,9 @@ fn parse_pretty(sess: &Session,
347347
} else {
348348
None
349349
};
350-
if pretty.is_none() && sess.unstable_options() {
351-
matches.opt_str("unpretty").map(|a| {
350+
351+
if pretty.is_none() {
352+
sess.opts.debugging_opts.unpretty.as_ref().map(|a| {
352353
// extended with unstable pretty-print variants
353354
pretty::parse_pretty(sess, &a, true)
354355
})

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,
@@ -1007,7 +1007,7 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
10071007
move |annotation, _| {
10081008
debug!("pretty printing source code {:?}", s);
10091009
let sess = annotation.sess();
1010-
let hir_map = annotation.hir_map().expect("--unpretty missing HIR map");
1010+
let hir_map = annotation.hir_map().expect("-Z unpretty missing HIR map");
10111011
let mut pp_state = pprust_hir::State::new_from_input(sess.codemap(),
10121012
&sess.parse_sess,
10131013
src_name,
@@ -1020,7 +1020,7 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
10201020
pp_state.print_node(node)?;
10211021
pp_state.s.space()?;
10221022
let path = annotation.node_path(node_id)
1023-
.expect("--unpretty missing node paths");
1023+
.expect("-Z unpretty missing node paths");
10241024
pp_state.synth_comment(path)?;
10251025
pp_state.s.hardbreak()?;
10261026
}
@@ -1072,7 +1072,7 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session,
10721072
ofile: Option<&Path>) {
10731073
let nodeid = if let Some(uii) = uii {
10741074
debug!("pretty printing for {:?}", uii);
1075-
Some(uii.to_one_node_id("--unpretty", sess, &hir_map))
1075+
Some(uii.to_one_node_id("-Z unpretty", sess, &hir_map))
10761076
} else {
10771077
debug!("pretty printing for whole crate");
10781078
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)