]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_codegen_ssa/lib.rs
Rollup merge of #68050 - Centril:canon-error, r=Mark-Simulacrum
[rust.git] / src / librustc_codegen_ssa / lib.rs
index 9919666027a2116c101fac344efc1dbccd44da06..a8d051db8b4780648f6212ff560b72002f3f0896 100644 (file)
@@ -1,5 +1,4 @@
 #![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
-
 #![feature(bool_to_option)]
 #![feature(box_patterns)]
 #![feature(box_syntax)]
 #![feature(nll)]
 #![feature(trusted_len)]
 #![feature(associated_type_bounds)]
-
-#![recursion_limit="256"]
+#![recursion_limit = "256"]
 
 //! This crate contains codegen code that is used by all codegen backends (LLVM and others).
 //! The backend-agnostic functions of this crate use functions defined in various traits that
 //! have to be implemented by each backends.
 
-#[macro_use] extern crate log;
-#[macro_use] extern crate rustc;
-#[macro_use] extern crate syntax;
+#[macro_use]
+extern crate log;
+#[macro_use]
+extern crate rustc;
 
-use std::path::{Path, PathBuf};
 use rustc::dep_graph::WorkProduct;
-use rustc::session::config::{OutputFilenames, OutputType, RUST_CGU_EXT};
+use rustc::middle::cstore::{CrateSource, LibSource, NativeLibrary};
+use rustc::middle::dependency_format::Dependencies;
 use rustc::middle::lang_items::LangItem;
-use rustc::hir::def_id::CrateNum;
+use rustc::session::config::{OutputFilenames, OutputType, RUST_CGU_EXT};
 use rustc::ty::query::Providers;
 use rustc_data_structures::fx::{FxHashMap, FxHashSet};
-use rustc_data_structures::sync::Lrc;
 use rustc_data_structures::svh::Svh;
-use rustc::middle::cstore::{LibSource, CrateSource, NativeLibrary};
-use rustc::middle::dependency_format::Dependencies;
-use syntax_pos::symbol::Symbol;
+use rustc_data_structures::sync::Lrc;
+use rustc_hir::def_id::CrateNum;
+use rustc_span::symbol::Symbol;
+use std::path::{Path, PathBuf};
 
+pub mod back;
+pub mod base;
 pub mod common;
-pub mod traits;
-pub mod mir;
 pub mod debuginfo;
-pub mod base;
 pub mod glue;
 pub mod meth;
+pub mod mir;
 pub mod mono_item;
-pub mod back;
+pub mod traits;
 
 pub struct ModuleCodegen<M> {
     /// The name of the module. When the crate may be saved between
@@ -62,19 +61,19 @@ pub struct ModuleCodegen<M> {
 pub const METADATA_FILENAME: &str = "lib.rmeta";
 pub const RLIB_BYTECODE_EXTENSION: &str = "bc.z";
 
-
 impl<M> ModuleCodegen<M> {
-    pub fn into_compiled_module(self,
-                            emit_obj: bool,
-                            emit_bc: bool,
-                            emit_bc_compressed: bool,
-                            outputs: &OutputFilenames) -> CompiledModule {
-        let object = emit_obj
-            .then(|| outputs.temp_path(OutputType::Object, Some(&self.name)));
-        let bytecode = emit_bc
-            .then(|| outputs.temp_path(OutputType::Bitcode, Some(&self.name)));
+    pub fn into_compiled_module(
+        self,
+        emit_obj: bool,
+        emit_bc: bool,
+        emit_bc_compressed: bool,
+        outputs: &OutputFilenames,
+    ) -> CompiledModule {
+        let object = emit_obj.then(|| outputs.temp_path(OutputType::Object, Some(&self.name)));
+        let bytecode = emit_bc.then(|| outputs.temp_path(OutputType::Bitcode, Some(&self.name)));
         let bytecode_compressed = emit_bc_compressed.then(|| {
-            outputs.temp_path(OutputType::Bitcode, Some(&self.name))
+            outputs
+                .temp_path(OutputType::Bitcode, Some(&self.name))
                 .with_extension(RLIB_BYTECODE_EXTENSION)
         });
 
@@ -137,7 +136,6 @@ pub struct CrateInfo {
     pub dependency_formats: Lrc<Dependencies>,
 }
 
-
 pub struct CodegenResults {
     pub crate_name: Symbol,
     pub modules: Vec<CompiledModule>,
@@ -167,13 +165,11 @@ pub fn looks_like_rust_object_file(filename: &str) -> bool {
     let ext = path.extension().and_then(|s| s.to_str());
     if ext != Some(OutputType::Object.extension()) {
         // The file name does not end with ".o", so it can't be an object file.
-        return false
+        return false;
     }
 
     // Strip the ".o" at the end
-    let ext2 = path.file_stem()
-        .and_then(|s| Path::new(s).extension())
-        .and_then(|s| s.to_str());
+    let ext2 = path.file_stem().and_then(|s| Path::new(s).extension()).and_then(|s| s.to_str());
 
     // Check if the "inner" extension
     ext2 == Some(RUST_CGU_EXT)