Skip to content

Commit 7d6bf86

Browse files
committed
Auto merge of #83491 - jyn514:remove-pretty, r=pnkfelix
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. Closes #36473.
2 parents c51607e + 23bbd65 commit 7d6bf86

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
@@ -1148,15 +1148,6 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
11481148
never = never colorize output",
11491149
"auto|always|never",
11501150
),
1151-
opt::opt(
1152-
"",
1153-
"pretty",
1154-
"Pretty-print the input instead of compiling;
1155-
valid types are: `normal` (un-annotated source),
1156-
`expanded` (crates expanded), or
1157-
`expanded,identified` (fully parenthesized, AST nodes with IDs).",
1158-
"TYPE",
1159-
),
11601151
opt::multi_s(
11611152
"",
11621153
"remap-path-prefix",
@@ -2073,7 +2064,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
20732064

20742065
let remap_path_prefix = parse_remap_path_prefix(matches, error_format);
20752066

2076-
let pretty = parse_pretty(matches, &debugging_opts, error_format);
2067+
let pretty = parse_pretty(&debugging_opts, error_format);
20772068

20782069
if !debugging_opts.unstable_options
20792070
&& !target_triple.triple().contains("apple")
@@ -2150,69 +2141,39 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
21502141
}
21512142
}
21522143

