Skip to content

Commit 2a93442

Browse files
Normalize variants of CrateType to standard style
This is a clippy-breaking change.
1 parent e59e02e commit 2a93442

File tree

22 files changed

+144
-145
lines changed

22 files changed

+144
-145
lines changed

src/librustc/middle/dependency_format.rs

Lines changed: 10 additions & 10 deletions
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub fn find_entry_point(session: &Session,
5959
hir_map: &hir_map::Map,
6060
crate_name: &str) {
6161
let any_exe = session.crate_types.borrow().iter().any(|ty| {
62-
*ty == config::CrateTypeExecutable
62+
*ty == config::CrateType::Executable
6363
});
6464
if !any_exe {
6565
// No need to find a main function

src/librustc/middle/reachable.rs

Lines changed: 2 additions & 2 deletions
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

Lines changed: 6 additions & 6 deletions
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 {

src/librustc/session/config.rs

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
//! command line options.
1313
1414
pub use self::EntryFnType::*;
15-
pub use self::CrateType::*;
1615
pub use self::Passes::*;
1716
pub use self::DebugInfoLevel::*;
1817

@@ -670,12 +669,12 @@ pub enum EntryFnType {
670669

671670
#[derive(Copy, PartialEq, PartialOrd, Clone, Ord, Eq, Hash, Debug)]
672671
pub enum CrateType {
673-
CrateTypeExecutable,
674-
CrateTypeDylib,
675-
CrateTypeRlib,
676-
CrateTypeStaticlib,
677-
CrateTypeCdylib,
678-
CrateTypeProcMacro,
672+
Executable,
673+
Dylib,
674+
Rlib,
675+
Staticlib,
676+
Cdylib,
677+
ProcMacro,
679678
}
680679

681680
#[derive(Clone, Hash)]
@@ -1374,7 +1373,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
13741373
}
13751374

13761375
pub fn default_lib_output() -> CrateType {
1377-
CrateTypeRlib
1376+
CrateType::Rlib
13781377
}
13791378

13801379
pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
@@ -1432,7 +1431,7 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
14321431
if sess.opts.debug_assertions {
14331432
ret.insert((Symbol::intern("debug_assertions"), None));
14341433
}
1435-
if sess.opts.crate_types.contains(&CrateTypeProcMacro) {
1434+
if sess.opts.crate_types.contains(&CrateType::ProcMacro) {
14361435
ret.insert((Symbol::intern("proc_macro"), None));
14371436
}
14381437
return ret;
@@ -2277,12 +2276,12 @@ pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateTy
22772276
for part in unparsed_crate_type.split(',') {
22782277
let new_part = match part {
22792278
"lib" => default_lib_output(),
2280-
"rlib" => CrateTypeRlib,
2281-
"staticlib" => CrateTypeStaticlib,
2282-
"dylib" => CrateTypeDylib,
2283-
"cdylib" => CrateTypeCdylib,
2284-
"bin" => CrateTypeExecutable,
2285-
"proc-macro" => CrateTypeProcMacro,
2279+
"rlib" => CrateType::Rlib,
2280+
"staticlib" => CrateType::Staticlib,
2281+
"dylib" => CrateType::Dylib,
2282+
"cdylib" => CrateType::Cdylib,
2283+
"bin" => CrateType::Executable,
2284+
"proc-macro" => CrateType::ProcMacro,
22862285
_ => {
22872286
return Err(format!("unknown crate type: `{}`", part));
22882287
}
@@ -2360,12 +2359,12 @@ pub mod nightly_options {
23602359
impl fmt::Display for CrateType {
23612360
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
23622361
match *self {
2363-
CrateTypeExecutable => "bin".fmt(f),
2364-
CrateTypeDylib => "dylib".fmt(f),
2365-
CrateTypeRlib => "rlib".fmt(f),
2366-
CrateTypeStaticlib => "staticlib".fmt(f),
2367-
CrateTypeCdylib => "cdylib".fmt(f),
2368-
CrateTypeProcMacro => "proc-macro".fmt(f),
2362+
CrateType::Executable => "bin".fmt(f),
2363+
CrateType::Dylib => "dylib".fmt(f),
2364+
CrateType::Rlib => "rlib".fmt(f),
2365+
CrateType::Staticlib => "staticlib".fmt(f),
2366+
CrateType::Cdylib => "cdylib".fmt(f),
2367+
CrateType::ProcMacro => "proc-macro".fmt(f),
23692368
}
23702369
}
23712370
}

src/librustc/ty/context.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use dep_graph::{DepNode, DepConstructor};
1515
use errors::DiagnosticBuilder;
1616
use session::Session;
1717
use session::config::{BorrowckMode, OutputFilenames, OptLevel};
18-
use session::config::CrateType::*;
18+
use session::config::CrateType;
1919
use middle;
2020
use hir::{TraitCandidate, HirId, ItemLocalId};
2121
use hir::def::{Def, Export};
@@ -1493,12 +1493,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
14931493

14941494
self.sess.crate_types.borrow().iter().any(|crate_type| {
14951495
match crate_type {
1496-
CrateTypeExecutable |
1497-
CrateTypeStaticlib |
1498-
CrateTypeProcMacro |
1499-
CrateTypeCdylib => false,
1500-
CrateTypeRlib |
1501-
CrateTypeDylib => true,
1496+
CrateType::Executable |
1497+
CrateType::Staticlib |
1498+
CrateType::ProcMacro |
1499+
CrateType::Cdylib => false,
1500+
CrateType::Rlib |
1501+
CrateType::Dylib => true,
15021502
}
15031503
})
15041504
}

src/librustc_codegen_llvm/back/link.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ pub(crate) fn link_binary(sess: &Session,
151151
let output_metadata = sess.opts.output_types.contains_key(&OutputType::Metadata);
152152
if (sess.opts.debugging_opts.no_codegen || !sess.opts.output_types.should_codegen()) &&
153153
!output_metadata &&
154-
crate_type == config::CrateTypeExecutable {
154+
crate_type == config::CrateType::Executable {
155155
continue;
156156
}
157157

@@ -208,7 +208,7 @@ fn preserve_objects_for_their_debuginfo(sess: &Session) -> bool {
208208
// the objects as they're losslessly contained inside the archives.
209209
let output_linked = sess.crate_types.borrow()
210210
.iter()
211-
.any(|x| *x != config::CrateTypeRlib && *x != config::CrateTypeStaticlib);
211+
.any(|x| *x != config::CrateType::Rlib && *x != config::CrateType::Staticlib);
212212
if !output_linked {
213213
return false
214214
}
@@ -255,10 +255,10 @@ pub(crate) fn each_linked_rlib(sess: &Session,
255255
f: &mut dyn FnMut(CrateNum, &Path)) -> Result<(), String> {
256256
let crates = info.used_crates_static.iter();
257257
let fmts = sess.dependency_formats.borrow();
258-
let fmts = fmts.get(&config::CrateTypeExecutable)
259-
.or_else(|| fmts.get(&config::CrateTypeStaticlib))
260-
.or_else(|| fmts.get(&config::CrateTypeCdylib))
261-
.or_else(|| fmts.get(&config::CrateTypeProcMacro));
258+
let fmts = fmts.get(&config::CrateType::Executable)
259+
.or_else(|| fmts.get(&config::CrateType::Staticlib))
260+
.or_else(|| fmts.get(&config::CrateType::Cdylib))
261+
.or_else(|| fmts.get(&config::CrateType::ProcMacro));
262262
let fmts = match fmts {
263263
Some(f) => f,
264264
None => return Err("could not find formats for rlibs".to_string())
@@ -344,14 +344,14 @@ fn link_binary_output(sess: &Session,
344344
if outputs.outputs.should_codegen() {
345345
let out_filename = out_filename(sess, crate_type, outputs, crate_name);
346346
match crate_type {
347-
config::CrateTypeRlib => {
347+
config::CrateType::Rlib => {
348348
link_rlib(sess,
349349
codegen_results,
350350
RlibFlavor::Normal,
351351
&out_filename,
352352
&tmpdir).build();
353353
}
354-
config::CrateTypeStaticlib => {
354+
config::CrateType::Staticlib => {
355355
link_staticlib(sess, codegen_results, &out_filename, &tmpdir);
356356
}
357357
_ => {
@@ -644,7 +644,7 @@ fn link_natively(sess: &Session,
644644
}
645645
cmd.args(&sess.opts.debugging_opts.pre_link_arg);
646646

647-
let pre_link_objects = if crate_type == config::CrateTypeExecutable {
647+
let pre_link_objects = if crate_type == config::CrateType::Executable {
648648
&sess.target.target.options.pre_link_objects_exe
649649
} else {
650650
&sess.target.target.options.pre_link_objects_dll
@@ -653,7 +653,7 @@ fn link_natively(sess: &Session,
653653
cmd.arg(root.join(obj));
654654
}
655655

656-
if crate_type == config::CrateTypeExecutable && sess.crt_static() {
656+
if crate_type == config::CrateType::Executable && sess.crt_static() {
657657
for obj in &sess.target.target.options.pre_link_objects_exe_crt {
658658
cmd.arg(root.join(obj));
659659
}
@@ -1013,7 +1013,7 @@ fn link_args(cmd: &mut dyn Linker,
10131013
}
10141014
cmd.output_filename(out_filename);
10151015

1016-
if crate_type == config::CrateTypeExecutable &&
1016+
if crate_type == config::CrateType::Executable &&
10171017
sess.target.target.options.is_like_windows {
10181018
if let Some(ref s) = codegen_results.windows_subsystem {
10191019
cmd.subsystem(s);
@@ -1022,16 +1022,16 @@ fn link_args(cmd: &mut dyn Linker,
10221022

10231023
// If we're building a dynamic library then some platforms need to make sure
10241024
// that all symbols are exported correctly from the dynamic library.
1025-
if crate_type != config::CrateTypeExecutable ||
1025+
if crate_type != config::CrateType::Executable ||
10261026
sess.target.target.options.is_like_emscripten {
10271027
cmd.export_symbols(tmpdir, crate_type);
10281028
}
10291029

10301030
// When linking a dynamic library, we put the metadata into a section of the
10311031
// executable. This metadata is in a separate object file from the main
10321032
// object file, so we link that in here.
1033-
if crate_type == config::CrateTypeDylib ||
1034-
crate_type == config::CrateTypeProcMacro {
1033+
if crate_type == config::CrateType::Dylib ||
1034+
crate_type == config::CrateType::ProcMacro {
10351035
if let Some(obj) = codegen_results.metadata_module.object.as_ref() {
10361036
cmd.add_object(obj);
10371037
}
@@ -1047,13 +1047,13 @@ fn link_args(cmd: &mut dyn Linker,
10471047
// Try to strip as much out of the generated object by removing unused
10481048
// sections if possible. See more comments in linker.rs
10491049
if !sess.opts.cg.link_dead_code {
1050-
let keep_metadata = crate_type == config::CrateTypeDylib;
1050+
let keep_metadata = crate_type == config::CrateType::Dylib;
10511051
cmd.gc_sections(keep_metadata);
10521052
}
10531053

10541054
let used_link_args = &codegen_results.crate_info.link_args;
10551055

1056-
if crate_type == config::CrateTypeExecutable {
1056+
if crate_type == config::CrateType::Executable {
10571057
let mut position_independent_executable = false;
10581058

10591059
if t.options.position_independent_executables {
@@ -1145,10 +1145,10 @@ fn link_args(cmd: &mut dyn Linker,
11451145
add_upstream_native_libraries(cmd, sess, codegen_results, crate_type);
11461146

11471147
// Tell the linker what we're doing.
1148-
if crate_type != config::CrateTypeExecutable {
1148+
if crate_type != config::CrateType::Executable {
11491149
cmd.build_dylib(out_filename);
11501150
}
1151-
if crate_type == config::CrateTypeExecutable && sess.crt_static() {
1151+
if crate_type == config::CrateType::Executable && sess.crt_static() {
11521152
cmd.build_static_executable();
11531153
}
11541154

@@ -1448,7 +1448,7 @@ fn add_upstream_rust_crates(cmd: &mut dyn Linker,
14481448

14491449
if (!is_full_lto_enabled(sess) ||
14501450
ignored_for_lto(sess, &codegen_results.crate_info, cnum)) &&
1451-
crate_type != config::CrateTypeDylib &&
1451+
crate_type != config::CrateType::Dylib &&
14521452
!skip_native {
14531453
cmd.link_rlib(&fix_windows_verbatim_for_gcc(cratepath));
14541454
return
@@ -1524,7 +1524,7 @@ fn add_upstream_rust_crates(cmd: &mut dyn Linker,
15241524
// Note, though, that we don't want to include the whole of a
15251525
// compiler-builtins crate (e.g. compiler-rt) because it'll get
15261526
// repeatedly linked anyway.
1527-
if crate_type == config::CrateTypeDylib &&
1527+
if crate_type == config::CrateType::Dylib &&
15281528
codegen_results.crate_info.compiler_builtins != Some(cnum) {
15291529
cmd.link_whole_rlib(&fix_windows_verbatim_for_gcc(&dst));
15301530
} else {

src/librustc_codegen_llvm/back/linker.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,8 @@ impl<'a> Linker for GccLinker<'a> {
387387
// exported symbols to ensure we don't expose any more. The object files
388388
// have far more public symbols than we actually want to export, so we
389389
// hide them all here.
390-
if crate_type == CrateType::CrateTypeDylib ||
391-
crate_type == CrateType::CrateTypeProcMacro {
390+
if crate_type == CrateType::Dylib ||
391+
crate_type == CrateType::ProcMacro {
392392
return
393393
}
394394

src/librustc_codegen_llvm/back/lto.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ use std::sync::Arc;
3232

3333
pub fn crate_type_allows_lto(crate_type: config::CrateType) -> bool {
3434
match crate_type {
35-
config::CrateTypeExecutable |
36-
config::CrateTypeStaticlib |
37-
config::CrateTypeCdylib => true,
35+
config::CrateType::Executable |
36+
config::CrateType::Staticlib |
37+
config::CrateType::Cdylib => true,
3838

39-
config::CrateTypeDylib |
40-
config::CrateTypeRlib |
41-
config::CrateTypeProcMacro => false,
39+
config::CrateType::Dylib |
40+
config::CrateType::Rlib |
41+
config::CrateType::ProcMacro => false,
4242
}
4343
}
4444

0 commit comments

Comments
 (0)