@@ -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
22182179pub fn make_crate_type_option ( ) -> RustcOptGroup {
@@ -2320,17 +2281,17 @@ impl fmt::Display for CrateType {
23202281
23212282#[ derive( Copy , Clone , PartialEq , Debug ) ]
23222283pub 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 ) ]
23562317pub 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`
0 commit comments