Skip to content

Commit

Permalink
Rollup merge of rust-lang#42266 - rkruppe:clean-trans-api, r=arielb1
Browse files Browse the repository at this point in the history
Remove unused APIs from rustc_trans

There were public re-exports of some rustc modules dating back to 2011 or so. While I was at it, some functions and modules were public but never used outside the crate. I made them private or `pub(crate)` as appropriate and in one case removed an unused function.
  • Loading branch information
Mark-Simulacrum committed May 28, 2017
2 parents 423b410 + 6fec17e commit 1128fab
Show file tree
Hide file tree
Showing 18 changed files with 50 additions and 72 deletions.
4 changes: 2 additions & 2 deletions src/librustc_trans/assert_module_sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ const CFG: &'static str = "cfg";
#[derive(Debug, PartialEq)]
enum Disposition { Reused, Translated }

pub fn assert_module_sources<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
modules: &[ModuleTranslation]) {
pub(crate) fn assert_module_sources<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
modules: &[ModuleTranslation]) {
let _ignore = tcx.dep_graph.in_ignore();

if tcx.sess.opts.incremental.is_none() {
Expand Down
20 changes: 9 additions & 11 deletions src/librustc_trans/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,16 @@ use super::rpath::RPathConfig;
use super::rpath;
use super::msvc;
use metadata::METADATA_FILENAME;
use session::config;
use session::config::NoDebugInfo;
use session::config::{OutputFilenames, Input, OutputType};
use session::filesearch;
use session::search_paths::PathKind;
use session::Session;
use middle::cstore::{self, LinkMeta, NativeLibrary, LibSource};
use middle::cstore::{LinkagePreference, NativeLibraryKind};
use middle::dependency_format::Linkage;
use rustc::session::config::{self, NoDebugInfo, OutputFilenames, Input, OutputType};
use rustc::session::filesearch;
use rustc::session::search_paths::PathKind;
use rustc::session::Session;
use rustc::middle::cstore::{self, LinkMeta, NativeLibrary, LibSource, LinkagePreference,
NativeLibraryKind};
use rustc::middle::dependency_format::Linkage;
use CrateTranslation;
use util::common::time;
use util::fs::fix_windows_verbatim_for_gcc;
use rustc::util::common::time;
use rustc::util::fs::fix_windows_verbatim_for_gcc;
use rustc::dep_graph::DepNode;
use rustc::hir::def_id::CrateNum;
use rustc::hir::svh::Svh;
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_trans/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ use context::SharedCrateContext;

use back::archive;
use back::symbol_export::{self, ExportedSymbols};
use middle::dependency_format::Linkage;
use rustc::middle::dependency_format::Linkage;
use rustc::hir::def_id::{LOCAL_CRATE, CrateNum};
use rustc_back::LinkerFlavor;
use session::Session;
use session::config::{self, CrateType, OptLevel, DebugInfoLevel};
use rustc::session::Session;
use rustc::session::config::{self, CrateType, OptLevel, DebugInfoLevel};
use serialize::{json, Encoder};

/// For all the linkers we support, and information they might
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_trans/back/msvc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ mod platform {
use std::fs;
use std::path::{Path, PathBuf};
use std::process::Command;
use session::Session;
use rustc::session::Session;
use super::arch::{host_arch, Arch};
use super::registry::LOCAL_MACHINE;

Expand Down Expand Up @@ -296,7 +296,7 @@ mod platform {
mod platform {
use std::path::PathBuf;
use std::process::Command;
use session::Session;
use rustc::session::Session;
pub fn link_exe_cmd(_sess: &Session) -> (Command, Option<PathBuf>) {
(Command::new("link.exe"), None)
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/back/symbol_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use context::SharedCrateContext;
use monomorphize::Instance;
use util::nodemap::FxHashMap;
use rustc::util::nodemap::FxHashMap;
use rustc::hir::def_id::{DefId, CrateNum, LOCAL_CRATE};
use rustc::session::config;
use rustc::ty::TyCtxt;
Expand Down
10 changes: 0 additions & 10 deletions src/librustc_trans/back/symbol_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,16 +348,6 @@ impl ItemPathBuffer for SymbolPathBuffer {
}
}

pub fn exported_name_from_type_and_prefix<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
t: Ty<'tcx>,
prefix: &str)
-> String {
let hash = get_symbol_hash(tcx, None, t, None);
let mut buffer = SymbolPathBuffer::new();
buffer.push(prefix);
buffer.finish(hash)
}

// Name sanitation. LLVM will happily accept identifiers with weird names, but
// gas doesn't!
// gas accepts the following characters in symbols: a-z, A-Z, 0-9, ., _, $
Expand Down
11 changes: 5 additions & 6 deletions src/librustc_trans/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@ use back::lto;
use back::link::{get_linker, remove};
use back::symbol_export::ExportedSymbols;
use rustc_incremental::{save_trans_partition, in_incr_comp_dir};
use session::config::{OutputFilenames, OutputTypes, Passes, SomePasses, AllPasses, Sanitizer};
use session::Session;
use session::config::{self, OutputType};
use rustc::session::config::{self, OutputFilenames, OutputType, OutputTypes, Passes, SomePasses,
AllPasses, Sanitizer};
use rustc::session::Session;
use llvm;
use llvm::{ModuleRef, TargetMachineRef, PassManagerRef, DiagnosticInfoRef, ContextRef};
use llvm::SMDiagnosticRef;
use {CrateTranslation, ModuleLlvm, ModuleSource, ModuleTranslation};
use util::common::{time, time_depth, set_time_depth};
use util::common::path2cstr;
use util::fs::link_or_copy;
use rustc::util::common::{time, time_depth, set_time_depth, path2cstr};
use rustc::util::fs::link_or_copy;
use errors::{self, Handler, Level, DiagnosticBuilder};
use errors::emitter::Emitter;
use syntax_pos::MultiSpan;
Expand Down
10 changes: 5 additions & 5 deletions src/librustc_trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ use llvm::{ContextRef, Linkage, ModuleRef, ValueRef, Vector, get_param};
use llvm;
use metadata;
use rustc::hir::def_id::LOCAL_CRATE;
use middle::lang_items::StartFnLangItem;
use middle::cstore::EncodedMetadata;
use rustc::middle::lang_items::StartFnLangItem;
use rustc::middle::cstore::EncodedMetadata;
use rustc::ty::{self, Ty, TyCtxt};
use rustc::dep_graph::AssertDepGraphSafe;
use rustc::middle::cstore::LinkMeta;
use rustc::hir::map as hir_map;
use rustc::util::common::time;
use session::config::{self, NoDebugInfo};
use rustc::session::config::{self, NoDebugInfo};
use rustc::session::{self, DataTypeKind, Session};
use rustc_incremental::IncrementalHashesMap;
use session::{self, DataTypeKind, Session};
use abi;
use mir::lvalue::LvalueRef;
use attributes;
Expand All @@ -71,7 +71,7 @@ use trans_item::{TransItem, DefPathBasedNames};
use type_::Type;
use type_of;
use value::Value;
use util::nodemap::{NodeSet, FxHashMap, FxHashSet};
use rustc::util::nodemap::{NodeSet, FxHashMap, FxHashSet};

use libc::c_uint;
use std::ffi::{CStr, CString};
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ use rustc::mir::visit::Visitor as MirVisitor;
use context::SharedCrateContext;
use common::{def_ty, instance_ty};
use monomorphize::{self, Instance};
use util::nodemap::{FxHashSet, FxHashMap, DefIdMap};
use rustc::util::nodemap::{FxHashSet, FxHashMap, DefIdMap};

use trans_item::{TransItem, DefPathBasedNames, InstantiationMode};

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use llvm::{ValueRef, ContextRef, TypeKind};
use llvm::{True, False, Bool, OperandBundleDef};
use rustc::hir::def_id::DefId;
use rustc::hir::map::DefPathData;
use middle::lang_items::LangItem;
use rustc::middle::lang_items::LangItem;
use base;
use builder::Builder;
use consts;
Expand Down
7 changes: 3 additions & 4 deletions src/librustc_trans/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ use rustc_data_structures::base_n;
use rustc::ty::subst::Substs;
use rustc::ty::{self, Ty, TyCtxt};
use rustc::ty::layout::{LayoutTyper, TyLayout};
use session::config::NoDebugInfo;
use session::Session;
use session::config;
use util::nodemap::{NodeSet, DefIdMap, FxHashMap};
use rustc::session::config::{self, NoDebugInfo};
use rustc::session::Session;
use rustc::util::nodemap::{NodeSet, DefIdMap, FxHashMap};

use std::ffi::{CStr, CString};
use std::cell::{Cell, RefCell};
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/debuginfo/gdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use common::{C_bytes, CrateContext, C_i32};
use builder::Builder;
use declare;
use type_::Type;
use session::config::NoDebugInfo;
use rustc::session::config::NoDebugInfo;

use std::ptr;
use syntax::attr;
Expand Down
5 changes: 2 additions & 3 deletions src/librustc_trans/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use super::namespace::mangled_name_of_item;
use super::type_names::compute_debuginfo_type_name;
use super::{CrateDebugContext};
use context::SharedCrateContext;
use session::Session;

use llvm::{self, ValueRef};
use llvm::debuginfo::{DIType, DIFile, DIScope, DIDescriptor,
Expand All @@ -37,8 +36,8 @@ use common::{self, CrateContext};
use type_::Type;
use rustc::ty::{self, AdtKind, Ty};
use rustc::ty::layout::{self, LayoutTyper};
use session::config;
use util::nodemap::FxHashMap;
use rustc::session::{Session, config};
use rustc::util::nodemap::FxHashMap;

use libc::{c_uint, c_longlong};
use std::ffi::CString;
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_trans/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ use builder::Builder;
use monomorphize::Instance;
use rustc::ty::{self, Ty};
use rustc::mir;
use session::config::{self, FullDebugInfo, LimitedDebugInfo, NoDebugInfo};
use util::nodemap::{DefIdMap, FxHashMap, FxHashSet};
use rustc::session::config::{self, FullDebugInfo, LimitedDebugInfo, NoDebugInfo};
use rustc::util::nodemap::{DefIdMap, FxHashMap, FxHashSet};

use libc::c_uint;
use std::cell::{Cell, RefCell};
Expand Down
27 changes: 10 additions & 17 deletions src/librustc_trans/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,32 +63,25 @@ extern crate syntax_pos;
extern crate rustc_errors as errors;
extern crate serialize;

pub use rustc::session;
pub use rustc::middle;
pub use rustc::lint;
pub use rustc::util;

pub use base::trans_crate;
pub use back::symbol_names::provide;

pub use metadata::LlvmMetadataLoader;
pub use llvm_util::{init, target_features, print_version, print_passes, print, enable_llvm_debug};

pub mod back {
pub use rustc::hir::svh;

pub mod archive;
pub mod linker;
mod archive;
pub(crate) mod linker;
pub mod link;
pub mod lto;
pub mod symbol_export;
pub mod symbol_names;
mod lto;
pub(crate) mod symbol_export;
pub(crate) mod symbol_names;
pub mod write;
pub mod msvc;
pub mod rpath;
mod msvc;
mod rpath;
}

pub mod diagnostics;
mod diagnostics;

mod abi;
mod adt;
Expand Down Expand Up @@ -171,8 +164,8 @@ pub struct CrateTranslation {
pub crate_name: Symbol,
pub modules: Vec<ModuleTranslation>,
pub metadata_module: ModuleTranslation,
pub link: middle::cstore::LinkMeta,
pub metadata: middle::cstore::EncodedMetadata,
pub link: rustc::middle::cstore::LinkMeta,
pub metadata: rustc::middle::cstore::EncodedMetadata,
pub exported_symbols: back::symbol_export::ExportedSymbols,
pub no_builtins: bool,
pub windows_subsystem: Option<String>,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use rustc::mir::{self, Mir};
use rustc::mir::tcx::LvalueTy;
use rustc::ty::subst::Substs;
use rustc::infer::TransNormalize;
use session::config::FullDebugInfo;
use rustc::session::config::FullDebugInfo;
use base;
use builder::Builder;
use common::{self, CrateContext, Funclet};
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/mir/rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use rustc::ty::cast::{CastTy, IntTy};
use rustc::ty::layout::{Layout, LayoutTyper};
use rustc::mir::tcx::LvalueTy;
use rustc::mir;
use middle::lang_items::ExchangeMallocFnLangItem;
use rustc::middle::lang_items::ExchangeMallocFnLangItem;

use base;
use builder::Builder;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/partitioning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ use std::sync::Arc;
use syntax::ast::NodeId;
use syntax::symbol::{Symbol, InternedString};
use trans_item::{TransItem, InstantiationMode};
use util::nodemap::{FxHashMap, FxHashSet};
use rustc::util::nodemap::{FxHashMap, FxHashSet};

pub enum PartitioningStrategy {
/// Generate one codegen unit per source-level module.
Expand Down

0 comments on commit 1128fab

Please sign in to comment.