@@ -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
20852046pub fn make_crate_type_option ( ) -> RustcOptGroup {
@@ -2187,17 +2148,17 @@ impl fmt::Display for CrateType {
21872148
21882149#[ derive( Copy , Clone , PartialEq , Debug ) ]
21892150pub 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 ) ]
22232184pub 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`
0 commit comments