@@ -1125,15 +1125,6 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
1125
1125
never = never colorize output" ,
1126
1126
"auto|always|never" ,
1127
1127
) ,
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
- ) ,
1137
1128
opt:: multi_s(
1138
1129
"" ,
1139
1130
"remap-path-prefix" ,
@@ -1969,7 +1960,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
1969
1960
1970
1961
let remap_path_prefix = parse_remap_path_prefix ( matches, error_format) ;
1971
1962
1972
- let pretty = parse_pretty ( matches , & debugging_opts, error_format) ;
1963
+ let pretty = parse_pretty ( & debugging_opts, error_format) ;
1973
1964
1974
1965
if !debugging_opts. unstable_options
1975
1966
&& !target_triple. triple ( ) . contains ( "apple" )
@@ -2017,69 +2008,39 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
2017
2008
}
2018
2009
}
2019
2010
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)
2083
2044
}
2084
2045
2085
2046
pub fn make_crate_type_option ( ) -> RustcOptGroup {
@@ -2187,17 +2148,17 @@ impl fmt::Display for CrateType {
2187
2148
2188
2149
#[ derive( Copy , Clone , PartialEq , Debug ) ]
2189
2150
pub enum PpSourceMode {
2190
- /// `--pretty =normal`
2151
+ /// `-Zunpretty =normal`
2191
2152
Normal ,
2192
2153
/// `-Zunpretty=everybody_loops`
2193
2154
EveryBodyLoops ,
2194
- /// `--pretty =expanded`
2155
+ /// `-Zunpretty =expanded`
2195
2156
Expanded ,
2196
- /// `--pretty =identified`
2157
+ /// `-Zunpretty =identified`
2197
2158
Identified ,
2198
- /// `--pretty =expanded,identified`
2159
+ /// `-Zunpretty =expanded,identified`
2199
2160
ExpandedIdentified ,
2200
- /// `--pretty =expanded,hygiene`
2161
+ /// `-Zunpretty =expanded,hygiene`
2201
2162
ExpandedHygiene ,
2202
2163
}
2203
2164
@@ -2222,7 +2183,7 @@ pub enum PpHirMode {
2222
2183
#[ derive( Copy , Clone , PartialEq , Debug ) ]
2223
2184
pub enum PpMode {
2224
2185
/// Options that print the source code, i.e.
2225
- /// `--pretty ` and `-Zunpretty=everybody_loops`
2186
+ /// `-Zunpretty=normal ` and `-Zunpretty=everybody_loops`
2226
2187
Source ( PpSourceMode ) ,
2227
2188
AstTree ( PpAstTreeMode ) ,
2228
2189
/// Options that print the HIR, i.e. `-Zunpretty=hir`
0 commit comments