]> git.lizzy.rs Git - rust.git/commitdiff
Delete the AST after lowering
authorJonas Schievink <jonas@schievink.net>
Fri, 25 Dec 2015 16:17:45 +0000 (17:17 +0100)
committerJonas Schievink <jonas@schievink.net>
Fri, 25 Dec 2015 16:17:45 +0000 (17:17 +0100)
src/librustc/session/config.rs
src/librustc_driver/driver.rs

index b275480a6fc68347113837514bdd6ee58374f7f8..d1c7da1d1075fcb1d6672e1d058400be9d402444 100644 (file)
@@ -622,6 +622,8 @@ fn parse_passes(slot: &mut Passes, v: Option<&str>) -> bool {
           "force nonzeroing move optimization on"),
     keep_mtwt_tables: bool = (false, parse_bool,
           "don't clear the resolution tables after analysis"),
+    keep_ast: bool = (false, parse_bool,
+          "keep the AST after lowering it to HIR"),
 }
 
 pub fn default_lib_output() -> CrateType {
index f6dce8af435c90a15b00eea02d0700db1687d41e..1ac1b5978cfb609cacc6bd9ccf055e9e635ab35b 100644 (file)
@@ -144,6 +144,14 @@ macro_rules! controller_entry_point{($point: ident, $tsess: expr, $make_state: e
              "early lint checks",
              || lint::check_ast_crate(&sess, &expanded_crate));
 
+        let opt_crate = if sess.opts.debugging_opts.keep_ast ||
+                           sess.opts.debugging_opts.save_analysis {
+            Some(&expanded_crate)
+        } else {
+            drop(expanded_crate);
+            None
+        };
+
         phase_3_run_analysis_passes(&sess,
                                     &cstore,
                                     hir_map,
@@ -157,7 +165,7 @@ macro_rules! controller_entry_point{($point: ident, $tsess: expr, $make_state: e
                                                 CompileState::state_after_analysis(input,
                                                                                    &tcx.sess,
                                                                                    outdir,
-                                                                                   &expanded_crate,
+                                                                                   opt_crate,
                                                                                    tcx.map.krate(),
                                                                                    &analysis,
                                                                                    &mir_map,
@@ -360,7 +368,7 @@ fn state_after_write_deps(input: &'a Input,
     fn state_after_analysis(input: &'a Input,
                             session: &'a Session,
                             out_dir: &'a Option<PathBuf>,
-                            krate: &'a ast::Crate,
+                            krate: Option<&'a ast::Crate>,
                             hir_crate: &'a hir::Crate,
                             analysis: &'a ty::CrateAnalysis,
                             mir_map: &'a MirMap<'tcx>,
@@ -372,7 +380,7 @@ fn state_after_analysis(input: &'a Input,
             analysis: Some(analysis),
             mir_map: Some(mir_map),
             tcx: Some(tcx),
-            krate: Some(krate),
+            krate: krate,
             hir_crate: Some(hir_crate),
             lcx: Some(lcx),
             crate_name: Some(crate_name),