Skip to content

Commit 94c3c34

Browse files
committed
Auto merge of #52758 - Mark-Simulacrum:session-cleanup, r=pnkfelix
Cleanup for librustc::session Some rather straightforward cleanup. Each commit mostly stands alone.
2 parents 215bf3a + 0ae2aa2 commit 94c3c34

File tree

38 files changed

+313
-346
lines changed

38 files changed

+313
-346
lines changed

src/librustc/middle/dependency_format.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -115,30 +115,30 @@ fn calculate_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
115115

116116
let preferred_linkage = match ty {
117117
// cdylibs must have all static dependencies.
118-
config::CrateTypeCdylib => Linkage::Static,
118+
config::CrateType::Cdylib => Linkage::Static,
119119

120120
// Generating a dylib without `-C prefer-dynamic` means that we're going
121121
// to try to eagerly statically link all dependencies. This is normally
122122
// done for end-product dylibs, not intermediate products.
123-
config::CrateTypeDylib if !sess.opts.cg.prefer_dynamic => Linkage::Static,
124-
config::CrateTypeDylib => Linkage::Dynamic,
123+
config::CrateType::Dylib if !sess.opts.cg.prefer_dynamic => Linkage::Static,
124+
config::CrateType::Dylib => Linkage::Dynamic,
125125

126126
// If the global prefer_dynamic switch is turned off, or the final
127127
// executable will be statically linked, prefer static crate linkage.
128-
config::CrateTypeExecutable if !sess.opts.cg.prefer_dynamic ||
128+
config::CrateType::Executable if !sess.opts.cg.prefer_dynamic ||
129129
sess.crt_static() => Linkage::Static,
130-
config::CrateTypeExecutable => Linkage::Dynamic,
130+
config::CrateType::Executable => Linkage::Dynamic,
131131

132132
// proc-macro crates are required to be dylibs, and they're currently
133133
// required to link to libsyntax as well.
134-
config::CrateTypeProcMacro => Linkage::Dynamic,
134+
config::CrateType::ProcMacro => Linkage::Dynamic,
135135

136136
// No linkage happens with rlibs, we just needed the metadata (which we
137137
// got long ago), so don't bother with anything.
138-
config::CrateTypeRlib => Linkage::NotLinked,
138+
config::CrateType::Rlib => Linkage::NotLinked,
139139

140140
// staticlibs must have all static dependencies.
141-
config::CrateTypeStaticlib => Linkage::Static,
141+
config::CrateType::Staticlib => Linkage::Static,
142142
};
143143

144144
if preferred_linkage == Linkage::NotLinked {
@@ -155,8 +155,8 @@ fn calculate_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
155155

156156
// Staticlibs, cdylibs, and static executables must have all static
157157
// dependencies. If any are not found, generate some nice pretty errors.
158-
if ty == config::CrateTypeCdylib || ty == config::CrateTypeStaticlib ||
159-
(ty == config::CrateTypeExecutable && sess.crt_static() &&
158+
if ty == config::CrateType::Cdylib || ty == config::CrateType::Staticlib ||
159+
(ty == config::CrateType::Executable && sess.crt_static() &&
160160
!sess.target.target.options.crt_static_allows_dylibs) {
161161
for &cnum in tcx.crates().iter() {
162162
if tcx.dep_kind(cnum).macros_only() { continue }

src/librustc/middle/entry.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use hir::map as hir_map;
1313
use hir::def_id::{CRATE_DEF_INDEX};
1414
use session::{config, Session};
15+
use session::config::EntryFnType;
1516
use syntax::ast::NodeId;
1617
use syntax::attr;
1718
use syntax::entry::EntryPointType;
@@ -59,7 +60,7 @@ pub fn find_entry_point(session: &Session,
5960
hir_map: &hir_map::Map,
6061
crate_name: &str) {
6162
let any_exe = session.crate_types.borrow().iter().any(|ty| {
62-
*ty == config::CrateTypeExecutable
63+
*ty == config::CrateType::Executable
6364
});
6465
if !any_exe {
6566
// No need to find a main function
@@ -155,11 +156,11 @@ fn find_item(item: &Item, ctxt: &mut EntryContext, at_root: bool) {
155156

156157
fn configure_main(this: &mut EntryContext, crate_name: &str) {
157158
if let Some((node_id, span)) = this.start_fn {
158-
this.session.entry_fn.set(Some((node_id, span, config::EntryStart)));
159+
this.session.entry_fn.set(Some((node_id, span, EntryFnType::Start)));
159160
} else if let Some((node_id, span)) = this.attr_main_fn {
160-
this.session.entry_fn.set(Some((node_id, span, config::EntryMain)));
161+
this.session.entry_fn.set(Some((node_id, span, EntryFnType::Main)));
161162
} else if let Some((node_id, span)) = this.main_fn {
162-
this.session.entry_fn.set(Some((node_id, span, config::EntryMain)));
163+
this.session.entry_fn.set(Some((node_id, span, EntryFnType::Main)));
163164
} else {
164165
// No main function
165166
this.session.entry_fn.set(None);

src/librustc/middle/reachable.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,8 @@ fn reachable_set<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum) ->
408408
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
409409

410410
let any_library = tcx.sess.crate_types.borrow().iter().any(|ty| {
411-
*ty == config::CrateTypeRlib || *ty == config::CrateTypeDylib ||
412-
*ty == config::CrateTypeProcMacro
411+
*ty == config::CrateType::Rlib || *ty == config::CrateType::Dylib ||
412+
*ty == config::CrateType::ProcMacro
413413
});
414414
let mut reachable_context = ReachableContext {
415415
tcx,

src/librustc/middle/weak_lang_items.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ fn verify<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
8989
// emitting something that's not an rlib.
9090
let needs_check = tcx.sess.crate_types.borrow().iter().any(|kind| {
9191
match *kind {
92-
config::CrateTypeDylib |
93-
config::CrateTypeProcMacro |
94-
config::CrateTypeCdylib |
95-
config::CrateTypeExecutable |
96-
config::CrateTypeStaticlib => true,
97-
config::CrateTypeRlib => false,
92+
config::CrateType::Dylib |
93+
config::CrateType::ProcMacro |
94+
config::CrateType::Cdylib |
95+
config::CrateType::Executable |
96+
config::CrateType::Staticlib => true,
97+
config::CrateType::Rlib => false,
9898
}
9999
});
100100
if !needs_check {

0 commit comments

Comments
 (0)