Skip to content

Commit 5c8aa74

Browse files
committed
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 #40328
1 parent f573db4 commit 5c8aa74

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

src/librustc_driver/driver.rs

+4
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ pub fn compile_input(sess: &Session,
125125
};
126126

127127
write_out_deps(sess, &outputs, &crate_name);
128+
if sess.opts.output_types.contains_key(&OutputType::DepInfo) &&
129+
sess.opts.output_types.keys().count() == 1 {
130+
return Ok(())
131+
}
128132

129133
let arena = DroplessArena::new();
130134
let arenas = GlobalArenas::new();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-include ../tools.mk
2+
3+
all:
4+
$(RUSTC) foo.rs --emit dep-info
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// We're only emitting dep info, so we shouldn't be running static analysis to
12+
// figure out that this program is erroneous.
13+
fn main() {
14+
let a: u8 = "a";
15+
}

0 commit comments

Comments
 (0)