diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index 10a85cc833a..51ebd1188a5 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -927,7 +927,7 @@ impl<'hir> Map<'hir> { } } - pub fn expect_expr_by_hir_id(&self, id: HirId) -> &'hir Expr { + pub fn expect_expr(&self, id: HirId) -> &'hir Expr { match self.find_by_hir_id(id) { // read recorded by find Some(Node::Expr(expr)) => expr, _ => bug!("expected expr, found {}", self.node_to_string(id)) diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index 2c063aaaa86..18a2bc45385 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -617,7 +617,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { } hir::MatchSource::TryDesugar => { if let Some(ty::error::ExpectedFound { expected, .. }) = exp_found { - let discrim_expr = self.tcx.hir().expect_expr_by_hir_id(discrim_hir_id); + let discrim_expr = self.tcx.hir().expect_expr(discrim_hir_id); let discrim_ty = if let hir::ExprKind::Call(_, args) = &discrim_expr.node { let arg_expr = args.first().expect("try desugaring call w/out arg"); self.in_progress_tables.and_then(|tables| { diff --git a/src/librustc/infer/error_reporting/need_type_info.rs b/src/librustc/infer/error_reporting/need_type_info.rs index fe151bdec6a..4426b5c0e85 100644 --- a/src/librustc/infer/error_reporting/need_type_info.rs +++ b/src/librustc/infer/error_reporting/need_type_info.rs @@ -133,7 +133,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { }; if let Some(body_id) = body_id { - let expr = self.tcx.hir().expect_expr_by_hir_id(body_id.hir_id); + let expr = self.tcx.hir().expect_expr(body_id.hir_id); local_visitor.visit_expr(expr); } diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index bfc61520d51..b22a8412ac8 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -702,7 +702,7 @@ impl BorrowckCtxt<'_, 'tcx> { move_data::MovePat => (self.tcx.hir().span(hir_id), ""), move_data::Captured => - (match self.tcx.hir().expect_expr_by_hir_id(hir_id).node { + (match self.tcx.hir().expect_expr(hir_id).node { hir::ExprKind::Closure(.., fn_decl_span, _) => fn_decl_span, ref r => bug!("Captured({:?}) maps to non-closure: {:?}", the_move.id, r), diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index 27049119b26..ac64cf79537 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -659,7 +659,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { def_id, target_place, places ); let hir_id = self.infcx.tcx.hir().as_local_hir_id(def_id)?; - let expr = &self.infcx.tcx.hir().expect_expr_by_hir_id(hir_id).node; + let expr = &self.infcx.tcx.hir().expect_expr(hir_id).node; debug!("closure_span: hir_id={:?} expr={:?}", hir_id, expr); if let hir::ExprKind::Closure( .., args_span, _ diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs index 46b690129ea..3dc0a99c78b 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs @@ -237,7 +237,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { if let DefiningTy::Closure(def_id, substs) = def_ty { let args_span = if let hir::ExprKind::Closure(_, _, _, span, _) = - tcx.hir().expect_expr_by_hir_id(mir_hir_id).node + tcx.hir().expect_expr(mir_hir_id).node { span } else { diff --git a/src/librustc_passes/loops.rs b/src/librustc_passes/loops.rs index e1e4195d6d5..1c18322259f 100644 --- a/src/librustc_passes/loops.rs +++ b/src/librustc_passes/loops.rs @@ -116,7 +116,7 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> { let loop_kind = if loop_id == hir::DUMMY_HIR_ID { None } else { - Some(match self.hir_map.expect_expr_by_hir_id(loop_id).node { + Some(match self.hir_map.expect_expr(loop_id).node { hir::ExprKind::While(..) => LoopKind::WhileLoop, hir::ExprKind::Loop(_, _, source) => LoopKind::Loop(source), ref r => span_bug!(e.span, diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index fa7e000106f..f67241ef23e 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -1532,7 +1532,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tcx, ' match ex.node { ast::ExprKind::Struct(ref path, ref fields, ref base) => { let expr_hir_id = self.save_ctxt.tcx.hir().node_to_hir_id(ex.id); - let hir_expr = self.save_ctxt.tcx.hir().expect_expr_by_hir_id(expr_hir_id); + let hir_expr = self.save_ctxt.tcx.hir().expect_expr(expr_hir_id); let adt = match self.save_ctxt.tables.expr_ty_opt(&hir_expr) { Some(ty) if ty.ty_adt_def().is_some() => ty.ty_adt_def().unwrap(), _ => { diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 3b0d0622bae..0664327d403 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -514,7 +514,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> { pub fn get_expr_data(&self, expr: &ast::Expr) -> Option { let expr_hir_id = self.tcx.hir().node_to_hir_id(expr.id); - let hir_node = self.tcx.hir().expect_expr_by_hir_id(expr_hir_id); + let hir_node = self.tcx.hir().expect_expr(expr_hir_id); let ty = self.tables.expr_ty_adjusted_opt(&hir_node); if ty.is_none() || ty.unwrap().sty == ty::Error { return None; diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 5943302c708..10efae59867 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -389,7 +389,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { Applicability::MachineApplicable, ); } else { - let call_expr = self.tcx.hir().expect_expr_by_hir_id( + let call_expr = self.tcx.hir().expect_expr( self.tcx.hir().get_parent_node_by_hir_id(expr.hir_id), );