Skip to content

Commit 5419517

Browse files
committed
Removed phantomdata no longer necessary
Because CodegenContext doesn't implement Backend anymore
1 parent 4e9ff6a commit 5419517

File tree

3 files changed

+12
-22
lines changed

3 files changed

+12
-22
lines changed

src/librustc_codegen_llvm/back/lto.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use rustc_data_structures::fx::FxHashMap;
2626
use rustc_codegen_utils::symbol_export;
2727
use time_graph::Timeline;
2828
use {ModuleCodegen, ModuleLlvm, ModuleKind};
29-
use std::marker::PhantomData;
3029

3130
use libc;
3231

@@ -764,7 +763,6 @@ impl ThinModule {
764763
llmod_raw,
765764
llcx,
766765
tm,
767-
phantom: PhantomData
768766
},
769767
name: self.name().to_string(),
770768
kind: ModuleKind::Regular,

src/librustc_codegen_llvm/back/write.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ use context::{is_pie_binary, get_reloc_model};
4949
use common;
5050
use jobserver::{Client, Acquired};
5151
use rustc_demangle;
52-
use std::marker::PhantomData;
5352

5453
use std::any::Any;
5554
use std::ffi::{CString, CStr};
@@ -348,7 +347,7 @@ struct AssemblerCommand {
348347

349348
/// Additional resources used by optimize_and_codegen (not module specific)
350349
#[derive(Clone)]
351-
pub struct CodegenContext<'ll> {
350+
pub struct CodegenContext {
352351
// Resources needed when running LTO
353352
pub time_passes: bool,
354353
pub lto: Lto,
@@ -389,13 +388,10 @@ pub struct CodegenContext<'ll> {
389388
// measuring is disabled.
390389
time_graph: Option<TimeGraph>,
391390
// The assembler command if no_integrated_as option is enabled, None otherwise
392-
assembler_cmd: Option<Arc<AssemblerCommand>>,
393-
// This field is used to give a lifetime parameter to the struct so that it can implement
394-
// the Backend trait.
395-
phantom: PhantomData<&'ll ()>
391+
assembler_cmd: Option<Arc<AssemblerCommand>>
396392
}
397393

398-
impl CodegenContext<'ll> {
394+
impl CodegenContext {
399395
pub fn create_diag_handler(&self) -> Handler {
400396
Handler::with_emitter(true, false, Box::new(self.diag_emitter.clone()))
401397
}
@@ -424,12 +420,12 @@ impl CodegenContext<'ll> {
424420
}
425421

426422
pub struct DiagnosticHandlers<'a> {
427-
data: *mut (&'a CodegenContext<'a>, &'a Handler),
423+
data: *mut (&'a CodegenContext, &'a Handler),
428424
llcx: &'a llvm::Context,
429425
}
430426

431427
impl<'a> DiagnosticHandlers<'a> {
432-
pub fn new(cgcx: &'a CodegenContext<'a>,
428+
pub fn new(cgcx: &'a CodegenContext,
433429
handler: &'a Handler,
434430
llcx: &'a llvm::Context) -> Self {
435431
let data = Box::into_raw(Box::new((cgcx, handler)));
@@ -1620,7 +1616,6 @@ fn start_executing_work(tcx: TyCtxt,
16201616
target_pointer_width: tcx.sess.target.target.target_pointer_width.clone(),
16211617
debuginfo: tcx.sess.opts.debuginfo,
16221618
assembler_cmd,
1623-
phantom: PhantomData
16241619
};
16251620

16261621
// This is the "main loop" of parallel work happening for parallel codegen.
@@ -2115,7 +2110,7 @@ pub const CODEGEN_WORK_PACKAGE_KIND: time_graph::WorkPackageKind =
21152110
const LLVM_WORK_PACKAGE_KIND: time_graph::WorkPackageKind =
21162111
time_graph::WorkPackageKind(&["#7DB67A", "#C6EEC4", "#ACDAAA", "#579354", "#3E6F3C"]);
21172112

2118-
fn spawn_work(cgcx: CodegenContext<'static>, work: WorkItem) {
2113+
fn spawn_work(cgcx: CodegenContext, work: WorkItem) {
21192114
let depth = time_depth();
21202115

21212116
thread::spawn(move || {

src/librustc_codegen_llvm/lib.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ use back::bytecode::RLIB_BYTECODE_EXTENSION;
7272
pub use llvm_util::target_features;
7373
use std::any::Any;
7474
use std::sync::mpsc;
75-
use std::marker::PhantomData;
7675
use rustc_data_structures::sync::Lrc;
7776

7877
use rustc::dep_graph::DepGraph;
@@ -274,7 +273,7 @@ struct ModuleCodegen {
274273
/// as the crate name and disambiguator.
275274
/// We currently generate these names via CodegenUnit::build_cgu_name().
276275
name: String,
277-
module_llvm: ModuleLlvm<'static>,
276+
module_llvm: ModuleLlvm,
278277
kind: ModuleKind,
279278
}
280279

@@ -325,17 +324,16 @@ struct CompiledModule {
325324
bytecode_compressed: Option<PathBuf>,
326325
}
327326

328-
struct ModuleLlvm<'ll> {
327+
struct ModuleLlvm {
329328
llcx: &'static mut llvm::Context,
330329
llmod_raw: *const llvm::Module,
331330
tm: &'static mut llvm::TargetMachine,
332-
phantom: PhantomData<&'ll ()>
333331
}
334332

335-
unsafe impl Send for ModuleLlvm<'ll> { }
336-
unsafe impl Sync for ModuleLlvm<'ll> { }
333+
unsafe impl Send for ModuleLlvm { }
334+
unsafe impl Sync for ModuleLlvm { }
337335

338-
impl ModuleLlvm<'ll> {
336+
impl ModuleLlvm {
339337
fn new(sess: &Session, mod_name: &str) -> Self {
340338
unsafe {
341339
let llcx = llvm::LLVMRustContextCreate(sess.fewer_names());
@@ -345,7 +343,6 @@ impl ModuleLlvm<'ll> {
345343
llmod_raw,
346344
llcx,
347345
tm: create_target_machine(sess, false),
348-
phantom: PhantomData
349346
}
350347
}
351348
}
@@ -357,7 +354,7 @@ impl ModuleLlvm<'ll> {
357354
}
358355
}
359356

360-
impl Drop for ModuleLlvm<'ll> {
357+
impl Drop for ModuleLlvm {
361358
fn drop(&mut self) {
362359
unsafe {
363360
llvm::LLVMContextDispose(&mut *(self.llcx as *mut _));

0 commit comments

Comments
 (0)