Skip to content

Commit 5a880b7

Browse files
committed
Removed phantomdata no longer necessary
Because CodegenContext doesn't implement Backend anymore
1 parent fed567a commit 5a880b7

File tree

3 files changed

+12
-22
lines changed

3 files changed

+12
-22
lines changed

src/librustc_codegen_llvm/back/lto.rs

-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use rustc::util::common::time_ext;
2525
use rustc_data_structures::fx::FxHashMap;
2626
use time_graph::Timeline;
2727
use {ModuleCodegen, ModuleLlvm, ModuleKind};
28-
use std::marker::PhantomData;
2928

3029
use libc;
3130

@@ -762,7 +761,6 @@ impl ThinModule {
762761
llmod_raw,
763762
llcx,
764763
tm,
765-
phantom: PhantomData
766764
},
767765
name: self.name().to_string(),
768766
kind: ModuleKind::Regular,

src/librustc_codegen_llvm/back/write.rs

+6-11
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ use context::{is_pie_binary, get_reloc_model};
4848
use common;
4949
use jobserver::{Client, Acquired};
5050
use rustc_demangle;
51-
use std::marker::PhantomData;
5251

5352
use std::any::Any;
5453
use std::ffi::{CString, CStr};
@@ -345,7 +344,7 @@ struct AssemblerCommand {
345344

346345
/// Additional resources used by optimize_and_codegen (not module specific)
347346
#[derive(Clone)]
348-
pub struct CodegenContext<'ll> {
347+
pub struct CodegenContext {
349348
// Resources needed when running LTO
350349
pub time_passes: bool,
351350
pub lto: Lto,
@@ -384,13 +383,10 @@ pub struct CodegenContext<'ll> {
384383
// measuring is disabled.
385384
time_graph: Option<TimeGraph>,
386385
// The assembler command if no_integrated_as option is enabled, None otherwise
387-
assembler_cmd: Option<Arc<AssemblerCommand>>,
388-
// This field is used to give a lifetime parameter to the struct so that it can implement
389-
// the Backend trait.
390-
phantom: PhantomData<&'ll ()>
386+
assembler_cmd: Option<Arc<AssemblerCommand>>
391387
}
392388

393-
impl CodegenContext<'ll> {
389+
impl CodegenContext {
394390
pub fn create_diag_handler(&self) -> Handler {
395391
Handler::with_emitter(true, false, Box::new(self.diag_emitter.clone()))
396392
}
@@ -419,12 +415,12 @@ impl CodegenContext<'ll> {
419415
}
420416

421417
pub struct DiagnosticHandlers<'a> {
422-
data: *mut (&'a CodegenContext<'a>, &'a Handler),
418+
data: *mut (&'a CodegenContext, &'a Handler),
423419
llcx: &'a llvm::Context,
424420
}
425421

426422
impl<'a> DiagnosticHandlers<'a> {
427-
pub fn new(cgcx: &'a CodegenContext<'a>,
423+
pub fn new(cgcx: &'a CodegenContext,
428424
handler: &'a Handler,
429425
llcx: &'a llvm::Context) -> Self {
430426
let data = Box::into_raw(Box::new((cgcx, handler)));
@@ -1625,7 +1621,6 @@ fn start_executing_work(tcx: TyCtxt,
16251621
target_pointer_width: tcx.sess.target.target.target_pointer_width.clone(),
16261622
debuginfo: tcx.sess.opts.debuginfo,
16271623
assembler_cmd,
1628-
phantom: PhantomData
16291624
};
16301625

16311626
// 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 =
20962091
const LLVM_WORK_PACKAGE_KIND: time_graph::WorkPackageKind =
20972092
time_graph::WorkPackageKind(&["#7DB67A", "#C6EEC4", "#ACDAAA", "#579354", "#3E6F3C"]);
20982093

2099-
fn spawn_work(cgcx: CodegenContext<'static>, work: WorkItem) {
2094+
fn spawn_work(cgcx: CodegenContext, work: WorkItem) {
21002095
let depth = time_depth();
21012096

21022097
thread::spawn(move || {

src/librustc_codegen_llvm/lib.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ pub use llvm_util::target_features;
7474
use std::any::Any;
7575
use std::path::{PathBuf};
7676
use std::sync::mpsc;
77-
use std::marker::PhantomData;
7877
use rustc_data_structures::sync::Lrc;
7978

8079
use rustc::dep_graph::DepGraph;
@@ -279,7 +278,7 @@ struct ModuleCodegen {
279278
/// as the crate name and disambiguator.
280279
/// We currently generate these names via CodegenUnit::build_cgu_name().
281280
name: String,
282-
module_llvm: ModuleLlvm<'static>,
281+
module_llvm: ModuleLlvm,
283282
kind: ModuleKind,
284283
}
285284

@@ -337,17 +336,16 @@ struct CompiledModule {
337336
bytecode_compressed: Option<PathBuf>,
338337
}
339338

340-
struct ModuleLlvm<'ll> {
339+
struct ModuleLlvm {
341340
llcx: &'static mut llvm::Context,
342341
llmod_raw: *const llvm::Module,
343342
tm: &'static mut llvm::TargetMachine,
344-
phantom: PhantomData<&'ll ()>
345343
}
346344

347-
unsafe impl Send for ModuleLlvm<'ll> { }
348-
unsafe impl Sync for ModuleLlvm<'ll> { }
345+
unsafe impl Send for ModuleLlvm { }
346+
unsafe impl Sync for ModuleLlvm { }
349347

350-
impl ModuleLlvm<'ll> {
348+
impl ModuleLlvm {
351349
fn new(sess: &Session, mod_name: &str) -> Self {
352350
unsafe {
353351
let llcx = llvm::LLVMRustContextCreate(sess.fewer_names());
@@ -357,7 +355,6 @@ impl ModuleLlvm<'ll> {
357355
llmod_raw,
358356
llcx,
359357
tm: create_target_machine(sess, false),
360-
phantom: PhantomData
361358
}
362359
}
363360
}
@@ -369,7 +366,7 @@ impl ModuleLlvm<'ll> {
369366
}
370367
}
371368

372-
impl Drop for ModuleLlvm<'ll> {
369+
impl Drop for ModuleLlvm {
373370
fn drop(&mut self) {
374371
unsafe {
375372
llvm::LLVMContextDispose(&mut *(self.llcx as *mut _));

0 commit comments

Comments
 (0)