Change:
I don't know if this is really problem, but e.g. the reimplements this function (and yields a bunch of other s, too. This needs some looking at Mostly leaving this here so I don't forget
is probably a hack for cache keying, and should ideally be removed?

Discussion:
fn should_warn_about_field(&mut self, field: &hir::StructField) -> bool { let field_type = self.tcx.type_of(self.tcx.hir.local_def_id(field.id)); <del> let is_marker_field = match field_type.ty_to_def_id() { Some(def_id) => self.tcx.lang_items().items().iter().any(|item| *item == Some(def_id)), _ => false }; </del> !field.is_positional() && !self.symbol_is_live(field.id, None) <del> && !is_marker_field </del> <ins> && !field_type.is_phantom_data() </ins> && !has_allow_dead_code_or_lang_attr(self.tcx, field.id, &field.attrs) }

flags.push((name, Some(value))); } <del> if let Some(true) = self_ty.ty_to_def_id().map(|def_id| def_id.is_local()) { </del> <ins> if let Some(true) = self_ty.ty_adt_def().map(|def| def.did.is_local()) { </ins> flags.push(("crate_local".to_string(), None)); }

} let found_trait_ty = found_trait_ref.self_ty(); <del> let found_did = found_trait_ty.ty_to_def_id(); </del> <ins> let found_did = match found_trait_ty.sty { ty::TyClosure(did, _) | ty::TyForeign(did) | ty::TyFnDef(did, _) => Some(did), ty::TyAdt(def, _) => Some(def.did), _ => None, }; </ins> let found_span = found_did.and_then(|did| { self.tcx.hir.span_if_local(did) }).map(|sp| self.tcx.sess.codemap().def_span(sp)); // the sp could be an fn def

} } <del> pub fn ty_to_def_id(&self) -> Option<DefId> { match self.sty { TyDynamic(ref tt, ..) => tt.principal().map(|p| p.def_id()), TyAdt(def, _) => Some(def.did), TyForeign(did) => Some(did), TyClosure(id, _) => Some(id), TyFnDef(id, _) => Some(id), _ => None, } } </del> pub fn ty_adt_def(&self) -> Option<&'tcx AdtDef> { match self.sty { TyAdt(adt, _) => Some(adt),

} struct DiagnosticHandlers<'a> { <del> inner: Box<(&'a CodegenContext, &'a Handler)>, </del> <ins> data: *mut (&'a CodegenContext, &'a Handler), </ins> llcx: ContextRef, }

fn new(cgcx: &'a CodegenContext, handler: &'a Handler, llcx: ContextRef) -> DiagnosticHandlers<'a> { <del> let data = Box::new((cgcx, handler)); </del> <ins> let data = Box::into_raw(Box::new((cgcx, handler))); </ins> unsafe { <del> 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, </del> <ins> llvm::LLVMRustSetInlineAsmDiagnosticHandler(llcx, inline_asm_handler, data as *mut _); llvm::LLVMContextSetDiagnosticHandler(llcx, diagnostic_handler, data as *mut _); </ins> } <ins> DiagnosticHandlers { data, llcx } </ins> } } impl<'a> Drop for DiagnosticHandlers<'a> { fn drop(&mut self) { <ins> use std::ptr::null_mut; </ins> unsafe { <del> llvm::LLVMRustSetInlineAsmDiagnosticHandler(self.llcx, inline_asm_handler, 0 as *mut _); llvm::LLVMContextSetDiagnosticHandler(self.llcx, diagnostic_handler, 0 as *mut _); </del> <ins> llvm::LLVMRustSetInlineAsmDiagnosticHandler(self.llcx, inline_asm_handler, null_mut()); llvm::LLVMContextSetDiagnosticHandler(self.llcx, diagnostic_handler, null_mut()); drop(Box::from_raw(self.data)); </ins> } } }

if self.impling_types.is_none() { let mut impls = NodeSet(); cx.tcx.for_each_impl(debug, |d| { <del> if let Some(ty_def) = cx.tcx.type_of(d).ty_to_def_id() { if let Some(node_id) = cx.tcx.hir.as_local_node_id(ty_def) { </del> <ins> if let Some(ty_def) = cx.tcx.type_of(d).ty_adt_def() { if let Some(node_id) = cx.tcx.hir.as_local_node_id(ty_def.did) { </ins> impls.insert(node_id); } }