#![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
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)
});
pub dependency_formats: Lrc<Dependencies>,
}
-
pub struct CodegenResults {
pub crate_name: Symbol,
pub modules: Vec<CompiledModule>,
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)