mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-15 20:45:45 +03:00
remove uses of the NodeId hir::map::expr
This commit is contained in:
@@ -927,12 +927,6 @@ pub fn expect_foreign_item(&self, id: HirId) -> &'hir ForeignItem {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expect_expr(&self, id: NodeId) -> &'hir Expr {
|
||||
let hir_id = self.node_to_hir_id(id);
|
||||
self.expect_expr_by_hir_id(hir_id)
|
||||
}
|
||||
|
||||
// FIXME(@ljedrz): replace the `NodeId` variant.
|
||||
pub fn expect_expr_by_hir_id(&self, id: HirId) -> &'hir Expr {
|
||||
match self.find_by_hir_id(id) { // read recorded by find
|
||||
Some(Node::Expr(expr)) => expr,
|
||||
|
||||
@@ -1531,7 +1531,8 @@ fn visit_expr(&mut self, ex: &'l ast::Expr) {
|
||||
self.process_macro_use(ex.span);
|
||||
match ex.node {
|
||||
ast::ExprKind::Struct(ref path, ref fields, ref base) => {
|
||||
let hir_expr = self.save_ctxt.tcx.hir().expect_expr(ex.id);
|
||||
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 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(),
|
||||
_ => {
|
||||
|
||||
@@ -513,7 +513,8 @@ pub fn get_trait_ref_data(&self, trait_ref: &ast::TraitRef) -> Option<Ref> {
|
||||
}
|
||||
|
||||
pub fn get_expr_data(&self, expr: &ast::Expr) -> Option<Data> {
|
||||
let hir_node = self.tcx.hir().expect_expr(expr.id);
|
||||
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 ty = self.tables.expr_ty_adjusted_opt(&hir_node);
|
||||
if ty.is_none() || ty.unwrap().sty == ty::Error {
|
||||
return None;
|
||||
|
||||
Reference in New Issue
Block a user