diff options
| author | LeSeulArtichaut <leseulartichaut@gmail.com> | 2021-02-19 22:40:28 +0100 |
|---|---|---|
| committer | LeSeulArtichaut <leseulartichaut@gmail.com> | 2021-03-03 15:11:26 +0100 |
| commit | 61114453ae55a93da437adb8fbf6b8a901f4fee5 (patch) | |
| tree | 12460eae888c7177918e36bc8575cf5e664eea44 /compiler/rustc_session/src | |
| parent | 939b14334dfec68d85b01b62c1be0172cee03339 (diff) | |
| download | rust-61114453ae55a93da437adb8fbf6b8a901f4fee5.tar.gz rust-61114453ae55a93da437adb8fbf6b8a901f4fee5.zip | |
Add `-Z unpretty` flags for the AST
Diffstat (limited to 'compiler/rustc_session/src')
| -rw-r--r-- | compiler/rustc_session/src/config.rs | 18 | ||||
| -rw-r--r-- | compiler/rustc_session/src/options.rs | 2 |
2 files changed, 17 insertions, 3 deletions
diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index a3900ebcea9..77a9a2b227c 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -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 ), ); @@ -2234,6 +2236,14 @@ pub enum PpSourceMode { } #[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` Normal, @@ -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 diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index e2b6b1dc243..6e7d39547a1 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -1158,6 +1158,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, `expanded`, `expanded,identified`, `expanded,hygiene` (with internal representations), `everybody_loops` (all function bodies replaced with `loop {}`), + `ast-tree` (raw AST before expansion), + `ast-tree,expanded` (raw AST after expansion), `hir` (the HIR), `hir,identified`, `hir,typed` (HIR with types for each node), `hir-tree` (dump the raw HIR), |
