diff --git a/src/librustc_ast_lowering/item.rs b/src/librustc_ast_lowering/item.rs index eced17c9245f2..8093dc2827011 100644 --- a/src/librustc_ast_lowering/item.rs +++ b/src/librustc_ast_lowering/item.rs @@ -13,7 +13,7 @@ use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::LocalDefId; use rustc_span::source_map::{respan, DesugaringKind}; use rustc_span::symbol::{kw, sym, Ident}; -use rustc_span::Span; +use rustc_span::{Span, DUMMY_SP}; use rustc_target::spec::abi; use log::debug; @@ -482,7 +482,13 @@ impl<'hir> LoweringContext<'_, 'hir> { let mut resolutions = self.expect_full_res_from_use(id); // We want to return *something* from this function, so hold onto the first item // for later. - let ret_res = self.lower_res(resolutions.next().unwrap_or(Res::Err)); + let ret_res = self.lower_res(resolutions.next().unwrap_or_else(|| { + self.sess.delay_span_bug( + DUMMY_SP, + &format!("missing `ret_res` for use_tree: {:?}", tree), + ); + Res::Err + })); // Here, we are looping over namespaces, if they exist for the definition // being imported. We only handle type and value namespaces because we diff --git a/src/librustc_passes/intrinsicck.rs b/src/librustc_passes/intrinsicck.rs index b407276cfbecd..7546e1dabd89c 100644 --- a/src/librustc_passes/intrinsicck.rs +++ b/src/librustc_passes/intrinsicck.rs @@ -146,20 +146,19 @@ impl Visitor<'tcx> for ExprVisitor<'tcx> { } fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) { - let res = if let hir::ExprKind::Path(ref qpath) = expr.kind { - self.tables.qpath_res(qpath, expr.hir_id) - } else { - Res::Err - }; - if let Res::Def(DefKind::Fn, did) = res { - if self.def_id_is_transmute(did) { - let typ = self.tables.node_type(expr.hir_id); - let sig = typ.fn_sig(self.tcx); - let from = sig.inputs().skip_binder()[0]; - let to = *sig.output().skip_binder(); - self.check_transmute(expr.span, from, to); + if let hir::ExprKind::Path(ref qpath) = expr.kind { + let res = self.tables.qpath_res(qpath, expr.hir_id); + + if let Res::Def(DefKind::Fn, did) = res { + if self.def_id_is_transmute(did) { + let typ = self.tables.node_type(expr.hir_id); + let sig = typ.fn_sig(self.tcx); + let from = sig.inputs().skip_binder()[0]; + let to = *sig.output().skip_binder(); + self.check_transmute(expr.span, from, to); + } } - } + }; intravisit::walk_expr(self, expr); }