Skip to content

Commit

Permalink
Rollup merge of rust-lang#40336 - alexcrichton:fast-dep-info, r=nrc
Browse files Browse the repository at this point in the history
rustc: Exit quickly on only `--emit dep-info`

This commit alters the compiler to exit quickly if the only output being emitted
is `dep-info`, which doesn't need a lot of other information to generate.

Closes rust-lang#40328
  • Loading branch information
alexcrichton authored Mar 10, 2017
2 parents 6dc03c3 + 5c8aa74 commit 88aa2ac
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ pub fn compile_input(sess: &Session,
};

write_out_deps(sess, &outputs, &crate_name);
if sess.opts.output_types.contains_key(&OutputType::DepInfo) &&
sess.opts.output_types.keys().count() == 1 {
return Ok(())
}

let arena = DroplessArena::new();
let arenas = GlobalArenas::new();
Expand Down
4 changes: 4 additions & 0 deletions src/test/run-make/dep-info-doesnt-run-much/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-include ../tools.mk

all:
$(RUSTC) foo.rs --emit dep-info
15 changes: 15 additions & 0 deletions src/test/run-make/dep-info-doesnt-run-much/foo.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2017 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.

// We're only emitting dep info, so we shouldn't be running static analysis to
// figure out that this program is erroneous.
fn main() {
let a: u8 = "a";
}

0 comments on commit 88aa2ac

Please sign in to comment.