2153-
fn parse_pretty(
2154-
matches: &getopts::Matches,
2155-
debugging_opts: &DebuggingOptions,
2156-
efmt: ErrorOutputType,
2157-
) -> Option<PpMode> {
2158-
fn parse_pretty_inner(efmt: ErrorOutputType, name: &str, extended: bool) -> PpMode {
2159-
use PpMode::*;
2160-
let first = match (name, extended) {
2161-
("normal", _) => Source(PpSourceMode::Normal),
2162-
("identified", _) => Source(PpSourceMode::Identified),
2163-
("everybody_loops", true) => Source(PpSourceMode::EveryBodyLoops),
2164-
("expanded", _) => Source(PpSourceMode::Expanded),
2165-
("expanded,identified", _) => Source(PpSourceMode::ExpandedIdentified),
2166-
("expanded,hygiene", _) => Source(PpSourceMode::ExpandedHygiene),
2167-
("ast-tree", true) => AstTree(PpAstTreeMode::Normal),
2168-
("ast-tree,expanded", true) => AstTree(PpAstTreeMode::Expanded),
2169-
("hir", true) => Hir(PpHirMode::Normal),
2170-
("hir,identified", true) => Hir(PpHirMode::Identified),
2171-
("hir,typed", true) => Hir(PpHirMode::Typed),
2172-
("hir-tree", true) => HirTree,
2173-
("thir-tree", true) => ThirTree,
2174-
("mir", true) => Mir,
2175-
("mir-cfg", true) => MirCFG,
2176-
_ => {
2177-
if extended {
2178-
early_error(
2179-
efmt,
2180-
&format!(
2181-
"argument to `unpretty` must be one of `normal`, \
2182-
`expanded`, `identified`, `expanded,identified`, \
2183-
`expanded,hygiene`, `everybody_loops`, \
2184-
`ast-tree`, `ast-tree,expanded`, `hir`, `hir,identified`, \
2185-
`hir,typed`, `hir-tree`, `mir` or `mir-cfg`; got {}",
2186-
name
2187-
),
2188-
);
2189-
} else {
2190-
early_error(
2191-
efmt,
2192-
&format!(
2193-
"argument to `pretty` must be one of `normal`, \
2194-
`expanded`, `identified`, or `expanded,identified`; got {}",
2195-
name
2196-
),
2197-
);
2198-
}
2199-
}
2200-
};
2201-
tracing::debug!("got unpretty option: {:?}", first);
2202-
first
2203-
}
2204-
2205-
if debugging_opts.unstable_options {
2206-
if let Some(a) = matches.opt_default("pretty", "normal") {
2207-
// stable pretty-print variants only
2208-
return Some(parse_pretty_inner(efmt, &a, false));
2209-
}
2210-
}
2211-
2212-
debugging_opts.unpretty.as_ref().map(|a| {
2213-
// extended with unstable pretty-print variants
2214-
parse_pretty_inner(efmt, &a, true)
2215-
})
2144+
fn parse_pretty(debugging_opts: &DebuggingOptions, efmt: ErrorOutputType) -> Option<PpMode> {
2145+
use PpMode::*;
2146+
2147+
let first = match debugging_opts.unpretty.as_deref()? {
2148+
"normal" => Source(PpSourceMode::Normal),
2149+
"identified" => Source(PpSourceMode::Identified),
2150+
"everybody_loops" => Source(PpSourceMode::EveryBodyLoops),
2151+
"expanded" => Source(PpSourceMode::Expanded),
2152+
"expanded,identified" => Source(PpSourceMode::ExpandedIdentified),
2153+
"expanded,hygiene" => Source(PpSourceMode::ExpandedHygiene),
2154+
"ast-tree" => AstTree(PpAstTreeMode::Normal),
2155+
"ast-tree,expanded" => AstTree(PpAstTreeMode::Expanded),
2156+
"hir" => Hir(PpHirMode::Normal),
2157+
"hir,identified" => Hir(PpHirMode::Identified),
2158+
"hir,typed" => Hir(PpHirMode::Typed),
2159+
"hir-tree" => HirTree,
2160+
"thir-tree" => ThirTree,
2161+
"mir" => Mir,
2162+
"mir-cfg" => MirCFG,
2163+
name => early_error(
2164+
efmt,
2165+
&format!(
2166+
"argument to `unpretty` must be one of `normal`, \
2167+
`expanded`, `identified`, `expanded,identified`, \
2168+
`expanded,hygiene`, `everybody_loops`, \
2169+
`ast-tree`, `ast-tree,expanded`, `hir`, `hir,identified`, \
2170+
`hir,typed`, `hir-tree`, `mir` or `mir-cfg`; got {}",
2171+
name
2172+
),
2173+
),
2174+
};
2175+
tracing::debug!("got unpretty option: {:?}", first);
2176+
Some(first)
22162177
}
22172178

22182179
pub fn make_crate_type_option() -> RustcOptGroup {
@@ -2320,17 +2281,17 @@ impl fmt::Display for CrateType {
23202281

23212282
#[derive(Copy, Clone, PartialEq, Debug)]
23222283
pub enum PpSourceMode {
2323-
/// `--pretty=normal`
2284+
/// `-Zunpretty=normal`
23242285
Normal,
23252286
/// `-Zunpretty=everybody_loops`
23262287
EveryBodyLoops,
2327-
/// `--pretty=expanded`
2288+
/// `-Zunpretty=expanded`
23282289
Expanded,
2329-
/// `--pretty=identified`
2290+
/// `-Zunpretty=identified`
23302291
Identified,
2331-
/// `--pretty=expanded,identified`
2292+
/// `-Zunpretty=expanded,identified`
23322293
ExpandedIdentified,
2333-
/// `--pretty=expanded,hygiene`
2294+
/// `-Zunpretty=expanded,hygiene`
23342295
ExpandedHygiene,
23352296
}
23362297

@@ -2355,7 +2316,7 @@ pub enum PpHirMode {
23552316
#[derive(Copy, Clone, PartialEq, Debug)]
23562317
pub enum PpMode {
23572318
/// Options that print the source code, i.e.
2358-
/// `--pretty` and `-Zunpretty=everybody_loops`
2319+
/// `-Zunpretty=normal` and `-Zunpretty=everybody_loops`
23592320
Source(PpSourceMode),
23602321
AstTree(PpAstTreeMode),
23612322
/// 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
@@ -1308,7 +1308,7 @@ options! {
13081308
"take the brakes off const evaluation. NOTE: this is unsound (default: no)"),
13091309
unpretty: Option<String> = (None, parse_unpretty, [UNTRACKED],
13101310
"present the input source, unstable (and less-pretty) variants;
1311-
valid types are any of the types for `--pretty`, as well as:
1311+
`normal`, `identified`,
13121312
`expanded`, `expanded,identified`,
13131313
`expanded,hygiene` (with internal representations),
13141314
`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
@@ -98,7 +98,7 @@ pub struct TestProps {
9898
// a proc-macro and needs `#![crate_type = "proc-macro"]`. This ensures
9999
// that the aux file is compiled as a `proc-macro` and not as a `dylib`.
100100
pub no_prefer_dynamic: bool,
101-
// Run --pretty expanded when running pretty printing tests
101+
// Run -Zunpretty expanded when running pretty printing tests
102102
pub pretty_expanded: bool,
103103
// Which pretty mode are we testing with, default to 'normal'
104104
pub pretty_mode: String,

src/tools/compiletest/src/runtest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ impl<'test> TestCx<'test> {
619619
return;
620620
}
621621

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

0 commit comments

Comments
 (0)