Auto merge of #116619 - nnethercote:rustc_driver_impl, r=compiler-errors
Streamline `rustc_driver_impl` pretty-printing. This PR simplifies a lot of unnecessary structure in `rustc_driver_impl/src/pretty.rs`. It removes some traits and functions, simplifies some structs, renames some things for increased consistency, and eliminates some boilerplate code. Overall it cuts more than 150 lines of code. r? `@compiler-errors`
This commit is contained in:
commit
2763ca50da
3 changed files with 154 additions and 309 deletions
|
@ -2925,8 +2925,8 @@ fn parse_pretty(handler: &EarlyErrorHandler, unstable_opts: &UnstableOptions) ->
|
|||
"expanded" => Source(PpSourceMode::Expanded),
|
||||
"expanded,identified" => Source(PpSourceMode::ExpandedIdentified),
|
||||
"expanded,hygiene" => Source(PpSourceMode::ExpandedHygiene),
|
||||
"ast-tree" => AstTree(PpAstTreeMode::Normal),
|
||||
"ast-tree,expanded" => AstTree(PpAstTreeMode::Expanded),
|
||||
"ast-tree" => AstTree,
|
||||
"ast-tree,expanded" => AstTreeExpanded,
|
||||
"hir" => Hir(PpHirMode::Normal),
|
||||
"hir,identified" => Hir(PpHirMode::Identified),
|
||||
"hir,typed" => Hir(PpHirMode::Typed),
|
||||
|
@ -3083,14 +3083,6 @@ pub enum PpSourceMode {
|
|||
ExpandedHygiene,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||
pub enum PpAstTreeMode {
|
||||
/// `-Zunpretty=ast`
|
||||
Normal,
|
||||
/// `-Zunpretty=ast,expanded`
|
||||
Expanded,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||
pub enum PpHirMode {
|
||||
/// `-Zunpretty=hir`
|
||||
|
@ -3106,7 +3098,10 @@ pub enum PpMode {
|
|||
/// Options that print the source code, i.e.
|
||||
/// `-Zunpretty=normal` and `-Zunpretty=expanded`
|
||||
Source(PpSourceMode),
|
||||
AstTree(PpAstTreeMode),
|
||||
/// `-Zunpretty=ast-tree`
|
||||
AstTree,
|
||||
/// `-Zunpretty=ast-tree,expanded`
|
||||
AstTreeExpanded,
|
||||
/// Options that print the HIR, i.e. `-Zunpretty=hir`
|
||||
Hir(PpHirMode),
|
||||
/// `-Zunpretty=hir-tree`
|
||||
|
@ -3126,10 +3121,10 @@ impl PpMode {
|
|||
use PpMode::*;
|
||||
use PpSourceMode::*;
|
||||
match *self {
|
||||
Source(Normal | Identified) | AstTree(PpAstTreeMode::Normal) => false,
|
||||
Source(Normal | Identified) | AstTree => false,
|
||||
|
||||
Source(Expanded | ExpandedIdentified | ExpandedHygiene)
|
||||
| AstTree(PpAstTreeMode::Expanded)
|
||||
| AstTreeExpanded
|
||||
| Hir(_)
|
||||
| HirTree
|
||||
| ThirTree
|
||||
|
@ -3141,7 +3136,7 @@ impl PpMode {
|
|||
pub fn needs_hir(&self) -> bool {
|
||||
use PpMode::*;
|
||||
match *self {
|
||||
Source(_) | AstTree(_) => false,
|
||||
Source(_) | AstTree | AstTreeExpanded => false,
|
||||
|
||||
Hir(_) | HirTree | ThirTree | ThirFlat | Mir | MirCFG => true,
|
||||
}
|
||||
|
@ -3149,7 +3144,7 @@ impl PpMode {
|
|||
|
||||
pub fn needs_analysis(&self) -> bool {
|
||||
use PpMode::*;
|
||||
matches!(*self, Mir | MirCFG | ThirTree | ThirFlat)
|
||||
matches!(*self, Hir(PpHirMode::Typed) | Mir | MirCFG | ThirTree | ThirFlat)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue