Skip to content

Commit d05efee

Browse files
committed
Remove PpAstTreeMode.
It's simpler to distinguish the two AST modes directly in `PpMode`.
1 parent 31ec630 commit d05efee

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
@@ -2925,8 +2925,8 @@ fn parse_pretty(handler: &EarlyErrorHandler, unstable_opts: &UnstableOptions) ->
29252925
"expanded" => Source(PpSourceMode::Expanded),
29262926
"expanded,identified" => Source(PpSourceMode::ExpandedIdentified),
29272927
"expanded,hygiene" => Source(PpSourceMode::ExpandedHygiene),
2928-
"ast-tree" => AstTree(PpAstTreeMode::Normal),
2929-
"ast-tree,expanded" => AstTree(PpAstTreeMode::Expanded),
2928+
"ast-tree" => AstTree,
2929+
"ast-tree,expanded" => AstTreeExpanded,
29302930
"hir" => Hir(PpHirMode::Normal),
29312931
"hir,identified" => Hir(PpHirMode::Identified),
29322932
"hir,typed" => Hir(PpHirMode::Typed),
@@ -3083,14 +3083,6 @@ pub enum PpSourceMode {
30833083
ExpandedHygiene,
30843084
}
30853085

3086-
#[derive(Copy, Clone, PartialEq, Debug)]
3087-
pub enum PpAstTreeMode {
3088-
/// `-Zunpretty=ast`
3089-
Normal,
3090-
/// `-Zunpretty=ast,expanded`
3091-
Expanded,
3092-
}
3093-
30943086
#[derive(Copy, Clone, PartialEq, Debug)]
30953087
pub enum PpHirMode {
30963088
/// `-Zunpretty=hir`
@@ -3106,7 +3098,10 @@ pub enum PpMode {
31063098
/// Options that print the source code, i.e.
31073099
/// `-Zunpretty=normal` and `-Zunpretty=expanded`
31083100
Source(PpSourceMode),
3109-
AstTree(PpAstTreeMode),
3101+
/// `-Zunpretty=ast-tree`
3102+
AstTree,
3103+
/// `-Zunpretty=ast-tree,expanded`
3104+
AstTreeExpanded,
31103105
/// Options that print the HIR, i.e. `-Zunpretty=hir`
31113106
Hir(PpHirMode),
31123107
/// `-Zunpretty=hir-tree`
@@ -3126,10 +3121,10 @@ impl PpMode {
31263121
use PpMode::*;
31273122
use PpSourceMode::*;
31283123
match *self {
3129-
Source(Normal | Identified) | AstTree(PpAstTreeMode::Normal) => false,
3124+
Source(Normal | Identified) | AstTree => false,
31303125

31313126
Source(Expanded | ExpandedIdentified | ExpandedHygiene)
3132-
| AstTree(PpAstTreeMode::Expanded)
3127+
| AstTreeExpanded
31333128
| Hir(_)
31343129
| HirTree
31353130
| ThirTree
@@ -3141,7 +3136,7 @@ impl PpMode {
31413136
pub fn needs_hir(&self) -> bool {
31423137
use PpMode::*;
31433138
match *self {
3144-
Source(_) | AstTree(_) => false,
3139+
Source(_) | AstTree | AstTreeExpanded => false,
31453140

31463141
Hir(_) | HirTree | ThirTree | ThirFlat | Mir | MirCFG => true,
31473142
}

0 commit comments

Comments
 (0)