Skip to content

Commit 5244d1c

Browse files
Rollup merge of #42266 - rkruppe:clean-trans-api, r=arielb1
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.
2 parents 2af8b0e + 6fec17e commit 5244d1c

18 files changed

+50
-72
lines changed

src/librustc_trans/assert_module_sources.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ const CFG: &'static str = "cfg";
4040
#[derive(Debug, PartialEq)]
4141
enum Disposition { Reused, Translated }
4242

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

4747
if tcx.sess.opts.incremental.is_none() {

src/librustc_trans/back/link.rs

+9-11
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,16 @@ use super::rpath::RPathConfig;
1414
use super::rpath;
1515
use super::msvc;
1616
use metadata::METADATA_FILENAME;
17-
use session::config;
18-
use session::config::NoDebugInfo;
19-
use session::config::{OutputFilenames, Input, OutputType};
20-
use session::filesearch;
21-
use session::search_paths::PathKind;
22-
use session::Session;
23-
use middle::cstore::{self, LinkMeta, NativeLibrary, LibSource};
24-
use middle::cstore::{LinkagePreference, NativeLibraryKind};
25-
use middle::dependency_format::Linkage;
17+
use rustc::session::config::{self, NoDebugInfo, OutputFilenames, Input, OutputType};
18+
use rustc::session::filesearch;
19+
use rustc::session::search_paths::PathKind;
20+
use rustc::session::Session;
21+
use rustc::middle::cstore::{self, LinkMeta, NativeLibrary, LibSource, LinkagePreference,
22+
NativeLibraryKind};
23+
use rustc::middle::dependency_format::Linkage;
2624
use CrateTranslation;
27-
use util::common::time;
28-
use util::fs::fix_windows_verbatim_for_gcc;
25+
use rustc::util::common::time;
26+
use rustc::util::fs::fix_windows_verbatim_for_gcc;
2927
use rustc::dep_graph::DepNode;
3028
use rustc::hir::def_id::CrateNum;
3129
use rustc::hir::svh::Svh;

src/librustc_trans/back/linker.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ use context::SharedCrateContext;
2020

2121
use back::archive;
2222
use back::symbol_export::{self, ExportedSymbols};
23-
use middle::dependency_format::Linkage;
23+
use rustc::middle::dependency_format::Linkage;
2424
use rustc::hir::def_id::{LOCAL_CRATE, CrateNum};
2525
use rustc_back::LinkerFlavor;
26-
use session::Session;
27-
use session::config::{self, CrateType, OptLevel, DebugInfoLevel};
26+
use rustc::session::Session;
27+
use rustc::session::config::{self, CrateType, OptLevel, DebugInfoLevel};
2828
use serialize::{json, Encoder};
2929

3030
/// For all the linkers we support, and information they might

src/librustc_trans/back/msvc/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ mod platform {
5252
use std::fs;
5353
use std::path::{Path, PathBuf};
5454
use std::process::Command;
55-
use session::Session;
55+
use rustc::session::Session;
5656
use super::arch::{host_arch, Arch};
5757
use super::registry::LOCAL_MACHINE;
5858

@@ -296,7 +296,7 @@ mod platform {
296296
mod platform {
297297
use std::path::PathBuf;
298298
use std::process::Command;
299-
use session::Session;
299+
use rustc::session::Session;
300300
pub fn link_exe_cmd(_sess: &Session) -> (Command, Option<PathBuf>) {
301301
(Command::new("link.exe"), None)
302302
}

src/librustc_trans/back/symbol_export.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use context::SharedCrateContext;
1212
use monomorphize::Instance;
13-
use util::nodemap::FxHashMap;
13+
use rustc::util::nodemap::FxHashMap;
1414
use rustc::hir::def_id::{DefId, CrateNum, LOCAL_CRATE};
1515
use rustc::session::config;
1616
use rustc::ty::TyCtxt;

src/librustc_trans/back/symbol_names.rs

-10
Original file line numberDiff line numberDiff line change
@@ -348,16 +348,6 @@ impl ItemPathBuffer for SymbolPathBuffer {
348348
}
349349
}
350350

351-
pub fn exported_name_from_type_and_prefix<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
352-
t: Ty<'tcx>,
353-
prefix: &str)
354-
-> String {
355-
let hash = get_symbol_hash(tcx, None, t, None);
356-
let mut buffer = SymbolPathBuffer::new();
357-
buffer.push(prefix);
358-
buffer.finish(hash)
359-
}
360-
361351
// Name sanitation. LLVM will happily accept identifiers with weird names, but
362352
// gas doesn't!
363353
// gas accepts the following characters in symbols: a-z, A-Z, 0-9, ., _, $

src/librustc_trans/back/write.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,15 @@ use back::lto;
1212
use back::link::{get_linker, remove};
1313
use back::symbol_export::ExportedSymbols;
1414
use rustc_incremental::{save_trans_partition, in_incr_comp_dir};
15-
use session::config::{OutputFilenames, OutputTypes, Passes, SomePasses, AllPasses, Sanitizer};
16-
use session::Session;
17-
use session::config::{self, OutputType};
15+
use rustc::session::config::{self, OutputFilenames, OutputType, OutputTypes, Passes, SomePasses,
16+
AllPasses, Sanitizer};
17+
use rustc::session::Session;
1818
use llvm;
1919
use llvm::{ModuleRef, TargetMachineRef, PassManagerRef, DiagnosticInfoRef, ContextRef};
2020
use llvm::SMDiagnosticRef;
2121
use {CrateTranslation, ModuleLlvm, ModuleSource, ModuleTranslation};
22-
use util::common::{time, time_depth, set_time_depth};
23-
use util::common::path2cstr;
24-
use util::fs::link_or_copy;
22+
use rustc::util::common::{time, time_depth, set_time_depth, path2cstr};
23+
use rustc::util::fs::link_or_copy;
2524
use errors::{self, Handler, Level, DiagnosticBuilder};
2625
use errors::emitter::Emitter;
2726
use syntax_pos::MultiSpan;

src/librustc_trans/base.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ use llvm::{ContextRef, Linkage, ModuleRef, ValueRef, Vector, get_param};
3636
use llvm;
3737
use metadata;
3838
use rustc::hir::def_id::LOCAL_CRATE;
39-
use middle::lang_items::StartFnLangItem;
40-
use middle::cstore::EncodedMetadata;
39+
use rustc::middle::lang_items::StartFnLangItem;
40+
use rustc::middle::cstore::EncodedMetadata;
4141
use rustc::ty::{self, Ty, TyCtxt};
4242
use rustc::dep_graph::AssertDepGraphSafe;
4343
use rustc::middle::cstore::LinkMeta;
4444
use rustc::hir::map as hir_map;
4545
use rustc::util::common::time;
46-
use session::config::{self, NoDebugInfo};
46+
use rustc::session::config::{self, NoDebugInfo};
47+
use rustc::session::{self, DataTypeKind, Session};
4748
use rustc_incremental::IncrementalHashesMap;
48-
use session::{self, DataTypeKind, Session};
4949
use abi;
5050
use mir::lvalue::LvalueRef;
5151
use attributes;
@@ -71,7 +71,7 @@ use trans_item::{TransItem, DefPathBasedNames};
7171
use type_::Type;
7272
use type_of;
7373
use value::Value;
74-
use util::nodemap::{NodeSet, FxHashMap, FxHashSet};
74+
use rustc::util::nodemap::{NodeSet, FxHashMap, FxHashSet};
7575

7676
use libc::c_uint;
7777
use std::ffi::{CStr, CString};

src/librustc_trans/collector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ use rustc::mir::visit::Visitor as MirVisitor;
204204
use context::SharedCrateContext;
205205
use common::{def_ty, instance_ty};
206206
use monomorphize::{self, Instance};
207-
use util::nodemap::{FxHashSet, FxHashMap, DefIdMap};
207+
use rustc::util::nodemap::{FxHashSet, FxHashMap, DefIdMap};
208208

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

src/librustc_trans/common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use llvm::{ValueRef, ContextRef, TypeKind};
1717
use llvm::{True, False, Bool, OperandBundleDef};
1818
use rustc::hir::def_id::DefId;
1919
use rustc::hir::map::DefPathData;
20-
use middle::lang_items::LangItem;
20+
use rustc::middle::lang_items::LangItem;
2121
use base;
2222
use builder::Builder;
2323
use consts;

src/librustc_trans/context.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ use rustc_data_structures::base_n;
2626
use rustc::ty::subst::Substs;
2727
use rustc::ty::{self, Ty, TyCtxt};
2828
use rustc::ty::layout::{LayoutTyper, TyLayout};
29-
use session::config::NoDebugInfo;
30-
use session::Session;
31-
use session::config;
32-
use util::nodemap::{NodeSet, DefIdMap, FxHashMap};
29+
use rustc::session::config::{self, NoDebugInfo};
30+
use rustc::session::Session;
31+
use rustc::util::nodemap::{NodeSet, DefIdMap, FxHashMap};
3332

3433
use std::ffi::{CStr, CString};
3534
use std::cell::{Cell, RefCell};

src/librustc_trans/debuginfo/gdb.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use common::{C_bytes, CrateContext, C_i32};
1616
use builder::Builder;
1717
use declare;
1818
use type_::Type;
19-
use session::config::NoDebugInfo;
19+
use rustc::session::config::NoDebugInfo;
2020

2121
use std::ptr;
2222
use syntax::attr;

src/librustc_trans/debuginfo/metadata.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use super::namespace::mangled_name_of_item;
1919
use super::type_names::compute_debuginfo_type_name;
2020
use super::{CrateDebugContext};
2121
use context::SharedCrateContext;
22-
use session::Session;
2322

2423
use llvm::{self, ValueRef};
2524
use llvm::debuginfo::{DIType, DIFile, DIScope, DIDescriptor,
@@ -37,8 +36,8 @@ use common::{self, CrateContext};
3736
use type_::Type;
3837
use rustc::ty::{self, AdtKind, Ty};
3938
use rustc::ty::layout::{self, LayoutTyper};
40-
use session::config;
41-
use util::nodemap::FxHashMap;
39+
use rustc::session::{Session, config};
40+
use rustc::util::nodemap::FxHashMap;
4241

4342
use libc::{c_uint, c_longlong};
4443
use std::ffi::CString;

src/librustc_trans/debuginfo/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ use builder::Builder;
3232
use monomorphize::Instance;
3333
use rustc::ty::{self, Ty};
3434
use rustc::mir;
35-
use session::config::{self, FullDebugInfo, LimitedDebugInfo, NoDebugInfo};
36-
use util::nodemap::{DefIdMap, FxHashMap, FxHashSet};
35+
use rustc::session::config::{self, FullDebugInfo, LimitedDebugInfo, NoDebugInfo};
36+
use rustc::util::nodemap::{DefIdMap, FxHashMap, FxHashSet};
3737

3838
use libc::c_uint;
3939
use std::cell::{Cell, RefCell};

src/librustc_trans/lib.rs

+10-17
Original file line numberDiff line numberDiff line change
@@ -63,32 +63,25 @@ extern crate syntax_pos;
6363
extern crate rustc_errors as errors;
6464
extern crate serialize;
6565

66-
pub use rustc::session;
67-
pub use rustc::middle;
68-
pub use rustc::lint;
69-
pub use rustc::util;
70-
7166
pub use base::trans_crate;
7267
pub use back::symbol_names::provide;
7368

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

7772
pub mod back {
78-
pub use rustc::hir::svh;
79-
80-
pub mod archive;
81-
pub mod linker;
73+
mod archive;
74+
pub(crate) mod linker;
8275
pub mod link;
83-
pub mod lto;
84-
pub mod symbol_export;
85-
pub mod symbol_names;
76+
mod lto;
77+
pub(crate) mod symbol_export;
78+
pub(crate) mod symbol_names;
8679
pub mod write;
87-
pub mod msvc;
88-
pub mod rpath;
80+
mod msvc;
81+
mod rpath;
8982
}
9083

91-
pub mod diagnostics;
84+
mod diagnostics;
9285

9386
mod abi;
9487
mod adt;
@@ -171,8 +164,8 @@ pub struct CrateTranslation {
171164
pub crate_name: Symbol,
172165
pub modules: Vec<ModuleTranslation>,
173166
pub metadata_module: ModuleTranslation,
174-
pub link: middle::cstore::LinkMeta,
175-
pub metadata: middle::cstore::EncodedMetadata,
167+
pub link: rustc::middle::cstore::LinkMeta,
168+
pub metadata: rustc::middle::cstore::EncodedMetadata,
176169
pub exported_symbols: back::symbol_export::ExportedSymbols,
177170
pub no_builtins: bool,
178171
pub windows_subsystem: Option<String>,

src/librustc_trans/mir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc::mir::{self, Mir};
1717
use rustc::mir::tcx::LvalueTy;
1818
use rustc::ty::subst::Substs;
1919
use rustc::infer::TransNormalize;
20-
use session::config::FullDebugInfo;
20+
use rustc::session::config::FullDebugInfo;
2121
use base;
2222
use builder::Builder;
2323
use common::{self, CrateContext, Funclet};

src/librustc_trans/mir/rvalue.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc::ty::cast::{CastTy, IntTy};
1414
use rustc::ty::layout::{Layout, LayoutTyper};
1515
use rustc::mir::tcx::LvalueTy;
1616
use rustc::mir;
17-
use middle::lang_items::ExchangeMallocFnLangItem;
17+
use rustc::middle::lang_items::ExchangeMallocFnLangItem;
1818

1919
use base;
2020
use builder::Builder;

src/librustc_trans/partitioning.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ use std::sync::Arc;
118118
use syntax::ast::NodeId;
119119
use syntax::symbol::{Symbol, InternedString};
120120
use trans_item::{TransItem, InstantiationMode};
121-
use util::nodemap::{FxHashMap, FxHashSet};
121+
use rustc::util::nodemap::{FxHashMap, FxHashSet};
122122

123123
pub enum PartitioningStrategy {
124124
/// Generate one codegen unit per source-level module.

0 commit comments

Comments
 (0)