Skip to content

Commit

Permalink
Auto merge of rust-lang#83491 - jyn514:remove-pretty, r=pnkfelix
Browse files Browse the repository at this point in the history
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 rust-lang#36473.
  • Loading branch information
bors committed Jul 27, 2021
2 parents c51607e + 23bbd65 commit 7d6bf86
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 87 deletions.
119 changes: 40 additions & 79 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1148,15 +1148,6 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
never = never colorize output",
"auto|always|never",
),
opt::opt(
"",
"pretty",
"Pretty-print the input instead of compiling;
valid types are: `normal` (un-annotated source),
`expanded` (crates expanded), or
`expanded,identified` (fully parenthesized, AST nodes with IDs).",
"TYPE",
),
opt::multi_s(
"",
"remap-path-prefix",
Expand Down Expand Up @@ -2073,7 +2064,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {

let remap_path_prefix = parse_remap_path_prefix(matches, error_format);

let pretty = parse_pretty(matches, &debugging_opts, error_format);
let pretty = parse_pretty(&debugging_opts, error_format);

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

fn parse_pretty(
matches: &getopts::Matches,
debugging_opts: &DebuggingOptions,
efmt: ErrorOutputType,
) -> Option<PpMode> {
fn parse_pretty_inner(efmt: ErrorOutputType, name: &str, extended: bool) -> PpMode {
use PpMode::*;
let first = match (name, extended) {
("normal", _) => Source(PpSourceMode::Normal),
("identified", _) => Source(PpSourceMode::Identified),
("everybody_loops", true) => Source(PpSourceMode::EveryBodyLoops),
("expanded", _) => Source(PpSourceMode::Expanded),
("expanded,identified", _) => Source(PpSourceMode::ExpandedIdentified),
("expanded,hygiene", _) => Source(PpSourceMode::ExpandedHygiene),
("ast-tree", true) => AstTree(PpAstTreeMode::Normal),
("ast-tree,expanded", true) => AstTree(PpAstTreeMode::Expanded),
("hir", true) => Hir(PpHirMode::Normal),
("hir,identified", true) => Hir(PpHirMode::Identified),
("hir,typed", true) => Hir(PpHirMode::Typed),
("hir-tree", true) => HirTree,
("thir-tree", true) => ThirTree,
("mir", true) => Mir,
("mir-cfg", true) => MirCFG,
_ => {
if extended {
early_error(
efmt,
&format!(
"argument to `unpretty` must be one of `normal`, \
`expanded`, `identified`, `expanded,identified`, \
`expanded,hygiene`, `everybody_loops`, \
`ast-tree`, `ast-tree,expanded`, `hir`, `hir,identified`, \
`hir,typed`, `hir-tree`, `mir` or `mir-cfg`; got {}",
name
),
);
} else {
early_error(
efmt,
&format!(
"argument to `pretty` must be one of `normal`, \
`expanded`, `identified`, or `expanded,identified`; got {}",
name
),
);
}
}
};
tracing::debug!("got unpretty option: {:?}", first);
first
}

if debugging_opts.unstable_options {
if let Some(a) = matches.opt_default("pretty", "normal") {
// stable pretty-print variants only
return Some(parse_pretty_inner(efmt, &a, false));
}
}

debugging_opts.unpretty.as_ref().map(|a| {
// extended with unstable pretty-print variants
parse_pretty_inner(efmt, &a, true)
})
fn parse_pretty(debugging_opts: &DebuggingOptions, efmt: ErrorOutputType) -> Option<PpMode> {
use PpMode::*;

let first = match debugging_opts.unpretty.as_deref()? {
"normal" => Source(PpSourceMode::Normal),
"identified" => Source(PpSourceMode::Identified),
"everybody_loops" => Source(PpSourceMode::EveryBodyLoops),
"expanded" => Source(PpSourceMode::Expanded),
"expanded,identified" => Source(PpSourceMode::ExpandedIdentified),
"expanded,hygiene" => Source(PpSourceMode::ExpandedHygiene),
"ast-tree" => AstTree(PpAstTreeMode::Normal),
"ast-tree,expanded" => AstTree(PpAstTreeMode::Expanded),
"hir" => Hir(PpHirMode::Normal),
"hir,identified" => Hir(PpHirMode::Identified),
"hir,typed" => Hir(PpHirMode::Typed),
"hir-tree" => HirTree,
"thir-tree" => ThirTree,
"mir" => Mir,
"mir-cfg" => MirCFG,
name => early_error(
efmt,
&format!(
"argument to `unpretty` must be one of `normal`, \
`expanded`, `identified`, `expanded,identified`, \
`expanded,hygiene`, `everybody_loops`, \
`ast-tree`, `ast-tree,expanded`, `hir`, `hir,identified`, \
`hir,typed`, `hir-tree`, `mir` or `mir-cfg`; got {}",
name
),
),
};
tracing::debug!("got unpretty option: {:?}", first);
Some(first)
}

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

#[derive(Copy, Clone, PartialEq, Debug)]
pub enum PpSourceMode {
/// `--pretty=normal`
/// `-Zunpretty=normal`
Normal,
/// `-Zunpretty=everybody_loops`
EveryBodyLoops,
/// `--pretty=expanded`
/// `-Zunpretty=expanded`
Expanded,
/// `--pretty=identified`
/// `-Zunpretty=identified`
Identified,
/// `--pretty=expanded,identified`
/// `-Zunpretty=expanded,identified`
ExpandedIdentified,
/// `--pretty=expanded,hygiene`
/// `-Zunpretty=expanded,hygiene`
ExpandedHygiene,
}

Expand All @@ -2355,7 +2316,7 @@ pub enum PpHirMode {
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum PpMode {
/// Options that print the source code, i.e.
/// `--pretty` and `-Zunpretty=everybody_loops`
/// `-Zunpretty=normal` and `-Zunpretty=everybody_loops`
Source(PpSourceMode),
AstTree(PpAstTreeMode),
/// Options that print the HIR, i.e. `-Zunpretty=hir`
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1308,7 +1308,7 @@ options! {
"take the brakes off const evaluation. NOTE: this is unsound (default: no)"),
unpretty: Option<String> = (None, parse_unpretty, [UNTRACKED],
"present the input source, unstable (and less-pretty) variants;
valid types are any of the types for `--pretty`, as well as:
`normal`, `identified`,
`expanded`, `expanded,identified`,
`expanded,hygiene` (with internal representations),
`everybody_loops` (all function bodies replaced with `loop {}`),
Expand Down
2 changes: 1 addition & 1 deletion src/test/pretty/block-comment-wchar.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This is meant as a test case for Issue 3961.
//
// Test via: rustc --pretty normal src/test/pretty/block-comment-wchar.rs
// Test via: rustc -Zunpretty normal src/test/pretty/block-comment-wchar.rs
// ignore-tidy-cr
// ignore-tidy-tab
// pp-exact:block-comment-wchar.pp
Expand Down
2 changes: 1 addition & 1 deletion src/test/pretty/block-comment-wchar.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This is meant as a test case for Issue 3961.
//
// Test via: rustc --pretty normal src/test/pretty/block-comment-wchar.rs
// Test via: rustc -Zunpretty normal src/test/pretty/block-comment-wchar.rs
// ignore-tidy-cr
// ignore-tidy-tab
// pp-exact:block-comment-wchar.pp
Expand Down
3 changes: 1 addition & 2 deletions src/test/run-make-fulldeps/pretty-expanded/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
-include ../tools.mk

all:
$(RUSTC) -o $(TMPDIR)/input.expanded.rs -Z unstable-options \
--pretty=expanded input.rs
$(RUSTC) -o $(TMPDIR)/input.expanded.rs -Zunpretty=expanded input.rs
2 changes: 1 addition & 1 deletion src/test/run-make-fulldeps/pretty-print-to-file/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-include ../tools.mk

all:
$(RUSTC) -o $(TMPDIR)/input.out --pretty=normal -Z unstable-options input.rs
$(RUSTC) -o $(TMPDIR)/input.out -Zunpretty=normal input.rs
diff -u $(TMPDIR)/input.out input.pp
2 changes: 1 addition & 1 deletion src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub struct TestProps {
// a proc-macro and needs `#![crate_type = "proc-macro"]`. This ensures
// that the aux file is compiled as a `proc-macro` and not as a `dylib`.
pub no_prefer_dynamic: bool,
// Run --pretty expanded when running pretty printing tests
// Run -Zunpretty expanded when running pretty printing tests
pub pretty_expanded: bool,
// Which pretty mode are we testing with, default to 'normal'
pub pretty_mode: String,
Expand Down
2 changes: 1 addition & 1 deletion src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ impl<'test> TestCx<'test> {
return;
}

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

0 comments on commit 7d6bf86

Please sign in to comment.