}
}
- 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))
}
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| {
};
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);
}
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),
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, _
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 {
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,
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(),
_ => {
pub fn get_expr_data(&self, expr: &ast::Expr) -> Option<Data> {
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;
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),
);