diff options
| author | bors <bors@rust-lang.org> | 2015-11-20 20:03:16 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-11-20 20:03:16 +0000 |
| commit | 20cbba71d496b8b3760d76d694e12dd54c3f3eea (patch) | |
| tree | 819352acff806428b0641a2ef343de0c3fb562d3 /src | |
| parent | 6a6b97cf025b8a1fb92fc48a4dc06611d2970861 (diff) | |
| parent | de8467cf4203632b91f80523f314bca4ddb17319 (diff) | |
| download | rust-20cbba71d496b8b3760d76d694e12dd54c3f3eea.tar.gz rust-20cbba71d496b8b3760d76d694e12dd54c3f3eea.zip | |
Auto merge of #29945 - nrc:save-crate-name, r=alexcrichton
r? @alexcrichton This prevents outputting csv files with the same name and thus overwriting each other when indexing Cargo projects with a bin crate (and some other cases).
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_trans/save/mod.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/librustc_trans/save/mod.rs b/src/librustc_trans/save/mod.rs index af9f3e4896d..53f2d93c3f1 100644 --- a/src/librustc_trans/save/mod.rs +++ b/src/librustc_trans/save/mod.rs @@ -17,8 +17,9 @@ use std::fs::{self, File}; use std::path::{Path, PathBuf}; use rustc_front; -use rustc::front::map::NodeItem; use rustc_front::{hir, lowering}; +use rustc::front::map::NodeItem; +use rustc::session::config::CrateType::CrateTypeExecutable; use syntax::ast::{self, NodeId}; use syntax::ast_util; @@ -744,7 +745,14 @@ pub fn process_crate<'l, 'tcx>(tcx: &'l ty::ctxt<'tcx>, } // Create output file. - let mut out_name = cratename.to_owned(); + let executable = tcx.sess.crate_types.borrow().iter().any(|ct| *ct == CrateTypeExecutable); + let mut out_name = if executable { + "".to_owned() + } else { + "lib".to_owned() + }; + out_name.push_str(&cratename); + out_name.push_str(&tcx.sess.opts.cg.extra_filename); out_name.push_str(".csv"); root_path.push(&out_name); let output_file = match File::create(&root_path) { |
