@@ -2068,40 +2068,21 @@ fn parse_pretty(
20682068 debugging_opts : & DebuggingOptions ,
20692069 efmt : ErrorOutputType ,
20702070) -> Option < PpMode > {
2071- let pretty = if debugging_opts. unstable_options {
2072- matches. opt_default ( "pretty" , "normal" ) . map ( |a| {
2073- // stable pretty-print variants only
2074- parse_pretty_inner ( efmt, & a, false )
2075- } )
2076- } else {
2077- None
2078- } ;
2079-
2080- return if pretty. is_none ( ) {
2081- debugging_opts. unpretty . as_ref ( ) . map ( |a| {
2082- // extended with unstable pretty-print variants
2083- parse_pretty_inner ( efmt, & a, true )
2084- } )
2085- } else {
2086- pretty
2087- } ;
2088-
20892071 fn parse_pretty_inner ( efmt : ErrorOutputType , name : & str , extended : bool ) -> PpMode {
20902072 use PpMode :: * ;
2091- use PpSourceMode :: * ;
20922073 let first = match ( name, extended) {
2093- ( "normal" , _) => PpmSource ( PpmNormal ) ,
2094- ( "identified" , _) => PpmSource ( PpmIdentified ) ,
2095- ( "everybody_loops" , true ) => PpmSource ( PpmEveryBodyLoops ) ,
2096- ( "expanded" , _) => PpmSource ( PpmExpanded ) ,
2097- ( "expanded,identified" , _) => PpmSource ( PpmExpandedIdentified ) ,
2098- ( "expanded,hygiene" , _) => PpmSource ( PpmExpandedHygiene ) ,
2099- ( "hir" , true ) => PpmHir ( PpmNormal ) ,
2100- ( "hir,identified" , true ) => PpmHir ( PpmIdentified ) ,
2101- ( "hir,typed" , true ) => PpmHir ( PpmTyped ) ,
2102- ( "hir-tree" , true ) => PpmHirTree ( PpmNormal ) ,
2103- ( "mir" , true ) => PpmMir ,
2104- ( "mir-cfg" , true ) => PpmMirCFG ,
2074+ ( "normal" , _) => Source ( PpSourceMode :: Normal ) ,
2075+ ( "identified" , _) => Source ( PpSourceMode :: Identified ) ,
2076+ ( "everybody_loops" , true ) => Source ( PpSourceMode :: EveryBodyLoops ) ,
2077+ ( "expanded" , _) => Source ( PpSourceMode :: Expanded ) ,
2078+ ( "expanded,identified" , _) => Source ( PpSourceMode :: ExpandedIdentified ) ,
2079+ ( "expanded,hygiene" , _) => Source ( PpSourceMode :: ExpandedHygiene ) ,
2080+ ( "hir" , true ) => Hir ( PpHirMode :: Normal ) ,
2081+ ( "hir,identified" , true ) => Hir ( PpHirMode :: Identified ) ,
2082+ ( "hir,typed" , true ) => Hir ( PpHirMode :: Typed ) ,
2083+ ( "hir-tree" , true ) => HirTree ,
2084+ ( "mir" , true ) => Mir ,
2085+ ( "mir-cfg" , true ) => MirCFG ,
21052086 _ => {
21062087 if extended {
21072088 early_error (
@@ -2130,6 +2111,18 @@ fn parse_pretty(
21302111 tracing:: debug!( "got unpretty option: {:?}" , first) ;
21312112 first
21322113 }
2114+
2115+ if debugging_opts. unstable_options {
2116+ if let Some ( a) = matches. opt_default ( "pretty" , "normal" ) {
2117+ // stable pretty-print variants only
2118+ return Some ( parse_pretty_inner ( efmt, & a, false ) ) ;
2119+ }
2120+ }
2121+
2122+ debugging_opts. unpretty . as_ref ( ) . map ( |a| {
2123+ // extended with unstable pretty-print variants
2124+ parse_pretty_inner ( efmt, & a, true )
2125+ } )
21332126}
21342127
21352128pub fn make_crate_type_option ( ) -> RustcOptGroup {
@@ -2237,45 +2230,63 @@ impl fmt::Display for CrateType {
22372230
22382231#[ derive( Copy , Clone , PartialEq , Debug ) ]
22392232pub enum PpSourceMode {
2240- PpmNormal ,
2241- PpmEveryBodyLoops ,
2242- PpmExpanded ,
2243- PpmIdentified ,
2244- PpmExpandedIdentified ,
2245- PpmExpandedHygiene ,
2246- PpmTyped ,
2233+ /// `--pretty=normal`
2234+ Normal ,
2235+ /// `-Zunpretty=everybody_loops`
2236+ EveryBodyLoops ,
2237+ /// `--pretty=expanded`
2238+ Expanded ,
2239+ /// `--pretty=identified`
2240+ Identified ,
2241+ /// `--pretty=expanded,identified`
2242+ ExpandedIdentified ,
2243+ /// `--pretty=expanded,hygiene`
2244+ ExpandedHygiene ,
2245+ }
2246+
2247+ #[ derive( Copy , Clone , PartialEq , Debug ) ]
2248+ pub enum PpHirMode {
2249+ /// `-Zunpretty=hir`
2250+ Normal ,
2251+ /// `-Zunpretty=hir,identified`
2252+ Identified ,
2253+ /// `-Zunpretty=hir,typed`
2254+ Typed ,
22472255}
22482256
22492257#[ derive( Copy , Clone , PartialEq , Debug ) ]
22502258pub enum PpMode {
2251- PpmSource ( PpSourceMode ) ,
2252- PpmHir ( PpSourceMode ) ,
2253- PpmHirTree ( PpSourceMode ) ,
2254- PpmMir ,
2255- PpmMirCFG ,
2259+ /// Options that print the source code, i.e.
2260+ /// `--pretty` and `-Zunpretty=everybody_loops`
2261+ Source ( PpSourceMode ) ,
2262+ /// Options that print the HIR, i.e. `-Zunpretty=hir`
2263+ Hir ( PpHirMode ) ,
2264+ /// `-Zunpretty=hir-tree`
2265+ HirTree ,
2266+ /// `-Zunpretty=mir`
2267+ Mir ,
2268+ /// `-Zunpretty=mir-cfg`
2269+ MirCFG ,
22562270}
22572271
22582272impl PpMode {
22592273 pub fn needs_ast_map ( & self ) -> bool {
22602274 use PpMode :: * ;
22612275 use PpSourceMode :: * ;
22622276 match * self {
2263- PpmSource ( PpmNormal | PpmIdentified ) => false ,
2277+ Source ( Normal | Identified ) => false ,
22642278
2265- PpmSource (
2266- PpmExpanded | PpmEveryBodyLoops | PpmExpandedIdentified | PpmExpandedHygiene ,
2267- )
2268- | PpmHir ( _)
2269- | PpmHirTree ( _)
2270- | PpmMir
2271- | PpmMirCFG => true ,
2272- PpmSource ( PpmTyped ) => panic ! ( "invalid state" ) ,
2279+ Source ( Expanded | EveryBodyLoops | ExpandedIdentified | ExpandedHygiene )
2280+ | Hir ( _)
2281+ | HirTree
2282+ | Mir
2283+ | MirCFG => true ,
22732284 }
22742285 }
22752286
22762287 pub fn needs_analysis ( & self ) -> bool {
22772288 use PpMode :: * ;
2278- matches ! ( * self , PpmMir | PpmMirCFG )
2289+ matches ! ( * self , Mir | MirCFG )
22792290 }
22802291}
22812292
0 commit comments