1
Fork 0

Add -Z unpretty flags for the AST

This commit is contained in:
LeSeulArtichaut 2021-02-19 22:40:28 +01:00
parent 939b14334d
commit 61114453ae
3 changed files with 46 additions and 22 deletions

View file

@ -2066,6 +2066,8 @@ fn parse_pretty(
("expanded", _) => Source(PpSourceMode::Expanded),
("expanded,identified", _) => Source(PpSourceMode::ExpandedIdentified),
("expanded,hygiene", _) => Source(PpSourceMode::ExpandedHygiene),
("ast-tree", true) => AstTree(PpAstTreeMode::Normal),
("ast-tree,expanded", true) => AstTree(PpAstTreeMode::Expanded),
("hir", true) => Hir(PpHirMode::Normal),
("hir,identified", true) => Hir(PpHirMode::Identified),
("hir,typed", true) => Hir(PpHirMode::Typed),
@ -2080,8 +2082,8 @@ fn parse_pretty(
"argument to `unpretty` must be one of `normal`, \
`expanded`, `identified`, `expanded,identified`, \
`expanded,hygiene`, `everybody_loops`, \
`hir`, `hir,identified`, `hir,typed`, `hir-tree`, \
`mir` or `mir-cfg`; got {}",
`ast-tree`, `ast-tree,expanded`, `hir`, `hir,identified`, \
`hir,typed`, `hir-tree`, `mir` or `mir-cfg`; got {}",
name
),
);
@ -2233,6 +2235,14 @@ 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`
@ -2248,6 +2258,7 @@ pub enum PpMode {
/// Options that print the source code, i.e.
/// `--pretty` and `-Zunpretty=everybody_loops`
Source(PpSourceMode),
AstTree(PpAstTreeMode),
/// Options that print the HIR, i.e. `-Zunpretty=hir`
Hir(PpHirMode),
/// `-Zunpretty=hir-tree`
@ -2263,9 +2274,10 @@ impl PpMode {
use PpMode::*;
use PpSourceMode::*;
match *self {
Source(Normal | Identified) => false,
Source(Normal | Identified) | AstTree(PpAstTreeMode::Normal) => false,
Source(Expanded | EveryBodyLoops | ExpandedIdentified | ExpandedHygiene)
| AstTree(PpAstTreeMode::Expanded)
| Hir(_)
| HirTree
| Mir