From a2d2cfa89afb9aa2aa87452e0ee414e488731b4e Mon Sep 17 00:00:00 2001 From: Phil Ellison Date: Wed, 7 Feb 2018 07:08:58 +0000 Subject: [PATCH 1/2] Explain how to dump HIR --- src/hir.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/hir.md b/src/hir.md index 52fda69a6fc32..1293368748dae 100644 --- a/src/hir.md +++ b/src/hir.md @@ -10,6 +10,14 @@ been desugared away (as an example, `for` loops are converted into a This chapter covers the main concepts of the HIR. +You can view the HIR representation of your code by passing the +`-Zunpretty=hir-tree` flag to rustc, for example by setting the `RUSTFLAGS` +environment variable: + +``` +RUSTFLAGS=-Zunpretty=hir-tree cargo build +``` + ### Out-of-band storage and the `Crate` type The top-level data-structure in the HIR is the `Crate`, which stores From 5ba0d6bc04309dc01913e6b9590efb30641276ea Mon Sep 17 00:00:00 2001 From: Phil Ellison Date: Wed, 7 Feb 2018 19:14:58 +0000 Subject: [PATCH 2/2] Use cargo rustc instead of setting RUSTFLAGS --- src/hir.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/hir.md b/src/hir.md index 1293368748dae..f3145925ce9f9 100644 --- a/src/hir.md +++ b/src/hir.md @@ -11,11 +11,10 @@ been desugared away (as an example, `for` loops are converted into a This chapter covers the main concepts of the HIR. You can view the HIR representation of your code by passing the -`-Zunpretty=hir-tree` flag to rustc, for example by setting the `RUSTFLAGS` -environment variable: +`-Zunpretty=hir-tree` flag to rustc: ``` -RUSTFLAGS=-Zunpretty=hir-tree cargo build +cargo rustc -- -Zunpretty=hir-tree ``` ### Out-of-band storage and the `Crate` type