diff --git a/src/librustc_codegen_llvm/back/lto.rs b/src/librustc_codegen_llvm/back/lto.rs index 2e58a11ac35cf..25bc662c408f6 100644 --- a/src/librustc_codegen_llvm/back/lto.rs +++ b/src/librustc_codegen_llvm/back/lto.rs @@ -25,7 +25,6 @@ use rustc::util::common::time_ext; use rustc_data_structures::fx::FxHashMap; use time_graph::Timeline; use {ModuleCodegen, ModuleLlvm, ModuleKind}; -use std::marker::PhantomData; use libc; @@ -762,7 +761,6 @@ impl ThinModule { llmod_raw, llcx, tm, - phantom: PhantomData }, name: self.name().to_string(), kind: ModuleKind::Regular, diff --git a/src/librustc_codegen_llvm/back/write.rs b/src/librustc_codegen_llvm/back/write.rs index ade3fbdd5ff52..85edd1bfec2a1 100644 --- a/src/librustc_codegen_llvm/back/write.rs +++ b/src/librustc_codegen_llvm/back/write.rs @@ -48,7 +48,6 @@ use context::{is_pie_binary, get_reloc_model}; use common; use jobserver::{Client, Acquired}; use rustc_demangle; -use std::marker::PhantomData; use std::any::Any; use std::ffi::{CString, CStr}; @@ -345,7 +344,7 @@ struct AssemblerCommand { /// Additional resources used by optimize_and_codegen (not module specific) #[derive(Clone)] -pub struct CodegenContext<'ll> { +pub struct CodegenContext { // Resources needed when running LTO pub time_passes: bool, pub lto: Lto, @@ -384,13 +383,10 @@ pub struct CodegenContext<'ll> { // measuring is disabled. time_graph: Option, // The assembler command if no_integrated_as option is enabled, None otherwise - assembler_cmd: Option>, - // This field is used to give a lifetime parameter to the struct so that it can implement - // the Backend trait. - phantom: PhantomData<&'ll ()> + assembler_cmd: Option> } -impl CodegenContext<'ll> { +impl CodegenContext { pub fn create_diag_handler(&self) -> Handler { Handler::with_emitter(true, false, Box::new(self.diag_emitter.clone())) } @@ -419,12 +415,12 @@ impl CodegenContext<'ll> { } pub struct DiagnosticHandlers<'a> { - data: *mut (&'a CodegenContext<'a>, &'a Handler), + data: *mut (&'a CodegenContext, &'a Handler), llcx: &'a llvm::Context, } impl<'a> DiagnosticHandlers<'a> { - pub fn new(cgcx: &'a CodegenContext<'a>, + pub fn new(cgcx: &'a CodegenContext, handler: &'a Handler, llcx: &'a llvm::Context) -> Self { let data = Box::into_raw(Box::new((cgcx, handler))); @@ -1625,7 +1621,6 @@ fn start_executing_work(tcx: TyCtxt, target_pointer_width: tcx.sess.target.target.target_pointer_width.clone(), debuginfo: tcx.sess.opts.debuginfo, assembler_cmd, - phantom: PhantomData }; // This is the "main loop" of parallel work happening for parallel codegen. @@ -2096,7 +2091,7 @@ pub const CODEGEN_WORK_PACKAGE_KIND: time_graph::WorkPackageKind = const LLVM_WORK_PACKAGE_KIND: time_graph::WorkPackageKind = time_graph::WorkPackageKind(&["#7DB67A", "#C6EEC4", "#ACDAAA", "#579354", "#3E6F3C"]); -fn spawn_work(cgcx: CodegenContext<'static>, work: WorkItem) { +fn spawn_work(cgcx: CodegenContext, work: WorkItem) { let depth = time_depth(); thread::spawn(move || { diff --git a/src/librustc_codegen_llvm/lib.rs b/src/librustc_codegen_llvm/lib.rs index f97cf4721f994..99e991adfc2e2 100644 --- a/src/librustc_codegen_llvm/lib.rs +++ b/src/librustc_codegen_llvm/lib.rs @@ -74,7 +74,6 @@ pub use llvm_util::target_features; use std::any::Any; use std::path::{PathBuf}; use std::sync::mpsc; -use std::marker::PhantomData; use rustc_data_structures::sync::Lrc; use rustc::dep_graph::DepGraph; @@ -279,7 +278,7 @@ struct ModuleCodegen { /// as the crate name and disambiguator. /// We currently generate these names via CodegenUnit::build_cgu_name(). name: String, - module_llvm: ModuleLlvm<'static>, + module_llvm: ModuleLlvm, kind: ModuleKind, } @@ -337,17 +336,16 @@ struct CompiledModule { bytecode_compressed: Option, } -struct ModuleLlvm<'ll> { +struct ModuleLlvm { llcx: &'static mut llvm::Context, llmod_raw: *const llvm::Module, tm: &'static mut llvm::TargetMachine, - phantom: PhantomData<&'ll ()> } -unsafe impl Send for ModuleLlvm<'ll> { } -unsafe impl Sync for ModuleLlvm<'ll> { } +unsafe impl Send for ModuleLlvm { } +unsafe impl Sync for ModuleLlvm { } -impl ModuleLlvm<'ll> { +impl ModuleLlvm { fn new(sess: &Session, mod_name: &str) -> Self { unsafe { let llcx = llvm::LLVMRustContextCreate(sess.fewer_names()); @@ -357,7 +355,6 @@ impl ModuleLlvm<'ll> { llmod_raw, llcx, tm: create_target_machine(sess, false), - phantom: PhantomData } } } @@ -369,7 +366,7 @@ impl ModuleLlvm<'ll> { } } -impl Drop for ModuleLlvm<'ll> { +impl Drop for ModuleLlvm { fn drop(&mut self) { unsafe { llvm::LLVMContextDispose(&mut *(self.llcx as *mut _));