@@ -1148,15 +1148,6 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
1148
1148
never = never colorize output" ,
1149
1149
"auto|always|never" ,
1150
1150
) ,
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
- ) ,
1160
1151
opt:: multi_s(
1161
1152
"" ,
1162
1153
"remap-path-prefix" ,
@@ -2073,7 +2064,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
2073
2064
2074
2065
let remap_path_prefix = parse_remap_path_prefix ( matches, error_format) ;
2075
2066
2076
- let pretty = parse_pretty ( matches , & debugging_opts, error_format) ;
2067
+ let pretty = parse_pretty ( & debugging_opts, error_format) ;
2077
2068
2078
2069
if !debugging_opts. unstable_options
2079
2070
&& !target_triple. triple ( ) . contains ( "apple" )
@@ -2150,69 +2141,39 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
2150
2141
}
2151
2142
}
2152
2143
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)
2216
2177
}
2217
2178
2218
2179
pub fn make_crate_type_option ( ) -> RustcOptGroup {
@@ -2320,17 +2281,17 @@ impl fmt::Display for CrateType {
2320
2281
2321
2282
#[ derive( Copy , Clone , PartialEq , Debug ) ]
2322
2283
pub enum PpSourceMode {
2323
- /// `--pretty =normal`
2284
+ /// `-Zunpretty =normal`
2324
2285
Normal ,
2325
2286
/// `-Zunpretty=everybody_loops`
2326
2287
EveryBodyLoops ,
2327
- /// `--pretty =expanded`
2288
+ /// `-Zunpretty =expanded`
2328
2289
Expanded ,
2329
- /// `--pretty =identified`
2290
+ /// `-Zunpretty =identified`
2330
2291
Identified ,
2331
- /// `--pretty =expanded,identified`
2292
+ /// `-Zunpretty =expanded,identified`
2332
2293
ExpandedIdentified ,
2333
- /// `--pretty =expanded,hygiene`
2294
+ /// `-Zunpretty =expanded,hygiene`
2334
2295
ExpandedHygiene ,
2335
2296
}
2336
2297
@@ -2355,7 +2316,7 @@ pub enum PpHirMode {
2355
2316
#[ derive( Copy , Clone , PartialEq , Debug ) ]
2356
2317
pub enum PpMode {
2357
2318
/// Options that print the source code, i.e.
2358
- /// `--pretty ` and `-Zunpretty=everybody_loops`
2319
+ /// `-Zunpretty=normal ` and `-Zunpretty=everybody_loops`
2359
2320
Source ( PpSourceMode ) ,
2360
2321
AstTree ( PpAstTreeMode ) ,
2361
2322
/// Options that print the HIR, i.e. `-Zunpretty=hir`
0 commit comments