Add len() method to OutputTypes

This commit is contained in:
varkor 2018-03-28 00:13:34 +01:00
parent f15e5c133e
commit 8414520436
3 changed files with 6 additions and 2 deletions

View File

@ -246,6 +246,10 @@ impl OutputTypes {
self.0.values()
}
pub fn len(&self) -> usize {
self.0.len()
}
// True if any of the output types require codegen or linking.
pub fn should_trans(&self) -> bool {
self.0.keys().any(|k| match *k {

View File

@ -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(())
}

View File

@ -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)
}