about summary refs log tree commit diff
path: root/src/librustc_codegen_llvm/back
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-07-15 10:29:00 +0000
committerbors <bors@rust-lang.org>2018-07-15 10:29:00 +0000
commit7afa0ccb37a3006ef3cedbdd60da4febee41500b (patch)
tree0a57bdfca85695ee6e1c7bf443a93440bd113571 /src/librustc_codegen_llvm/back
parentee8cc77b32e5480c92b0259347f32f9a4bef6f92 (diff)
parentecab96fd7ce9991218145a9e0063ef3c25c7a977 (diff)
downloadrust-7afa0ccb37a3006ef3cedbdd60da4febee41500b.tar.gz
rust-7afa0ccb37a3006ef3cedbdd60da4febee41500b.zip
Auto merge of #52381 - oli-obk:ty_to_def_id, r=eddyb
Remove `ty_to_def_id`

fixes https://github.com/rust-lang/rust/issues/52341

The uses were mostly convenience and generally "too powerful" (would also have worked for types that weren't interesting at the use site)

r? @eddyb
Diffstat (limited to 'src/librustc_codegen_llvm/back')
-rw-r--r--src/librustc_codegen_llvm/back/write.rs20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/librustc_codegen_llvm/back/write.rs b/src/librustc_codegen_llvm/back/write.rs
index 99daf4b0ed6..2179999125b 100644
--- a/src/librustc_codegen_llvm/back/write.rs
+++ b/src/librustc_codegen_llvm/back/write.rs
@@ -399,7 +399,7 @@ impl CodegenContext {
 }
 
 struct DiagnosticHandlers<'a> {
-    inner: Box<(&'a CodegenContext, &'a Handler)>,
+    data: *mut (&'a CodegenContext, &'a Handler),
     llcx: ContextRef,
 }
 
@@ -407,24 +407,22 @@ impl<'a> DiagnosticHandlers<'a> {
     fn new(cgcx: &'a CodegenContext,
            handler: &'a Handler,
            llcx: ContextRef) -> DiagnosticHandlers<'a> {
-        let data = Box::new((cgcx, handler));
+        let data = Box::into_raw(Box::new((cgcx, handler)));
         unsafe {
-            let arg = &*data as &(_, _) as *const _ as *mut _;
-            llvm::LLVMRustSetInlineAsmDiagnosticHandler(llcx, inline_asm_handler, arg);
-            llvm::LLVMContextSetDiagnosticHandler(llcx, diagnostic_handler, arg);
-        }
-        DiagnosticHandlers {
-            inner: data,
-            llcx: llcx,
+            llvm::LLVMRustSetInlineAsmDiagnosticHandler(llcx, inline_asm_handler, data as *mut _);
+            llvm::LLVMContextSetDiagnosticHandler(llcx, diagnostic_handler, data as *mut _);
         }
+        DiagnosticHandlers { data, llcx }
     }
 }
 
 impl<'a> Drop for DiagnosticHandlers<'a> {
     fn drop(&mut self) {
+        use std::ptr::null_mut;
         unsafe {
-            llvm::LLVMRustSetInlineAsmDiagnosticHandler(self.llcx, inline_asm_handler, 0 as *mut _);
-            llvm::LLVMContextSetDiagnosticHandler(self.llcx, diagnostic_handler, 0 as *mut _);
+            llvm::LLVMRustSetInlineAsmDiagnosticHandler(self.llcx, inline_asm_handler, null_mut());
+            llvm::LLVMContextSetDiagnosticHandler(self.llcx, diagnostic_handler, null_mut());
+            drop(Box::from_raw(self.data));
         }
     }
 }