Skip to content

Commit 4425f22

Browse files
committed
Remove PpAstTreeMode.
It's simpler to distinguish the two AST modes directly in `PpMode`.
1 parent 29d97c9 commit 4425f22

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

compiler/rustc_driver_impl/src/pretty.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_hir_pretty as pprust_hir;
88
use rustc_middle::hir::map as hir_map;
99
use rustc_middle::mir::{write_mir_graphviz, write_mir_pretty};
1010
use rustc_middle::ty::{self, TyCtxt};
11-
use rustc_session::config::{OutFileName, PpAstTreeMode, PpHirMode, PpMode, PpSourceMode};
11+
use rustc_session::config::{OutFileName, PpHirMode, PpMode, PpSourceMode};
1212
use rustc_session::Session;
1313
use rustc_span::symbol::Ident;
1414
use rustc_span::FileName;
@@ -382,7 +382,7 @@ pub fn print_after_parsing(sess: &Session, krate: &ast::Crate, ppm: PpMode) {
382382
)
383383
})
384384
}
385-
AstTree(PpAstTreeMode::Normal) => {
385+
AstTree => {
386386
debug!("pretty printing AST tree");
387387
format!("{krate:#?}")
388388
}
@@ -420,7 +420,7 @@ pub fn print_after_hir_lowering<'tcx>(tcx: TyCtxt<'tcx>, ppm: PpMode) {
420420
})
421421
}
422422

423-
AstTree(PpAstTreeMode::Expanded) => {
423+
AstTreeExpanded => {
424424
debug!("pretty-printing expanded AST");
425425
format!("{:#?}", tcx.resolver_for_lowering(()).borrow().1)
426426
}

compiler/rustc_session/src/config.rs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2918,8 +2918,8 @@ fn parse_pretty(handler: &EarlyErrorHandler, unstable_opts: &UnstableOptions) ->
29182918
"expanded" => Source(PpSourceMode::Expanded),
29192919
"expanded,identified" => Source(PpSourceMode::ExpandedIdentified),
29202920
"expanded,hygiene" => Source(PpSourceMode::ExpandedHygiene),
2921-
"ast-tree" => AstTree(PpAstTreeMode::Normal),
2922-
"ast-tree,expanded" => AstTree(PpAstTreeMode::Expanded),
2921+
"ast-tree" => AstTree,
2922+
"ast-tree,expanded" => AstTreeExpanded,
29232923
"hir" => Hir(PpHirMode::Normal),
29242924
"hir,identified" => Hir(PpHirMode::Identified),
29252925
"hir,typed" => Hir(PpHirMode::Typed),
@@ -3076,14 +3076,6 @@ pub enum PpSourceMode {
30763076
ExpandedHygiene,
30773077
}
30783078

3079-
#[derive(Copy, Clone, PartialEq, Debug)]
3080-
pub enum PpAstTreeMode {
3081-
/// `-Zunpretty=ast`
3082-
Normal,
3083-
/// `-Zunpretty=ast,expanded`
3084-
Expanded,
3085-
}
3086-
30873079
#[derive(Copy, Clone, PartialEq, Debug)]
30883080
pub enum PpHirMode {
30893081
/// `-Zunpretty=hir`
@@ -3099,7 +3091,10 @@ pub enum PpMode {
30993091
/// Options that print the source code, i.e.
31003092
/// `-Zunpretty=normal` and `-Zunpretty=expanded`
31013093
Source(PpSourceMode),
3102-
AstTree(PpAstTreeMode),
3094+
/// `-Zunpretty=ast-tree`
3095+
AstTree,
3096+
/// `-Zunpretty=ast-tree,expanded`
3097+
AstTreeExpanded,
31033098
/// Options that print the HIR, i.e. `-Zunpretty=hir`
31043099
Hir(PpHirMode),
31053100
/// `-Zunpretty=hir-tree`
@@ -3119,10 +3114,10 @@ impl PpMode {
31193114
use PpMode::*;
31203115
use PpSourceMode::*;
31213116
match *self {
3122-
Source(Normal | Identified) | AstTree(PpAstTreeMode::Normal) => false,
3117+
Source(Normal | Identified) | AstTree => false,
31233118

31243119
Source(Expanded | ExpandedIdentified | ExpandedHygiene)
3125-
| AstTree(PpAstTreeMode::Expanded)
3120+
| AstTreeExpanded
31263121
| Hir(_)
31273122
| HirTree
31283123
| ThirTree
@@ -3134,7 +3129,7 @@ impl PpMode {
31343129
pub fn needs_hir(&self) -> bool {
31353130
use PpMode::*;
31363131
match *self {
3137-
Source(_) | AstTree(_) => false,
3132+
Source(_) | AstTree | AstTreeExpanded => false,
31383133

31393134
Hir(_) | HirTree | ThirTree | ThirFlat | Mir | MirCFG => true,
31403135
}

0 commit comments

Comments
 (0)