Skip to content

Commit

Permalink
Add len() method to OutputTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
varkor committed Mar 27, 2018
1 parent f15e5c1 commit 308f381
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@ impl OutputTypes {
self.0.values()
}

pub fn len(&self) -> usize {
self.0.keys().count()
}

// True if any of the output types require codegen or linking.
pub fn should_trans(&self) -> bool {
self.0.keys().any(|k| match *k {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ pub fn compile_input(trans: Box<TransCrate>,

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

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {

fn metadata_output_only(&self) -> bool {
// MIR optimisation can be skipped when we're just interested in the metadata.
self.tcx.sess.opts.output_types.keys().count() == 1 &&
self.tcx.sess.opts.output_types.len() == 1 &&
self.tcx.sess.opts.output_types.contains_key(&OutputType::Metadata)
}

Expand Down

0 comments on commit 308f381

Please sign in to comment.