about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2018-07-26 11:13:11 -0600
committerMark Rousskov <mark.simulacrum@gmail.com>2018-08-04 06:53:15 -0600
commit2a9344206be8ecd1cd2106bd93cccf46892fc2e5 (patch)
treec7f24f8ff8b1bbdf361f42b7a1697181a5efcea8 /src
parente59e02ef46c360eb6a2e2e30dd7cd10fc71e5e41 (diff)
downloadrust-2a9344206be8ecd1cd2106bd93cccf46892fc2e5.tar.gz
rust-2a9344206be8ecd1cd2106bd93cccf46892fc2e5.zip
Normalize variants of CrateType to standard style
This is a clippy-breaking change.
Diffstat (limited to 'src')
-rw-r--r--src/librustc/middle/dependency_format.rs20
-rw-r--r--src/librustc/middle/entry.rs2
-rw-r--r--src/librustc/middle/reachable.rs4
-rw-r--r--src/librustc/middle/weak_lang_items.rs12
-rw-r--r--src/librustc/session/config.rs41
-rw-r--r--src/librustc/ty/context.rs14
-rw-r--r--src/librustc_codegen_llvm/back/link.rs40
-rw-r--r--src/librustc_codegen_llvm/back/linker.rs4
-rw-r--r--src/librustc_codegen_llvm/back/lto.rs12
-rw-r--r--src/librustc_codegen_llvm/back/symbol_export.rs14
-rw-r--r--src/librustc_codegen_llvm/back/write.rs6
-rw-r--r--src/librustc_codegen_llvm/base.rs14
-rw-r--r--src/librustc_codegen_llvm/context.rs2
-rw-r--r--src/librustc_codegen_utils/codegen_backend.rs12
-rw-r--r--src/librustc_codegen_utils/link.rs28
-rw-r--r--src/librustc_driver/driver.rs18
-rw-r--r--src/librustc_metadata/creader.rs28
-rw-r--r--src/librustc_metadata/encoder.rs6
-rw-r--r--src/librustc_save_analysis/lib.rs4
-rw-r--r--src/librustdoc/core.rs2
-rw-r--r--src/librustdoc/test.rs4
-rw-r--r--src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs2
22 files changed, 144 insertions, 145 deletions
diff --git a/src/librustc/middle/dependency_format.rs b/src/librustc/middle/dependency_format.rs
index 4c99b46ddff..a9c118d606b 100644
--- a/src/librustc/middle/dependency_format.rs
+++ b/src/librustc/middle/dependency_format.rs
@@ -115,30 +115,30 @@ fn calculate_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 
     let preferred_linkage = match ty {
         // cdylibs must have all static dependencies.
-        config::CrateTypeCdylib => Linkage::Static,
+        config::CrateType::Cdylib => Linkage::Static,
 
         // Generating a dylib without `-C prefer-dynamic` means that we're going
         // to try to eagerly statically link all dependencies. This is normally
         // done for end-product dylibs, not intermediate products.
-        config::CrateTypeDylib if !sess.opts.cg.prefer_dynamic => Linkage::Static,
-        config::CrateTypeDylib => Linkage::Dynamic,
+        config::CrateType::Dylib if !sess.opts.cg.prefer_dynamic => Linkage::Static,
+        config::CrateType::Dylib => Linkage::Dynamic,
 
         // If the global prefer_dynamic switch is turned off, or the final
         // executable will be statically linked, prefer static crate linkage.
-        config::CrateTypeExecutable if !sess.opts.cg.prefer_dynamic ||
+        config::CrateType::Executable if !sess.opts.cg.prefer_dynamic ||
             sess.crt_static() => Linkage::Static,
-        config::CrateTypeExecutable => Linkage::Dynamic,
+        config::CrateType::Executable => Linkage::Dynamic,
 
         // proc-macro crates are required to be dylibs, and they're currently
         // required to link to libsyntax as well.
-        config::CrateTypeProcMacro => Linkage::Dynamic,
+        config::CrateType::ProcMacro => Linkage::Dynamic,
 
         // No linkage happens with rlibs, we just needed the metadata (which we
         // got long ago), so don't bother with anything.
-        config::CrateTypeRlib => Linkage::NotLinked,
+        config::CrateType::Rlib => Linkage::NotLinked,
 
         // staticlibs must have all static dependencies.
-        config::CrateTypeStaticlib => Linkage::Static,
+        config::CrateType::Staticlib => Linkage::Static,
     };
 
     if preferred_linkage == Linkage::NotLinked {
@@ -155,8 +155,8 @@ fn calculate_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 
         // Staticlibs, cdylibs, and static executables must have all static
         // dependencies. If any are not found, generate some nice pretty errors.
-        if ty == config::CrateTypeCdylib || ty == config::CrateTypeStaticlib ||
-                (ty == config::CrateTypeExecutable && sess.crt_static() &&
+        if ty == config::CrateType::Cdylib || ty == config::CrateType::Staticlib ||
+                (ty == config::CrateType::Executable && sess.crt_static() &&
                 !sess.target.target.options.crt_static_allows_dylibs) {
             for &cnum in tcx.crates().iter() {
                 if tcx.dep_kind(cnum).macros_only() { continue }
diff --git a/src/librustc/middle/entry.rs b/src/librustc/middle/entry.rs
index feeb508d676..9c2157aa2b3 100644
--- a/src/librustc/middle/entry.rs
+++ b/src/librustc/middle/entry.rs
@@ -59,7 +59,7 @@ pub fn find_entry_point(session: &Session,
                         hir_map: &hir_map::Map,
                         crate_name: &str) {
     let any_exe = session.crate_types.borrow().iter().any(|ty| {
-        *ty == config::CrateTypeExecutable
+        *ty == config::CrateType::Executable
     });
     if !any_exe {
         // No need to find a main function
diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs
index 19c82d7d27c..94246db3706 100644
--- a/src/librustc/middle/reachable.rs
+++ b/src/librustc/middle/reachable.rs
@@ -408,8 +408,8 @@ fn reachable_set<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum) ->
     let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
 
     let any_library = tcx.sess.crate_types.borrow().iter().any(|ty| {
-        *ty == config::CrateTypeRlib || *ty == config::CrateTypeDylib ||
-        *ty == config::CrateTypeProcMacro
+        *ty == config::CrateType::Rlib || *ty == config::CrateType::Dylib ||
+        *ty == config::CrateType::ProcMacro
     });
     let mut reachable_context = ReachableContext {
         tcx,
diff --git a/src/librustc/middle/weak_lang_items.rs b/src/librustc/middle/weak_lang_items.rs
index d8570b43fbe..e8431ce3e10 100644
--- a/src/librustc/middle/weak_lang_items.rs
+++ b/src/librustc/middle/weak_lang_items.rs
@@ -89,12 +89,12 @@ fn verify<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     // emitting something that's not an rlib.
     let needs_check = tcx.sess.crate_types.borrow().iter().any(|kind| {
         match *kind {
-            config::CrateTypeDylib |
-            config::CrateTypeProcMacro |
-            config::CrateTypeCdylib |
-            config::CrateTypeExecutable |
-            config::CrateTypeStaticlib => true,
-            config::CrateTypeRlib => false,
+            config::CrateType::Dylib |
+            config::CrateType::ProcMacro |
+            config::CrateType::Cdylib |
+            config::CrateType::Executable |
+            config::CrateType::Staticlib => true,
+            config::CrateType::Rlib => false,
         }
     });
     if !needs_check {
diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs
index dda4a2d2418..27fc5995d73 100644
--- a/src/librustc/session/config.rs
+++ b/src/librustc/session/config.rs
@@ -12,7 +12,6 @@
 //! command line options.
 
 pub use self::EntryFnType::*;
-pub use self::CrateType::*;
 pub use self::Passes::*;
 pub use self::DebugInfoLevel::*;
 
@@ -670,12 +669,12 @@ pub enum EntryFnType {
 
 #[derive(Copy, PartialEq, PartialOrd, Clone, Ord, Eq, Hash, Debug)]
 pub enum CrateType {
-    CrateTypeExecutable,
-    CrateTypeDylib,
-    CrateTypeRlib,
-    CrateTypeStaticlib,
-    CrateTypeCdylib,
-    CrateTypeProcMacro,
+    Executable,
+    Dylib,
+    Rlib,
+    Staticlib,
+    Cdylib,
+    ProcMacro,
 }
 
 #[derive(Clone, Hash)]
@@ -1374,7 +1373,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
 }
 
 pub fn default_lib_output() -> CrateType {
-    CrateTypeRlib
+    CrateType::Rlib
 }
 
 pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
@@ -1432,7 +1431,7 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
     if sess.opts.debug_assertions {
         ret.insert((Symbol::intern("debug_assertions"), None));
     }
-    if sess.opts.crate_types.contains(&CrateTypeProcMacro) {
+    if sess.opts.crate_types.contains(&CrateType::ProcMacro) {
         ret.insert((Symbol::intern("proc_macro"), None));
     }
     return ret;
@@ -2277,12 +2276,12 @@ pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateTy
         for part in unparsed_crate_type.split(',') {
             let new_part = match part {
                 "lib" => default_lib_output(),
-                "rlib" => CrateTypeRlib,
-                "staticlib" => CrateTypeStaticlib,
-                "dylib" => CrateTypeDylib,
-                "cdylib" => CrateTypeCdylib,
-                "bin" => CrateTypeExecutable,
-                "proc-macro" => CrateTypeProcMacro,
+                "rlib" => CrateType::Rlib,
+                "staticlib" => CrateType::Staticlib,
+                "dylib" => CrateType::Dylib,
+                "cdylib" => CrateType::Cdylib,
+                "bin" => CrateType::Executable,
+                "proc-macro" => CrateType::ProcMacro,
                 _ => {
                     return Err(format!("unknown crate type: `{}`", part));
                 }
@@ -2360,12 +2359,12 @@ pub mod nightly_options {
 impl fmt::Display for CrateType {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match *self {
-            CrateTypeExecutable => "bin".fmt(f),
-            CrateTypeDylib => "dylib".fmt(f),
-            CrateTypeRlib => "rlib".fmt(f),
-            CrateTypeStaticlib => "staticlib".fmt(f),
-            CrateTypeCdylib => "cdylib".fmt(f),
-            CrateTypeProcMacro => "proc-macro".fmt(f),
+            CrateType::Executable => "bin".fmt(f),
+            CrateType::Dylib => "dylib".fmt(f),
+            CrateType::Rlib => "rlib".fmt(f),
+            CrateType::Staticlib => "staticlib".fmt(f),
+            CrateType::Cdylib => "cdylib".fmt(f),
+            CrateType::ProcMacro => "proc-macro".fmt(f),
         }
     }
 }
diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs
index 89f3d7c30db..03a84021a0d 100644
--- a/src/librustc/ty/context.rs
+++ b/src/librustc/ty/context.rs
@@ -15,7 +15,7 @@ use dep_graph::{DepNode, DepConstructor};
 use errors::DiagnosticBuilder;
 use session::Session;
 use session::config::{BorrowckMode, OutputFilenames, OptLevel};
-use session::config::CrateType::*;
+use session::config::CrateType;
 use middle;
 use hir::{TraitCandidate, HirId, ItemLocalId};
 use hir::def::{Def, Export};
@@ -1493,12 +1493,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
 
         self.sess.crate_types.borrow().iter().any(|crate_type| {
             match crate_type {
-                CrateTypeExecutable |
-                CrateTypeStaticlib  |
-                CrateTypeProcMacro  |
-                CrateTypeCdylib     => false,
-                CrateTypeRlib       |
-                CrateTypeDylib      => true,
+                CrateType::Executable |
+                CrateType::Staticlib  |
+                CrateType::ProcMacro  |
+                CrateType::Cdylib     => false,
+                CrateType::Rlib       |
+                CrateType::Dylib      => true,
             }
         })
     }
diff --git a/src/librustc_codegen_llvm/back/link.rs b/src/librustc_codegen_llvm/back/link.rs
index 845a66c6e44..7cd2deabdeb 100644
--- a/src/librustc_codegen_llvm/back/link.rs
+++ b/src/librustc_codegen_llvm/back/link.rs
@@ -151,7 +151,7 @@ pub(crate) fn link_binary(sess: &Session,
         let output_metadata = sess.opts.output_types.contains_key(&OutputType::Metadata);
         if (sess.opts.debugging_opts.no_codegen || !sess.opts.output_types.should_codegen()) &&
            !output_metadata &&
-           crate_type == config::CrateTypeExecutable {
+           crate_type == config::CrateType::Executable {
             continue;
         }
 
@@ -208,7 +208,7 @@ fn preserve_objects_for_their_debuginfo(sess: &Session) -> bool {
     // the objects as they're losslessly contained inside the archives.
     let output_linked = sess.crate_types.borrow()
         .iter()
-        .any(|x| *x != config::CrateTypeRlib && *x != config::CrateTypeStaticlib);
+        .any(|x| *x != config::CrateType::Rlib && *x != config::CrateType::Staticlib);
     if !output_linked {
         return false
     }
@@ -255,10 +255,10 @@ pub(crate) fn each_linked_rlib(sess: &Session,
                                f: &mut dyn FnMut(CrateNum, &Path)) -> Result<(), String> {
     let crates = info.used_crates_static.iter();
     let fmts = sess.dependency_formats.borrow();
-    let fmts = fmts.get(&config::CrateTypeExecutable)
-                   .or_else(|| fmts.get(&config::CrateTypeStaticlib))
-                   .or_else(|| fmts.get(&config::CrateTypeCdylib))
-                   .or_else(|| fmts.get(&config::CrateTypeProcMacro));
+    let fmts = fmts.get(&config::CrateType::Executable)
+                   .or_else(|| fmts.get(&config::CrateType::Staticlib))
+                   .or_else(|| fmts.get(&config::CrateType::Cdylib))
+                   .or_else(|| fmts.get(&config::CrateType::ProcMacro));
     let fmts = match fmts {
         Some(f) => f,
         None => return Err("could not find formats for rlibs".to_string())
@@ -344,14 +344,14 @@ fn link_binary_output(sess: &Session,
     if outputs.outputs.should_codegen() {
         let out_filename = out_filename(sess, crate_type, outputs, crate_name);
         match crate_type {
-            config::CrateTypeRlib => {
+            config::CrateType::Rlib => {
                 link_rlib(sess,
                           codegen_results,
                           RlibFlavor::Normal,
                           &out_filename,
                           &tmpdir).build();
             }
-            config::CrateTypeStaticlib => {
+            config::CrateType::Staticlib => {
                 link_staticlib(sess, codegen_results, &out_filename, &tmpdir);
             }
             _ => {
@@ -644,7 +644,7 @@ fn link_natively(sess: &Session,
     }
     cmd.args(&sess.opts.debugging_opts.pre_link_arg);
 
-    let pre_link_objects = if crate_type == config::CrateTypeExecutable {
+    let pre_link_objects = if crate_type == config::CrateType::Executable {
         &sess.target.target.options.pre_link_objects_exe
     } else {
         &sess.target.target.options.pre_link_objects_dll
@@ -653,7 +653,7 @@ fn link_natively(sess: &Session,
         cmd.arg(root.join(obj));
     }
 
-    if crate_type == config::CrateTypeExecutable && sess.crt_static() {
+    if crate_type == config::CrateType::Executable && sess.crt_static() {
         for obj in &sess.target.target.options.pre_link_objects_exe_crt {
             cmd.arg(root.join(obj));
         }
@@ -1013,7 +1013,7 @@ fn link_args(cmd: &mut dyn Linker,
     }
     cmd.output_filename(out_filename);
 
-    if crate_type == config::CrateTypeExecutable &&
+    if crate_type == config::CrateType::Executable &&
        sess.target.target.options.is_like_windows {
         if let Some(ref s) = codegen_results.windows_subsystem {
             cmd.subsystem(s);
@@ -1022,7 +1022,7 @@ fn link_args(cmd: &mut dyn Linker,
 
     // If we're building a dynamic library then some platforms need to make sure
     // that all symbols are exported correctly from the dynamic library.
-    if crate_type != config::CrateTypeExecutable ||
+    if crate_type != config::CrateType::Executable ||
        sess.target.target.options.is_like_emscripten {
         cmd.export_symbols(tmpdir, crate_type);
     }
@@ -1030,8 +1030,8 @@ fn link_args(cmd: &mut dyn Linker,
     // When linking a dynamic library, we put the metadata into a section of the
     // executable. This metadata is in a separate object file from the main
     // object file, so we link that in here.
-    if crate_type == config::CrateTypeDylib ||
-       crate_type == config::CrateTypeProcMacro {
+    if crate_type == config::CrateType::Dylib ||
+       crate_type == config::CrateType::ProcMacro {
         if let Some(obj) = codegen_results.metadata_module.object.as_ref() {
             cmd.add_object(obj);
         }
@@ -1047,13 +1047,13 @@ fn link_args(cmd: &mut dyn Linker,
     // Try to strip as much out of the generated object by removing unused
     // sections if possible. See more comments in linker.rs
     if !sess.opts.cg.link_dead_code {
-        let keep_metadata = crate_type == config::CrateTypeDylib;
+        let keep_metadata = crate_type == config::CrateType::Dylib;
         cmd.gc_sections(keep_metadata);
     }
 
     let used_link_args = &codegen_results.crate_info.link_args;
 
-    if crate_type == config::CrateTypeExecutable {
+    if crate_type == config::CrateType::Executable {
         let mut position_independent_executable = false;
 
         if t.options.position_independent_executables {
@@ -1145,10 +1145,10 @@ fn link_args(cmd: &mut dyn Linker,
     add_upstream_native_libraries(cmd, sess, codegen_results, crate_type);
 
     // Tell the linker what we're doing.
-    if crate_type != config::CrateTypeExecutable {
+    if crate_type != config::CrateType::Executable {
         cmd.build_dylib(out_filename);
     }
-    if crate_type == config::CrateTypeExecutable && sess.crt_static() {
+    if crate_type == config::CrateType::Executable && sess.crt_static() {
         cmd.build_static_executable();
     }
 
@@ -1448,7 +1448,7 @@ fn add_upstream_rust_crates(cmd: &mut dyn Linker,
 
         if (!is_full_lto_enabled(sess) ||
             ignored_for_lto(sess, &codegen_results.crate_info, cnum)) &&
-           crate_type != config::CrateTypeDylib &&
+           crate_type != config::CrateType::Dylib &&
            !skip_native {
             cmd.link_rlib(&fix_windows_verbatim_for_gcc(cratepath));
             return
@@ -1524,7 +1524,7 @@ fn add_upstream_rust_crates(cmd: &mut dyn Linker,
             // Note, though, that we don't want to include the whole of a
             // compiler-builtins crate (e.g. compiler-rt) because it'll get
             // repeatedly linked anyway.
-            if crate_type == config::CrateTypeDylib &&
+            if crate_type == config::CrateType::Dylib &&
                 codegen_results.crate_info.compiler_builtins != Some(cnum) {
                 cmd.link_whole_rlib(&fix_windows_verbatim_for_gcc(&dst));
             } else {
diff --git a/src/librustc_codegen_llvm/back/linker.rs b/src/librustc_codegen_llvm/back/linker.rs
index 7253b5346b9..0383539e7c4 100644
--- a/src/librustc_codegen_llvm/back/linker.rs
+++ b/src/librustc_codegen_llvm/back/linker.rs
@@ -387,8 +387,8 @@ impl<'a> Linker for GccLinker<'a> {
         // exported symbols to ensure we don't expose any more. The object files
         // have far more public symbols than we actually want to export, so we
         // hide them all here.
-        if crate_type == CrateType::CrateTypeDylib ||
-           crate_type == CrateType::CrateTypeProcMacro {
+        if crate_type == CrateType::Dylib ||
+           crate_type == CrateType::ProcMacro {
             return
         }
 
diff --git a/src/librustc_codegen_llvm/back/lto.rs b/src/librustc_codegen_llvm/back/lto.rs
index b644422e795..098676c95a2 100644
--- a/src/librustc_codegen_llvm/back/lto.rs
+++ b/src/librustc_codegen_llvm/back/lto.rs
@@ -32,13 +32,13 @@ use std::sync::Arc;
 
 pub fn crate_type_allows_lto(crate_type: config::CrateType) -> bool {
     match crate_type {
-        config::CrateTypeExecutable |
-        config::CrateTypeStaticlib  |
-        config::CrateTypeCdylib     => true,
+        config::CrateType::Executable |
+        config::CrateType::Staticlib  |
+        config::CrateType::Cdylib     => true,
 
-        config::CrateTypeDylib     |
-        config::CrateTypeRlib      |
-        config::CrateTypeProcMacro => false,
+        config::CrateType::Dylib     |
+        config::CrateType::Rlib      |
+        config::CrateType::ProcMacro => false,
     }
 }
 
diff --git a/src/librustc_codegen_llvm/back/symbol_export.rs b/src/librustc_codegen_llvm/back/symbol_export.rs
index 48de2f3beed..5ce0d45a9bc 100644
--- a/src/librustc_codegen_llvm/back/symbol_export.rs
+++ b/src/librustc_codegen_llvm/back/symbol_export.rs
@@ -37,12 +37,12 @@ pub fn threshold(tcx: TyCtxt) -> SymbolExportLevel {
 
 fn crate_export_threshold(crate_type: config::CrateType) -> SymbolExportLevel {
     match crate_type {
-        config::CrateTypeExecutable |
-        config::CrateTypeStaticlib  |
-        config::CrateTypeProcMacro  |
-        config::CrateTypeCdylib     => SymbolExportLevel::C,
-        config::CrateTypeRlib       |
-        config::CrateTypeDylib      => SymbolExportLevel::Rust,
+        config::CrateType::Executable |
+        config::CrateType::Staticlib  |
+        config::CrateType::ProcMacro  |
+        config::CrateType::Cdylib     => SymbolExportLevel::C,
+        config::CrateType::Rlib       |
+        config::CrateType::Dylib      => SymbolExportLevel::Rust,
     }
 }
 
@@ -235,7 +235,7 @@ fn exported_symbols_provider_local<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
         }
     }
 
-    if tcx.sess.crate_types.borrow().contains(&config::CrateTypeDylib) {
+    if tcx.sess.crate_types.borrow().contains(&config::CrateType::Dylib) {
         let symbol_name = metadata_symbol_name(tcx);
         let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new(&symbol_name));
 
diff --git a/src/librustc_codegen_llvm/back/write.rs b/src/librustc_codegen_llvm/back/write.rs
index 209c3a23c5c..484d30ab7a5 100644
--- a/src/librustc_codegen_llvm/back/write.rs
+++ b/src/librustc_codegen_llvm/back/write.rs
@@ -875,7 +875,7 @@ pub(crate) struct CompiledModules {
 }
 
 fn need_crate_bitcode_for_rlib(sess: &Session) -> bool {
-    sess.crate_types.borrow().contains(&config::CrateTypeRlib) &&
+    sess.crate_types.borrow().contains(&config::CrateType::Rlib) &&
     sess.opts.output_types.contains_key(&OutputType::Exe)
 }
 
@@ -1341,7 +1341,7 @@ fn execute_work_item(cgcx: &CodegenContext,
                 // anything about it yet until we've got a final product.
                 Lto::Yes | Lto::Fat | Lto::Thin => {
                     cgcx.crate_types.len() != 1 ||
-                        cgcx.crate_types[0] != config::CrateTypeRlib
+                        cgcx.crate_types[0] != config::CrateType::Rlib
                 }
 
                 // When we're automatically doing ThinLTO for multi-codegen-unit
@@ -2346,7 +2346,7 @@ pub(crate) fn submit_codegened_module_to_llvm(tcx: TyCtxt,
 
 fn msvc_imps_needed(tcx: TyCtxt) -> bool {
     tcx.sess.target.target.options.is_like_msvc &&
-        tcx.sess.crate_types.borrow().iter().any(|ct| *ct == config::CrateTypeRlib)
+        tcx.sess.crate_types.borrow().iter().any(|ct| *ct == config::CrateType::Rlib)
 }
 
 // Create a `__imp_<symbol> = &symbol` global for every public static `symbol`.
diff --git a/src/librustc_codegen_llvm/base.rs b/src/librustc_codegen_llvm/base.rs
index 34cd3998f83..8fb3670e5ed 100644
--- a/src/librustc_codegen_llvm/base.rs
+++ b/src/librustc_codegen_llvm/base.rs
@@ -645,14 +645,14 @@ fn write_metadata<'a, 'gcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>,
 
     let kind = tcx.sess.crate_types.borrow().iter().map(|ty| {
         match *ty {
-            config::CrateTypeExecutable |
-            config::CrateTypeStaticlib |
-            config::CrateTypeCdylib => MetadataKind::None,
+            config::CrateType::Executable |
+            config::CrateType::Staticlib |
+            config::CrateType::Cdylib => MetadataKind::None,
 
-            config::CrateTypeRlib => MetadataKind::Uncompressed,
+            config::CrateType::Rlib => MetadataKind::Uncompressed,
 
-            config::CrateTypeDylib |
-            config::CrateTypeProcMacro => MetadataKind::Compressed,
+            config::CrateType::Dylib |
+            config::CrateType::ProcMacro => MetadataKind::Compressed,
         }
     }).max().unwrap_or(MetadataKind::None);
 
@@ -1102,7 +1102,7 @@ impl CrateInfo {
 
         let load_wasm_items = tcx.sess.crate_types.borrow()
             .iter()
-            .any(|c| *c != config::CrateTypeRlib) &&
+            .any(|c| *c != config::CrateType::Rlib) &&
             tcx.sess.opts.target_triple.triple() == "wasm32-unknown-unknown";
 
         if load_wasm_items {
diff --git a/src/librustc_codegen_llvm/context.rs b/src/librustc_codegen_llvm/context.rs
index 11f8e75831e..2832c114f51 100644
--- a/src/librustc_codegen_llvm/context.rs
+++ b/src/librustc_codegen_llvm/context.rs
@@ -147,7 +147,7 @@ fn get_tls_model(sess: &Session) -> llvm::ThreadLocalMode {
 
 fn is_any_library(sess: &Session) -> bool {
     sess.crate_types.borrow().iter().any(|ty| {
-        *ty != config::CrateTypeExecutable
+        *ty != config::CrateType::Executable
     })
 }
 
diff --git a/src/librustc_codegen_utils/codegen_backend.rs b/src/librustc_codegen_utils/codegen_backend.rs
index 3f230dd5d45..7e726f00b0b 100644
--- a/src/librustc_codegen_utils/codegen_backend.rs
+++ b/src/librustc_codegen_utils/codegen_backend.rs
@@ -114,8 +114,7 @@ impl CodegenBackend for MetadataOnlyCodegenBackend {
     fn init(&self, sess: &Session) {
         for cty in sess.opts.crate_types.iter() {
             match *cty {
-                CrateType::CrateTypeRlib | CrateType::CrateTypeDylib |
-                CrateType::CrateTypeExecutable => {},
+                CrateType::Rlib | CrateType::Dylib | CrateType::Executable => {},
                 _ => {
                     sess.parse_sess.span_diagnostic.warn(
                         &format!("LLVM unsupported, so output type {} is not supported", cty)
@@ -201,13 +200,14 @@ impl CodegenBackend for MetadataOnlyCodegenBackend {
         let ongoing_codegen = ongoing_codegen.downcast::<OngoingCodegen>()
             .expect("Expected MetadataOnlyCodegenBackend's OngoingCodegen, found Box<dyn Any>");
         for &crate_type in sess.opts.crate_types.iter() {
-            if crate_type != CrateType::CrateTypeRlib && crate_type != CrateType::CrateTypeDylib {
+            if crate_type != CrateType::Rlib &&
+               crate_type != CrateType::Dylib {
                 continue;
             }
             let output_name =
                 out_filename(sess, crate_type, &outputs, &ongoing_codegen.crate_name.as_str());
             let mut compressed = ongoing_codegen.metadata_version.clone();
-            let metadata = if crate_type == CrateType::CrateTypeDylib {
+            let metadata = if crate_type == CrateType::Dylib {
                 DeflateEncoder::new(&mut compressed, Compression::fast())
                     .write_all(&ongoing_codegen.metadata.raw_data)
                     .unwrap();
@@ -220,8 +220,8 @@ impl CodegenBackend for MetadataOnlyCodegenBackend {
         }
 
         sess.abort_if_errors();
-        if !sess.opts.crate_types.contains(&CrateType::CrateTypeRlib)
-            && !sess.opts.crate_types.contains(&CrateType::CrateTypeDylib)
+        if !sess.opts.crate_types.contains(&CrateType::Rlib)
+            && !sess.opts.crate_types.contains(&CrateType::Dylib)
         {
             sess.fatal("Executables are not supported by the metadata-only backend.");
         }
diff --git a/src/librustc_codegen_utils/link.rs b/src/librustc_codegen_utils/link.rs
index b33482eb868..73cffdf7d49 100644
--- a/src/librustc_codegen_utils/link.rs
+++ b/src/librustc_codegen_utils/link.rs
@@ -114,24 +114,24 @@ pub fn filename_for_input(sess: &Session,
     let libname = format!("{}{}", crate_name, sess.opts.cg.extra_filename);
 
     match crate_type {
-        config::CrateTypeRlib => {
+        config::CrateType::Rlib => {
             outputs.out_directory.join(&format!("lib{}.rlib", libname))
         }
-        config::CrateTypeCdylib |
-        config::CrateTypeProcMacro |
-        config::CrateTypeDylib => {
+        config::CrateType::Cdylib |
+        config::CrateType::ProcMacro |
+        config::CrateType::Dylib => {
             let (prefix, suffix) = (&sess.target.target.options.dll_prefix,
                                     &sess.target.target.options.dll_suffix);
             outputs.out_directory.join(&format!("{}{}{}", prefix, libname,
                                                 suffix))
         }
-        config::CrateTypeStaticlib => {
+        config::CrateType::Staticlib => {
             let (prefix, suffix) = (&sess.target.target.options.staticlib_prefix,
                                     &sess.target.target.options.staticlib_suffix);
             outputs.out_directory.join(&format!("{}{}{}", prefix, libname,
                                                 suffix))
         }
-        config::CrateTypeExecutable => {
+        config::CrateType::Executable => {
             let suffix = &sess.target.target.options.exe_suffix;
             let out_filename = outputs.path(OutputType::Exe);
             if suffix.is_empty() {
@@ -148,15 +148,15 @@ pub fn filename_for_input(sess: &Session,
 /// Default crate type is used when crate type isn't provided neither
 /// through cmd line arguments nor through crate attributes
 ///
-/// It is CrateTypeExecutable for all platforms but iOS as there is no
+/// It is CrateType::Executable for all platforms but iOS as there is no
 /// way to run iOS binaries anyway without jailbreaking and
 /// interaction with Rust code through static library is the only
 /// option for now
 pub fn default_output_for_target(sess: &Session) -> config::CrateType {
     if !sess.target.target.options.executables {
-        config::CrateTypeStaticlib
+        config::CrateType::Staticlib
     } else {
-        config::CrateTypeExecutable
+        config::CrateType::Executable
     }
 }
 
@@ -164,9 +164,9 @@ pub fn default_output_for_target(sess: &Session) -> config::CrateType {
 pub fn invalid_output_for_target(sess: &Session,
                                  crate_type: config::CrateType) -> bool {
     match crate_type {
-        config::CrateTypeCdylib |
-        config::CrateTypeDylib |
-        config::CrateTypeProcMacro => {
+        config::CrateType::Cdylib |
+        config::CrateType::Dylib |
+        config::CrateType::ProcMacro => {
             if !sess.target.target.options.dynamic_linking {
                 return true
             }
@@ -178,12 +178,12 @@ pub fn invalid_output_for_target(sess: &Session,
     }
     if sess.target.target.options.only_cdylib {
         match crate_type {
-            config::CrateTypeProcMacro | config::CrateTypeDylib => return true,
+            config::CrateType::ProcMacro | config::CrateType::Dylib => return true,
             _ => {}
         }
     }
     if !sess.target.target.options.executables {
-        if crate_type == config::CrateTypeExecutable {
+        if crate_type == config::CrateType::Executable {
             return true
         }
     }
diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs
index 2c877e27e2e..27b747c633c 100644
--- a/src/librustc_driver/driver.rs
+++ b/src/librustc_driver/driver.rs
@@ -1058,7 +1058,7 @@ where
         krate = time(sess, "maybe creating a macro crate", || {
             let crate_types = sess.crate_types.borrow();
             let num_crate_types = crate_types.len();
-            let is_proc_macro_crate = crate_types.contains(&config::CrateTypeProcMacro);
+            let is_proc_macro_crate = crate_types.contains(&config::CrateType::ProcMacro);
             let is_test_crate = sess.opts.test;
             syntax_ext::proc_macro_registrar::modify(
                 &sess.parse_sess,
@@ -1501,13 +1501,13 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<c
         .filter_map(|a| {
             if a.check_name("crate_type") {
                 match a.value_str() {
-                    Some(ref n) if *n == "rlib" => Some(config::CrateTypeRlib),
-                    Some(ref n) if *n == "dylib" => Some(config::CrateTypeDylib),
-                    Some(ref n) if *n == "cdylib" => Some(config::CrateTypeCdylib),
+                    Some(ref n) if *n == "rlib" => Some(config::CrateType::Rlib),
+                    Some(ref n) if *n == "dylib" => Some(config::CrateType::Dylib),
+                    Some(ref n) if *n == "cdylib" => Some(config::CrateType::Cdylib),
                     Some(ref n) if *n == "lib" => Some(config::default_lib_output()),
-                    Some(ref n) if *n == "staticlib" => Some(config::CrateTypeStaticlib),
-                    Some(ref n) if *n == "proc-macro" => Some(config::CrateTypeProcMacro),
-                    Some(ref n) if *n == "bin" => Some(config::CrateTypeExecutable),
+                    Some(ref n) if *n == "staticlib" => Some(config::CrateType::Staticlib),
+                    Some(ref n) if *n == "proc-macro" => Some(config::CrateType::ProcMacro),
+                    Some(ref n) if *n == "bin" => Some(config::CrateType::Executable),
                     Some(_) => {
                         session.buffer_lint(
                             lint::builtin::UNKNOWN_CRATE_TYPES,
@@ -1534,7 +1534,7 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<c
     // If we're generating a test executable, then ignore all other output
     // styles at all other locations
     if session.opts.test {
-        return vec![config::CrateTypeExecutable];
+        return vec![config::CrateType::Executable];
     }
 
     // Only check command line flags if present. If no types are specified by
@@ -1598,7 +1598,7 @@ pub fn compute_crate_disambiguator(session: &Session) -> CrateDisambiguator {
     let is_exe = session
         .crate_types
         .borrow()
-        .contains(&config::CrateTypeExecutable);
+        .contains(&config::CrateType::Executable);
     hasher.write(if is_exe { b"exe" } else { b"lib" });
 
     CrateDisambiguator::from(hasher.finish())
diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs
index b5b47fb35dc..62c06aac1df 100644
--- a/src/librustc_metadata/creader.rs
+++ b/src/librustc_metadata/creader.rs
@@ -627,7 +627,7 @@ impl<'a> CrateLoader<'a> {
         // If we're only compiling an rlib, then there's no need to select a
         // panic runtime, so we just skip this section entirely.
         let any_non_rlib = self.sess.crate_types.borrow().iter().any(|ct| {
-            *ct != config::CrateTypeRlib
+            *ct != config::CrateType::Rlib
         });
         if !any_non_rlib {
             info!("panic runtime injection skipped, only generating rlib");
@@ -738,13 +738,13 @@ impl<'a> CrateLoader<'a> {
                 if !self.sess.crate_types.borrow().iter().all(|ct| {
                     match *ct {
                         // Link the runtime
-                        config::CrateTypeStaticlib |
-                        config::CrateTypeExecutable => true,
+                        config::CrateType::Staticlib |
+                        config::CrateType::Executable => true,
                         // This crate will be compiled with the required
                         // instrumentation pass
-                        config::CrateTypeRlib |
-                        config::CrateTypeDylib |
-                        config::CrateTypeCdylib =>
+                        config::CrateType::Rlib |
+                        config::CrateType::Dylib |
+                        config::CrateType::Cdylib =>
                             false,
                         _ => {
                             self.sess.err(&format!("Only executables, staticlibs, \
@@ -760,10 +760,10 @@ impl<'a> CrateLoader<'a> {
                 if !self.sess.crate_types.borrow().iter().all(|ct| {
                     match *ct {
                         // Link the runtime
-                        config::CrateTypeExecutable => true,
+                        config::CrateType::Executable => true,
                         // This crate will be compiled with the required
                         // instrumentation pass
-                        config::CrateTypeRlib => false,
+                        config::CrateType::Rlib => false,
                         _ => {
                             self.sess.err(&format!("Only executables and rlibs can be \
                                                     compiled with `-Z sanitizer`"));
@@ -853,12 +853,12 @@ impl<'a> CrateLoader<'a> {
         let mut need_exe_alloc = false;
         for ct in self.sess.crate_types.borrow().iter() {
             match *ct {
-                config::CrateTypeExecutable => need_exe_alloc = true,
-                config::CrateTypeDylib |
-                config::CrateTypeProcMacro |
-                config::CrateTypeCdylib |
-                config::CrateTypeStaticlib => need_lib_alloc = true,
-                config::CrateTypeRlib => {}
+                config::CrateType::Executable => need_exe_alloc = true,
+                config::CrateType::Dylib |
+                config::CrateType::ProcMacro |
+                config::CrateType::Cdylib |
+                config::CrateType::Staticlib => need_lib_alloc = true,
+                config::CrateType::Rlib => {}
             }
         }
         if !need_lib_alloc && !need_exe_alloc {
diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs
index 7ed991e0de3..4a02a278bc1 100644
--- a/src/librustc_metadata/encoder.rs
+++ b/src/librustc_metadata/encoder.rs
@@ -28,7 +28,7 @@ use rustc::traits::specialization_graph;
 use rustc::ty::{self, Ty, TyCtxt, ReprOptions, SymbolName};
 use rustc::ty::codec::{self as ty_codec, TyEncoder};
 
-use rustc::session::config::{self, CrateTypeProcMacro};
+use rustc::session::config::{self, CrateType};
 use rustc::util::nodemap::FxHashMap;
 
 use rustc_data_structures::stable_hasher::StableHasher;
@@ -478,7 +478,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
 
         let attrs = tcx.hir.krate_attrs();
         let link_meta = self.link_meta;
-        let is_proc_macro = tcx.sess.crate_types.borrow().contains(&CrateTypeProcMacro);
+        let is_proc_macro = tcx.sess.crate_types.borrow().contains(&CrateType::ProcMacro);
         let has_default_lib_allocator = attr::contains_name(&attrs, "default_lib_allocator");
         let has_global_allocator = *tcx.sess.has_global_allocator.get();
 
@@ -1542,7 +1542,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
     }
 
     fn encode_dylib_dependency_formats(&mut self, _: ()) -> LazySeq<Option<LinkagePreference>> {
-        match self.tcx.sess.dependency_formats.borrow().get(&config::CrateTypeDylib) {
+        match self.tcx.sess.dependency_formats.borrow().get(&config::CrateType::Dylib) {
             Some(arr) => {
                 self.lazy_seq(arr.iter().map(|slot| {
                     match *slot {
diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs
index 240b33c3c94..6e49951ff29 100644
--- a/src/librustc_save_analysis/lib.rs
+++ b/src/librustc_save_analysis/lib.rs
@@ -44,7 +44,7 @@ use rustc::hir::def::Def as HirDef;
 use rustc::hir::map::{Node, NodeTraitItem, NodeImplItem};
 use rustc::hir::def_id::{DefId, LOCAL_CRATE};
 use rustc::middle::cstore::ExternCrate;
-use rustc::session::config::CrateType::CrateTypeExecutable;
+use rustc::session::config::CrateType;
 use rustc::ty::{self, TyCtxt};
 use rustc_typeck::hir_ty_to_ty;
 
@@ -1048,7 +1048,7 @@ impl<'a> DumpHandler<'a> {
                 let executable = sess.crate_types
                     .borrow()
                     .iter()
-                    .any(|ct| *ct == CrateTypeExecutable);
+                    .any(|ct| *ct == CrateType::Executable);
                 let mut out_name = if executable {
                     "".to_owned()
                 } else {
diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs
index 84741f12ad1..b4b573fcb3d 100644
--- a/src/librustdoc/core.rs
+++ b/src/librustdoc/core.rs
@@ -223,7 +223,7 @@ pub fn run_core(search_paths: SearchPaths,
     let sessopts = config::Options {
         maybe_sysroot,
         search_paths,
-        crate_types: vec![config::CrateTypeRlib],
+        crate_types: vec![config::CrateType::Rlib],
         lint_opts: if !allow_warnings {
             lints
         } else {
diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs
index 650a2408aa6..401d0d193a1 100644
--- a/src/librustdoc/test.rs
+++ b/src/librustdoc/test.rs
@@ -73,7 +73,7 @@ pub fn run(input_path: &Path,
         maybe_sysroot: maybe_sysroot.clone().or_else(
             || Some(env::current_exe().unwrap().parent().unwrap().parent().unwrap().to_path_buf())),
         search_paths: libs.clone(),
-        crate_types: vec![config::CrateTypeDylib],
+        crate_types: vec![config::CrateType::Dylib],
         cg: cg.clone(),
         externs: externs.clone(),
         unstable_features: UnstableFeatures::from_environment(),
@@ -216,7 +216,7 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize,
         maybe_sysroot: maybe_sysroot.or_else(
             || Some(env::current_exe().unwrap().parent().unwrap().parent().unwrap().to_path_buf())),
         search_paths: libs,
-        crate_types: vec![config::CrateTypeExecutable],
+        crate_types: vec![config::CrateType::Executable],
         output_types: outputs,
         externs,
         cg: config::CodegenOptions {
diff --git a/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs b/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs
index a3cd033f863..87d2026fe2d 100644
--- a/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs
+++ b/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs
@@ -63,7 +63,7 @@ impl CodegenBackend for TheBackend {
         let crate_name = ongoing_codegen.downcast::<Symbol>()
             .expect("in join_codegen_and_link: ongoing_codegen is not a Symbol");
         for &crate_type in sess.opts.crate_types.iter() {
-            if crate_type != CrateType::CrateTypeRlib {
+            if crate_type != CrateType::Rlib {
                 sess.fatal(&format!("Crate type is {:?}", crate_type));
             }
             let output_name =