]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #33450 - SiegeLord:dep_info_no_analysis, r=nrc
authorbors <bors@rust-lang.org>
Fri, 13 May 2016 02:52:51 +0000 (19:52 -0700)
committerbors <bors@rust-lang.org>
Fri, 13 May 2016 02:52:51 +0000 (19:52 -0700)
Make --emit dep-info work correctly with -Z no-analysis again.

Previously, it would attempt to resolve some external crates that weren't necessary for dep-info output.

Fixes #33231.

src/librustc_driver/driver.rs
src/librustc_driver/lib.rs
src/librustc_driver/pretty.rs
src/test/run-make/dep-info-no-analysis/Makefile [new file with mode: 0644]
src/test/run-make/dep-info-no-analysis/input.dd [new file with mode: 0644]
src/test/run-make/dep-info-no-analysis/input.rs [new file with mode: 0644]

index f0c2de293277580fd3c778b6d423547c7ddc1e99..6837c23e41467c1651f3453589b3915addad5d52 100644 (file)
@@ -138,6 +138,19 @@ macro_rules! controller_entry_point {
                                                                  &id),
                                 Ok(()));
 
+        write_out_deps(sess, &outputs, &id);
+
+        controller_entry_point!(after_write_deps,
+                                sess,
+                                CompileState::state_after_write_deps(input,
+                                                                     sess,
+                                                                     outdir,
+                                                                     output,
+                                                                     &cstore,
+                                                                     &expanded_crate,
+                                                                     &id),
+                                Ok(()));
+
         let expanded_crate = assign_node_ids(sess, expanded_crate);
         let dep_graph = DepGraph::new(sess.opts.build_dep_graph());
 
@@ -173,25 +186,22 @@ macro_rules! controller_entry_point {
                            "indexing hir",
                            move || hir_map::map_crate(hir_forest, defs));
 
