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
This commit is contained in:
bors 2018-07-15 10:29:00 +00:00
commit 7afa0ccb37
5 changed files with 20 additions and 31 deletions

View file

@ -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));
}
}
}