diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index bdda7741221f5..514d76a4129ec 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -146,8 +146,9 @@ pub(crate) fn link_binary(sess: &Session, let mut out_filenames = Vec::new(); for &crate_type in sess.crate_types.borrow().iter() { // Ignore executable crates if we have -Z no-trans, as they will error. - if (sess.opts.debugging_opts.no_trans || - !sess.opts.output_types.should_trans()) && + let output_metadata = sess.opts.output_types.contains_key(&OutputType::Metadata); + if (sess.opts.debugging_opts.no_trans || !sess.opts.output_types.should_trans()) && + !output_metadata && crate_type == config::CrateTypeExecutable { continue; }