From 6dffaa9175449fa771e456210f339cdabe9d0c6d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 28 Dec 2017 10:11:26 +0100 Subject: [PATCH] Hide even more of rustc_trans --- src/librustc_trans/allocator.rs | 2 +- src/librustc_trans/back/link.rs | 16 ++++++++-------- src/librustc_trans/back/lto.rs | 10 +++++----- src/librustc_trans/back/write.rs | 22 +++++++++++----------- src/librustc_trans/lib.rs | 12 ++++++------ 5 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/librustc_trans/allocator.rs b/src/librustc_trans/allocator.rs index 9abb6d66f9c..fd5aa1364d3 100644 --- a/src/librustc_trans/allocator.rs +++ b/src/librustc_trans/allocator.rs @@ -19,7 +19,7 @@ use rustc_allocator::{ALLOCATOR_METHODS, AllocatorTy}; use ModuleLlvm; use llvm::{self, False, True}; -pub unsafe fn trans(tcx: TyCtxt, mods: &ModuleLlvm, kind: AllocatorKind) { +pub(crate) unsafe fn trans(tcx: TyCtxt, mods: &ModuleLlvm, kind: AllocatorKind) { let llcx = mods.llcx; let llmod = mods.llmod; let usize = match &tcx.sess.target.target.target_pointer_width[..] { diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index f53c5b3f581..62b65b7952e 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -141,10 +141,10 @@ pub fn remove(sess: &Session, path: &Path) { /// Perform the linkage portion of the compilation phase. This will generate all /// of the requested outputs for this compilation session. -pub fn link_binary(sess: &Session, - trans: &CrateTranslation, - outputs: &OutputFilenames, - crate_name: &str) -> Vec { +pub(crate) fn link_binary(sess: &Session, + trans: &CrateTranslation, + outputs: &OutputFilenames, + crate_name: &str) -> Vec { 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. @@ -201,9 +201,9 @@ fn filename_for_metadata(sess: &Session, crate_name: &str, outputs: &OutputFilen out_filename } -pub fn each_linked_rlib(sess: &Session, - info: &CrateInfo, - f: &mut FnMut(CrateNum, &Path)) -> Result<(), String> { +pub(crate) fn each_linked_rlib(sess: &Session, + info: &CrateInfo, + f: &mut FnMut(CrateNum, &Path)) -> Result<(), String> { let crates = info.used_crates_static.iter(); let fmts = sess.dependency_formats.borrow(); let fmts = fmts.get(&config::CrateTypeExecutable) @@ -247,7 +247,7 @@ pub fn each_linked_rlib(sess: &Session, /// It's unusual for a crate to not participate in LTO. Typically only /// compiler-specific and unstable crates have a reason to not participate in /// LTO. -pub fn ignored_for_lto(sess: &Session, info: &CrateInfo, cnum: CrateNum) -> bool { +pub(crate) fn ignored_for_lto(sess: &Session, info: &CrateInfo, cnum: CrateNum) -> bool { // If our target enables builtin function lowering in LLVM then the // crates providing these functions don't participate in LTO (e.g. // no_builtins or compiler builtins crates). diff --git a/src/librustc_trans/back/lto.rs b/src/librustc_trans/back/lto.rs index 60b24a578c6..b612247ffcd 100644 --- a/src/librustc_trans/back/lto.rs +++ b/src/librustc_trans/back/lto.rs @@ -42,7 +42,7 @@ pub fn crate_type_allows_lto(crate_type: config::CrateType) -> bool { } } -pub enum LtoModuleTranslation { +pub(crate) enum LtoModuleTranslation { Fat { module: Option, _serialized_bitcode: Vec, @@ -65,9 +65,9 @@ impl LtoModuleTranslation { /// points to LLVM data structures owned by this `LtoModuleTranslation`. /// It's intended that the module returned is immediately code generated and /// dropped, and then this LTO module is dropped. - pub unsafe fn optimize(&mut self, - cgcx: &CodegenContext, - timeline: &mut Timeline) + pub(crate) unsafe fn optimize(&mut self, + cgcx: &CodegenContext, + timeline: &mut Timeline) -> Result { match *self { @@ -100,7 +100,7 @@ pub enum LTOMode { JustThisCrate, } -pub fn run(cgcx: &CodegenContext, +pub(crate) fn run(cgcx: &CodegenContext, modules: Vec, mode: LTOMode, timeline: &mut Timeline) diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index db0b045ef1e..a013af7a460 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -363,7 +363,7 @@ impl CodegenContext { Handler::with_emitter(true, false, Box::new(self.diag_emitter.clone())) } - pub fn config(&self, kind: ModuleKind) -> &ModuleConfig { + pub(crate) fn config(&self, kind: ModuleKind) -> &ModuleConfig { match kind { ModuleKind::Regular => &self.regular_module_config, ModuleKind::Metadata => &self.metadata_module_config, @@ -371,7 +371,7 @@ impl CodegenContext { } } - pub fn save_temp_bitcode(&self, trans: &ModuleTranslation, name: &str) { + pub(crate) fn save_temp_bitcode(&self, trans: &ModuleTranslation, name: &str) { if !self.save_temps { return } @@ -822,7 +822,7 @@ fn binaryen_assemble(cgcx: &CodegenContext, } } -pub struct CompiledModules { +pub(crate) struct CompiledModules { pub modules: Vec, pub metadata_module: CompiledModule, pub allocator_module: Option, @@ -1162,7 +1162,7 @@ fn produce_final_output_artifacts(sess: &Session, // These are used in linking steps and will be cleaned up afterward. } -pub fn dump_incremental_data(trans: &CrateTranslation) { +pub(crate) fn dump_incremental_data(trans: &CrateTranslation) { println!("[incremental] Re-using {} out of {} modules", trans.modules.iter().filter(|m| m.pre_existing).count(), trans.modules.len()); @@ -2144,7 +2144,7 @@ pub struct OngoingCrateTranslation { } impl OngoingCrateTranslation { - pub fn join(self, sess: &Session, dep_graph: &DepGraph) -> CrateTranslation { + pub(crate) fn join(self, sess: &Session, dep_graph: &DepGraph) -> CrateTranslation { self.shared_emitter_main.check(sess, true); let compiled_modules = match self.future.join() { Ok(Ok(compiled_modules)) => compiled_modules, @@ -2212,9 +2212,9 @@ impl OngoingCrateTranslation { trans } - pub fn submit_pre_translated_module_to_llvm(&self, - tcx: TyCtxt, - mtrans: ModuleTranslation) { + pub(crate) fn submit_pre_translated_module_to_llvm(&self, + tcx: TyCtxt, + mtrans: ModuleTranslation) { self.wait_for_signal_to_translate_item(); self.check_for_errors(tcx.sess); @@ -2247,9 +2247,9 @@ impl OngoingCrateTranslation { } } -pub fn submit_translated_module_to_llvm(tcx: TyCtxt, - mtrans: ModuleTranslation, - cost: u64) { +pub(crate) fn submit_translated_module_to_llvm(tcx: TyCtxt, + mtrans: ModuleTranslation, + cost: u64) { let llvm_work_item = WorkItem::Optimize(mtrans); drop(tcx.tx_to_llvm_workers.send(Box::new(Message::TranslationDone { llvm_work_item, diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index 96a130d86d2..d1dec63e0d8 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -250,7 +250,7 @@ impl TransCrate for LlvmTransCrate { } } -pub struct ModuleTranslation { +struct ModuleTranslation { /// The name of the module. When the crate may be saved between /// compilations, incremental compilation requires that name be /// unique amongst **all** crates. Therefore, it should contain @@ -263,7 +263,7 @@ pub struct ModuleTranslation { } #[derive(Copy, Clone, Debug, PartialEq)] -pub enum ModuleKind { +enum ModuleKind { Regular, Metadata, Allocator, @@ -316,7 +316,7 @@ impl ModuleTranslation { } #[derive(Debug)] -pub struct CompiledModule { +struct CompiledModule { name: String, llmod_id: String, kind: ModuleKind, @@ -335,7 +335,7 @@ enum ModuleSource { } #[derive(Debug)] -pub struct ModuleLlvm { +struct ModuleLlvm { llcx: llvm::ContextRef, llmod: llvm::ModuleRef, tm: llvm::TargetMachineRef, @@ -354,7 +354,7 @@ impl Drop for ModuleLlvm { } } -pub struct CrateTranslation { +struct CrateTranslation { crate_name: Symbol, modules: Vec, allocator_module: Option, @@ -367,7 +367,7 @@ pub struct CrateTranslation { } // Misc info we load from metadata to persist beyond the tcx -pub struct CrateInfo { +struct CrateInfo { panic_runtime: Option, compiler_builtins: Option, profiler_runtime: Option,