Skip to content

Commit 23bbd65

Browse files
committed
Remove unstable --pretty flag
It doesn't do anything `--unpretty` doesn't, and due to a bug, also didn't show up in `--help`. I don't think there's any reason to keep it around, I haven't seen anyone using it.
1 parent 7f4afdf commit 23bbd65

File tree

8 files changed

+47
-87
lines changed

8 files changed

+47
-87
lines changed

compiler/rustc_session/src/config.rs

+40-79
Original file line numberDiff line numberDiff line change
@@ -1125,15 +1125,6 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
11251125
never = never colorize output",
11261126
"auto|always|never",
11271127
),
1128-
opt::opt(
1129-
"",
1130-
"pretty",
1131-
"Pretty-print the input instead of compiling;
1132-
valid types are: `normal` (un-annotated source),
1133-
`expanded` (crates expanded), or
1134-
`expanded,identified` (fully parenthesized, AST nodes with IDs).",
1135-
"TYPE",
1136-
),
11371128
opt::multi_s(
11381129
"",
11391130
"remap-path-prefix",
@@ -1969,7 +1960,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
19691960

19701961
let remap_path_prefix = parse_remap_path_prefix(matches, error_format);
19711962

1972-
let pretty = parse_pretty(matches, &debugging_opts, error_format);
1963+
let pretty = parse_pretty(&debugging_opts, error_format);
19731964

19741965
if !debugging_opts.unstable_options
19751966
&& !target_triple.triple().contains("apple")
@@ -2017,69 +2008,39 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
20172008
}
20182009
}
20192010