-
-        write_out_deps(sess, &outputs, &id);
-
         {
             let _ignore = hir_map.dep_graph.in_ignore();
-            controller_entry_point!(after_write_deps,
+            controller_entry_point!(after_hir_lowering,
                                     sess,
-                                    CompileState::state_after_write_deps(input,
-                                                                         sess,
-                                                                         outdir,
-                                                                         output,
-                                                                         &arenas,
-                                                                         &cstore,
-                                                                         &hir_map,
-                                                                         &analysis,
-                                                                         &resolutions,
-                                                                         &expanded_crate,
-                                                                         &hir_map.krate(),
-                                                                         &id),
+                                    CompileState::state_after_hir_lowering(input,
+                                                                  sess,
+                                                                  outdir,
+                                                                  output,
+                                                                  &arenas,
+                                                                  &cstore,
+                                                                  &hir_map,
+                                                                  &analysis,
+                                                                  &resolutions,
+                                                                  &expanded_crate,
+                                                                  &hir_map.krate(),
+                                                                  &id),
                                     Ok(()));
         }
 
@@ -311,6 +321,7 @@ pub struct CompileController<'a> {
     pub after_parse: PhaseController<'a>,
     pub after_expand: PhaseController<'a>,
     pub after_write_deps: PhaseController<'a>,
+    pub after_hir_lowering: PhaseController<'a>,
     pub after_analysis: PhaseController<'a>,
     pub after_llvm: PhaseController<'a>,
 
@@ -323,6 +334,7 @@ pub fn basic() -> CompileController<'a> {
             after_parse: PhaseController::basic(),
             after_expand: PhaseController::basic(),
             after_write_deps: PhaseController::basic(),
+            after_hir_lowering: PhaseController::basic(),
             after_analysis: PhaseController::basic(),
             after_llvm: PhaseController::basic(),
             make_glob_map: resolve::MakeGlobMap::No,
@@ -433,15 +445,32 @@ fn state_after_write_deps(input: &'a Input,
                               session: &'ast Session,
                               out_dir: &'a Option<PathBuf>,
                               out_file: &'a Option<PathBuf>,
-                              arenas: &'ast ty::CtxtArenas<'ast>,
                               cstore: &'a CStore,
-                              hir_map: &'a hir_map::Map<'ast>,
-                              analysis: &'a ty::CrateAnalysis,
-                              resolutions: &'a Resolutions,
                               krate: &'a ast::Crate,
-                              hir_crate: &'a hir::Crate,
                               crate_name: &'a str)
                               -> CompileState<'a, 'b, 'ast, 'tcx> {
+        CompileState {
+            crate_name: Some(crate_name),
+            cstore: Some(cstore),
+            expanded_crate: Some(krate),
+            out_file: out_file.as_ref().map(|s| &**s),
+            ..CompileState::empty(input, session, out_dir)
+        }
+    }
+
+    fn state_after_hir_lowering(input: &'a Input,
+                                session: &'ast Session,
+                                out_dir: &'a Option<PathBuf>,
+                                out_file: &'a Option<PathBuf>,
+                                arenas: &'ast ty::CtxtArenas<'ast>,
+                                cstore: &'a CStore,
+                                hir_map: &'a hir_map::Map<'ast>,
+                                analysis: &'a ty::CrateAnalysis,
+                                resolutions: &'a Resolutions,
+                                krate: &'a ast::Crate,
+                                hir_crate: &'a hir::Crate,
+                                crate_name: &'a str)
+                                -> CompileState<'a, 'b, 'ast, 'tcx> {
         CompileState {
             crate_name: Some(crate_name),
             arenas: Some(arenas),
index 4da36be94e009bdfa1fa2efd5eb0032a364cbca0..2a4b30e016f28225ea469e5a11a95fb49ff786a2 100644 (file)
@@ -461,23 +461,23 @@ fn build_controller(&mut self,
 
         if let Some((ppm, opt_uii)) = parse_pretty(sess, matches) {
             if ppm.needs_ast_map(&opt_uii) {
-                control.after_write_deps.stop = Compilation::Stop;
+                control.after_hir_lowering.stop = Compilation::Stop;
 
                 control.after_parse.callback = box move |state| {
                     state.krate = Some(pretty::fold_crate(state.krate.take().unwrap(), ppm));
                 };
-                control.after_write_deps.callback = box move |state| {
-                    pretty::print_after_write_deps(state.session,
-                                                   state.ast_map.unwrap(),
-                                                   state.analysis.unwrap(),
-                                                   state.resolutions.unwrap(),
-                                                   state.input,
-                                                   &state.expanded_crate.take().unwrap(),
-                                                   state.crate_name.unwrap(),
-                                                   ppm,
-                                                   state.arenas.unwrap(),
-                                                   opt_uii.clone(),
-                                                   state.out_file);
+                control.after_hir_lowering.callback = box move |state| {
+                    pretty::print_after_hir_lowering(state.session,
+                                                     state.ast_map.unwrap(),
+                                                     state.analysis.unwrap(),
+                                                     state.resolutions.unwrap(),
+                                                     state.input,
+                                                     &state.expanded_crate.take().unwrap(),
+                                                     state.crate_name.unwrap(),
+                                                     ppm,
+                                                     state.arenas.unwrap(),
+                                                     opt_uii.clone(),
+                                                     state.out_file);
                 };
             } else {
                 control.after_parse.stop = Compilation::Stop;
index d841f7c86a93e3228ba42bdba8e09e9747b7961a..9aae9f04c92cbe264a70e2fcde19cee12bb36fca 100644 (file)
@@ -812,17 +812,17 @@ pub fn print_after_parsing(sess: &Session,
     write_output(out, ofile);
 }
 
-pub fn print_after_write_deps<'tcx, 'a: 'tcx>(sess: &'a Session,
-                                              ast_map: &hir_map::Map<'tcx>,
-                                              analysis: &ty::CrateAnalysis,
-                                              resolutions: &Resolutions,
-                                              input: &Input,
-                                              krate: &ast::Crate,
-                                              crate_name: &str,
-                                              ppm: PpMode,
-                                              arenas: &'tcx ty::CtxtArenas<'tcx>,
-                                              opt_uii: Option<UserIdentifiedItem>,
-                                              ofile: Option<&Path>) {
+pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
+                                                ast_map: &hir_map::Map<'tcx>,
+                                                analysis: &ty::CrateAnalysis,
+                                                resolutions: &Resolutions,
+                                                input: &Input,
+                                                krate: &ast::Crate,
+                                                crate_name: &str,
+                                                ppm: PpMode,
+                                                arenas: &'tcx ty::CtxtArenas<'tcx>,
+                                                opt_uii: Option<UserIdentifiedItem>,
+                                                ofile: Option<&Path>) {
     let dep_graph = DepGraph::new(false);
     let _ignore = dep_graph.in_ignore();
 
diff --git a/src/test/run-make/dep-info-no-analysis/Makefile b/src/test/run-make/dep-info-no-analysis/Makefile
new file mode 100644 (file)
index 0000000..5d2cfad
--- /dev/null
@@ -0,0 +1,6 @@
+-include ../tools.mk
+
+all:
+       $(RUSTC) -o $(TMPDIR)/input.dd -Z no-analysis --emit dep-info input.rs
+       sed -i'.bak' 's/^.*input.dd/input.dd/g' $(TMPDIR)/input.dd
+       diff -u $(TMPDIR)/input.dd input.dd
diff --git a/src/test/run-make/dep-info-no-analysis/input.dd b/src/test/run-make/dep-info-no-analysis/input.dd
new file mode 100644 (file)
index 0000000..f2c8676
--- /dev/null
@@ -0,0 +1,3 @@
+input.dd: input.rs
+
+input.rs:
diff --git a/src/test/run-make/dep-info-no-analysis/input.rs b/src/test/run-make/dep-info-no-analysis/input.rs
new file mode 100644 (file)
index 0000000..523b0f0
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Tests that dep info can be emitted without resolving external crates.
+extern crate not_there;
+
+fn main() {}