2020-
fn parse_pretty(
2021-
matches: &getopts::Matches,
2022-
debugging_opts: &DebuggingOptions,
2023-
efmt: ErrorOutputType,
2024-
) -> Option<PpMode> {
2025-
fn parse_pretty_inner(efmt: ErrorOutputType, name: &str, extended: bool) -> PpMode {
2026-
use PpMode::*;
2027-
let first = match (name, extended) {
2028-
("normal", _) => Source(PpSourceMode::Normal),
2029-
("identified", _) => Source(PpSourceMode::Identified),
2030-
("everybody_loops", true) => Source(PpSourceMode::EveryBodyLoops),
2031-
("expanded", _) => Source(PpSourceMode::Expanded),
2032-
("expanded,identified", _) => Source(PpSourceMode::ExpandedIdentified),
2033-
("expanded,hygiene", _) => Source(PpSourceMode::ExpandedHygiene),
2034-
("ast-tree", true) => AstTree(PpAstTreeMode::Normal),
2035-
("ast-tree,expanded", true) => AstTree(PpAstTreeMode::Expanded),
2036-
("hir", true) => Hir(PpHirMode::Normal),
2037-
("hir,identified", true) => Hir(PpHirMode::Identified),
2038-
("hir,typed", true) => Hir(PpHirMode::Typed),
2039-
("hir-tree", true) => HirTree,
2040-
("thir-tree", true) => ThirTree,
2041-
("mir", true) => Mir,
2042-
("mir-cfg", true) => MirCFG,
2043-
_ => {
2044-
if extended {
2045-
early_error(
2046-
efmt,
2047-
&format!(
2048-
"argument to `unpretty` must be one of `normal`, \
2049-
`expanded`, `identified`, `expanded,identified`, \
2050-
`expanded,hygiene`, `everybody_loops`, \
2051-
`ast-tree`, `ast-tree,expanded`, `hir`, `hir,identified`, \
2052-
`hir,typed`, `hir-tree`, `mir` or `mir-cfg`; got {}",
2053-
name
2054-
),
2055-
);
2056-
} else {
2057-
early_error(
2058-
efmt,
2059-
&format!(
2060-
"argument to `pretty` must be one of `normal`, \
2061-
`expanded`, `identified`, or `expanded,identified`; got {}",
2062-
name
2063-
),
2064-
);
2065-
}
2066-
}
2067-
};
2068-
tracing::debug!("got unpretty option: {:?}", first);
2069-
first
2070-
}
2071-
2072-
if debugging_opts.unstable_options {
2073-
if let Some(a) = matches.opt_default("pretty", "normal") {
2074-
// stable pretty-print variants only
2075-
return Some(parse_pretty_inner(efmt, &a, false));
2076-
}
2077-
}
2078-
2079-
debugging_opts.unpretty.as_ref().map(|a| {
2080-
// extended with unstable pretty-print variants
2081-
parse_pretty_inner(efmt, &a, true)
2082-
})
2011+
fn parse_pretty(debugging_opts: &DebuggingOptions, efmt: ErrorOutputType) -> Option<PpMode> {
2012+
use PpMode::*;
2013+
2014+
let first = match debugging_opts.unpretty.as_deref()? {
2015+
"normal" => Source(PpSourceMode::Normal),
2016+
"identified" => Source(PpSourceMode::Identified),
2017+
"everybody_loops" => Source(PpSourceMode::EveryBodyLoops),
2018+
"expanded" => Source(PpSourceMode::Expanded),
2019+
"expanded,identified" => Source(PpSourceMode::ExpandedIdentified),
2020+
"expanded,hygiene" => Source(PpSourceMode::ExpandedHygiene),
2021+
"ast-tree" => AstTree(PpAstTreeMode::Normal),
2022+
"ast-tree,expanded" => AstTree(PpAstTreeMode::Expanded),
2023+
"hir" => Hir(PpHirMode::Normal),
2024+
"hir,identified" => Hir(PpHirMode::Identified),
2025+
"hir,typed" => Hir(PpHirMode::Typed),
2026+
"hir-tree" => HirTree,
2027+
"thir-tree" => ThirTree,
2028+
"mir" => Mir,
2029+
"mir-cfg" => MirCFG,
2030+
name => early_error(
2031+
efmt,
2032+
&format!(
2033+
"argument to `unpretty` must be one of `normal`, \
2034+
`expanded`, `identified`, `expanded,identified`, \
2035+
`expanded,hygiene`, `everybody_loops`, \
2036+
`ast-tree`, `ast-tree,expanded`, `hir`, `hir,identified`, \
2037+
`hir,typed`, `hir-tree`, `mir` or `mir-cfg`; got {}",
2038+
name
2039+
),
2040+
),
2041+
};
2042+
tracing::debug!("got unpretty option: {:?}", first);
2043+
Some(first)
20832044
}
20842045

20852046
pub fn make_crate_type_option() -> RustcOptGroup {
@@ -2187,17 +2148,17 @@ impl fmt::Display for CrateType {
21872148

21882149
#[derive(Copy, Clone, PartialEq, Debug)]
21892150
pub enum PpSourceMode {
2190-
/// `--pretty=normal`
2151+
/// `-Zunpretty=normal`
21912152
Normal,
21922153
/// `-Zunpretty=everybody_loops`
21932154
EveryBodyLoops,
2194-
/// `--pretty=expanded`
2155+
/// `-Zunpretty=expanded`
21952156
Expanded,
2196-
/// `--pretty=identified`
2157+
/// `-Zunpretty=identified`
21972158
Identified,
2198-
/// `--pretty=expanded,identified`
2159+
/// `-Zunpretty=expanded,identified`
21992160
ExpandedIdentified,
2200-
/// `--pretty=expanded,hygiene`
2161+
/// `-Zunpretty=expanded,hygiene`
22012162
ExpandedHygiene,
22022163
}
22032164

@@ -2222,7 +2183,7 @@ pub enum PpHirMode {
22222183
#[derive(Copy, Clone, PartialEq, Debug)]
22232184
pub enum PpMode {
22242185
/// Options that print the source code, i.e.
2225-
/// `--pretty` and `-Zunpretty=everybody_loops`
2186+
/// `-Zunpretty=normal` and `-Zunpretty=everybody_loops`
22262187
Source(PpSourceMode),
22272188
AstTree(PpAstTreeMode),
22282189
/// Options that print the HIR, i.e. `-Zunpretty=hir`

compiler/rustc_session/src/options.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
11891189
"take the brakes off const evaluation. NOTE: this is unsound (default: no)"),
11901190
unpretty: Option<String> = (None, parse_unpretty, [UNTRACKED],
11911191
"present the input source, unstable (and less-pretty) variants;
1192-
valid types are any of the types for `--pretty`, as well as:
1192+
`normal`, `identified`,
11931193
`expanded`, `expanded,identified`,
11941194
`expanded,hygiene` (with internal representations),
11951195
`everybody_loops` (all function bodies replaced with `loop {}`),

src/test/pretty/block-comment-wchar.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This is meant as a test case for Issue 3961.
22
//
3-
// Test via: rustc --pretty normal src/test/pretty/block-comment-wchar.rs
3+
// Test via: rustc -Zunpretty normal src/test/pretty/block-comment-wchar.rs
44
// ignore-tidy-cr
55
// ignore-tidy-tab
66
// pp-exact:block-comment-wchar.pp

src/test/pretty/block-comment-wchar.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This is meant as a test case for Issue 3961.
22
//
3-
// Test via: rustc --pretty normal src/test/pretty/block-comment-wchar.rs
3+
// Test via: rustc -Zunpretty normal src/test/pretty/block-comment-wchar.rs
44
// ignore-tidy-cr
55
// ignore-tidy-tab
66
// pp-exact:block-comment-wchar.pp
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
-include ../tools.mk
22

33
all:
4-
$(RUSTC) -o $(TMPDIR)/input.expanded.rs -Z unstable-options \
5-
--pretty=expanded input.rs
4+
$(RUSTC) -o $(TMPDIR)/input.expanded.rs -Zunpretty=expanded input.rs
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-include ../tools.mk
22

33
all:
4-
$(RUSTC) -o $(TMPDIR)/input.out --pretty=normal -Z unstable-options input.rs
4+
$(RUSTC) -o $(TMPDIR)/input.out -Zunpretty=normal input.rs
55
diff -u $(TMPDIR)/input.out input.pp

src/tools/compiletest/src/header.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ pub struct TestProps {
306306
// a proc-macro and needs `#![crate_type = "proc-macro"]`. This ensures
307307
// that the aux file is compiled as a `proc-macro` and not as a `dylib`.
308308
pub no_prefer_dynamic: bool,
309-
// Run --pretty expanded when running pretty printing tests
309+
// Run -Zunpretty expanded when running pretty printing tests
310310
pub pretty_expanded: bool,
311311
// Which pretty mode are we testing with, default to 'normal'
312312
pub pretty_mode: String,

src/tools/compiletest/src/runtest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ impl<'test> TestCx<'test> {
599599
return;
600600
}
601601

602-
// additionally, run `--pretty expanded` and try to build it.
602+
// additionally, run `-Zunpretty=expanded` and try to build it.
603603
let proc_res = self.print_source(ReadFrom::Path, "expanded");
604604
if !proc_res.status.success() {
605605
self.fatal_proc_rec("pretty-printing (expanded) failed", &proc_res);

0 commit comments

Comments
 (0)