HIR: rename get_parent_node_by_hir_id to get_parent_node
This commit is contained in:
parent
c7e1f4dcb7
commit
d08bd72e97
21 changed files with 47 additions and 47 deletions
|
@ -87,7 +87,7 @@ impl<'a> Code<'a> {
|
||||||
match map.get(id) {
|
match map.get(id) {
|
||||||
map::Node::Block(_) => {
|
map::Node::Block(_) => {
|
||||||
// Use the parent, hopefully an expression node.
|
// Use the parent, hopefully an expression node.
|
||||||
Code::from_node(map, map.get_parent_node_by_hir_id(id))
|
Code::from_node(map, map.get_parent_node(id))
|
||||||
}
|
}
|
||||||
map::Node::Expr(expr) => Some(Code::Expr(expr)),
|
map::Node::Expr(expr) => Some(Code::Expr(expr)),
|
||||||
node => FnLikeNode::from_node(node).map(Code::FnLike)
|
node => FnLikeNode::from_node(node).map(Code::FnLike)
|
||||||
|
|
|
@ -347,7 +347,7 @@ impl<'hir> Map<'hir> {
|
||||||
if variant_data.ctor_hir_id().is_none() {
|
if variant_data.ctor_hir_id().is_none() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let ctor_of = match self.find_by_hir_id(self.get_parent_node_by_hir_id(hir_id)) {
|
let ctor_of = match self.find_by_hir_id(self.get_parent_node(hir_id)) {
|
||||||
Some(Node::Item(..)) => def::CtorOf::Struct,
|
Some(Node::Item(..)) => def::CtorOf::Struct,
|
||||||
Some(Node::Variant(..)) => def::CtorOf::Variant,
|
Some(Node::Variant(..)) => def::CtorOf::Variant,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
|
@ -424,7 +424,7 @@ impl<'hir> Map<'hir> {
|
||||||
/// which this is the body of, i.e., a `fn`, `const` or `static`
|
/// which this is the body of, i.e., a `fn`, `const` or `static`
|
||||||
/// item (possibly associated), a closure, or a `hir::AnonConst`.
|
/// item (possibly associated), a closure, or a `hir::AnonConst`.
|
||||||
pub fn body_owner(&self, BodyId { hir_id }: BodyId) -> HirId {
|
pub fn body_owner(&self, BodyId { hir_id }: BodyId) -> HirId {
|
||||||
let parent = self.get_parent_node_by_hir_id(hir_id);
|
let parent = self.get_parent_node(hir_id);
|
||||||
assert!(self.lookup(parent).map_or(false, |e| e.is_body_owner(hir_id)));
|
assert!(self.lookup(parent).map_or(false, |e| e.is_body_owner(hir_id)));
|
||||||
parent
|
parent
|
||||||
}
|
}
|
||||||
|
@ -485,7 +485,7 @@ impl<'hir> Map<'hir> {
|
||||||
match self.get(id) {
|
match self.get(id) {
|
||||||
Node::Item(&Item { node: ItemKind::Trait(..), .. }) |
|
Node::Item(&Item { node: ItemKind::Trait(..), .. }) |
|
||||||
Node::Item(&Item { node: ItemKind::TraitAlias(..), .. }) => id,
|
Node::Item(&Item { node: ItemKind::TraitAlias(..), .. }) => id,
|
||||||
Node::GenericParam(_) => self.get_parent_node_by_hir_id(id),
|
Node::GenericParam(_) => self.get_parent_node(id),
|
||||||
_ => bug!("ty_param_owner: {} not a type parameter", self.node_to_string(id))
|
_ => bug!("ty_param_owner: {} not a type parameter", self.node_to_string(id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -625,7 +625,7 @@ impl<'hir> Map<'hir> {
|
||||||
/// never appear as the parent node. Thus, you can always walk the parent nodes
|
/// never appear as the parent node. Thus, you can always walk the parent nodes
|
||||||
/// from a node to the root of the HIR (unless you get back the same ID here,
|
/// from a node to the root of the HIR (unless you get back the same ID here,
|
||||||
/// which can happen if the ID is not in the map itself or is just weird).
|
/// which can happen if the ID is not in the map itself or is just weird).
|
||||||
pub fn get_parent_node_by_hir_id(&self, hir_id: HirId) -> HirId {
|
pub fn get_parent_node(&self, hir_id: HirId) -> HirId {
|
||||||
if self.dep_graph.is_fully_enabled() {
|
if self.dep_graph.is_fully_enabled() {
|
||||||
let hir_id_owner = hir_id.owner;
|
let hir_id_owner = hir_id.owner;
|
||||||
let def_path_hash = self.definitions.def_path_hash(hir_id_owner);
|
let def_path_hash = self.definitions.def_path_hash(hir_id_owner);
|
||||||
|
@ -644,7 +644,7 @@ impl<'hir> Map<'hir> {
|
||||||
Some(Node::Binding(_)) => (),
|
Some(Node::Binding(_)) => (),
|
||||||
_ => return false,
|
_ => return false,
|
||||||
}
|
}
|
||||||
match self.find_by_hir_id(self.get_parent_node_by_hir_id(id)) {
|
match self.find_by_hir_id(self.get_parent_node(id)) {
|
||||||
Some(Node::Item(_)) |
|
Some(Node::Item(_)) |
|
||||||
Some(Node::TraitItem(_)) |
|
Some(Node::TraitItem(_)) |
|
||||||
Some(Node::ImplItem(_)) => true,
|
Some(Node::ImplItem(_)) => true,
|
||||||
|
@ -680,7 +680,7 @@ impl<'hir> Map<'hir> {
|
||||||
{
|
{
|
||||||
let mut id = start_id;
|
let mut id = start_id;
|
||||||
loop {
|
loop {
|
||||||
let parent_id = self.get_parent_node_by_hir_id(id);
|
let parent_id = self.get_parent_node(id);
|
||||||
if parent_id == CRATE_HIR_ID {
|
if parent_id == CRATE_HIR_ID {
|
||||||
return Ok(CRATE_HIR_ID);
|
return Ok(CRATE_HIR_ID);
|
||||||
}
|
}
|
||||||
|
@ -1022,7 +1022,7 @@ impl<'hir> Map<'hir> {
|
||||||
Some(Node::Arm(arm)) => arm.span,
|
Some(Node::Arm(arm)) => arm.span,
|
||||||
Some(Node::Block(block)) => block.span,
|
Some(Node::Block(block)) => block.span,
|
||||||
Some(Node::Ctor(..)) => match self.find_by_hir_id(
|
Some(Node::Ctor(..)) => match self.find_by_hir_id(
|
||||||
self.get_parent_node_by_hir_id(hir_id))
|
self.get_parent_node(hir_id))
|
||||||
{
|
{
|
||||||
Some(Node::Item(item)) => item.span,
|
Some(Node::Item(item)) => item.span,
|
||||||
Some(Node::Variant(variant)) => variant.span,
|
Some(Node::Variant(variant)) => variant.span,
|
||||||
|
|
|
@ -662,7 +662,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||||
if let Some(Region::LateBound(_, def_id, _)) = def {
|
if let Some(Region::LateBound(_, def_id, _)) = def {
|
||||||
if let Some(hir_id) = self.tcx.hir().as_local_hir_id(def_id) {
|
if let Some(hir_id) = self.tcx.hir().as_local_hir_id(def_id) {
|
||||||
// Ensure that the parent of the def is an item, not HRTB
|
// Ensure that the parent of the def is an item, not HRTB
|
||||||
let parent_id = self.tcx.hir().get_parent_node_by_hir_id(hir_id);
|
let parent_id = self.tcx.hir().get_parent_node(hir_id);
|
||||||
let parent_impl_id = hir::ImplItemId { hir_id: parent_id };
|
let parent_impl_id = hir::ImplItemId { hir_id: parent_id };
|
||||||
let parent_trait_id = hir::TraitItemId { hir_id: parent_id };
|
let parent_trait_id = hir::TraitItemId { hir_id: parent_id };
|
||||||
let krate = self.tcx.hir().forest.krate();
|
let krate = self.tcx.hir().forest.krate();
|
||||||
|
@ -2051,7 +2051,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||||
// and whether there's a `self` argument (treated specially).
|
// and whether there's a `self` argument (treated specially).
|
||||||
let mut assoc_item_kind = None;
|
let mut assoc_item_kind = None;
|
||||||
let mut impl_self = None;
|
let mut impl_self = None;
|
||||||
let parent = self.tcx.hir().get_parent_node_by_hir_id(output.hir_id);
|
let parent = self.tcx.hir().get_parent_node(output.hir_id);
|
||||||
let body = match self.tcx.hir().get(parent) {
|
let body = match self.tcx.hir().get(parent) {
|
||||||
// `fn` definitions and methods.
|
// `fn` definitions and methods.
|
||||||
Node::Item(&hir::Item {
|
Node::Item(&hir::Item {
|
||||||
|
|
|
@ -938,7 +938,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
err: &mut DiagnosticBuilder<'tcx>,
|
err: &mut DiagnosticBuilder<'tcx>,
|
||||||
) {
|
) {
|
||||||
if let &ObligationCauseCode::VariableType(hir_id) = code {
|
if let &ObligationCauseCode::VariableType(hir_id) = code {
|
||||||
let parent_node = self.tcx.hir().get_parent_node_by_hir_id(hir_id);
|
let parent_node = self.tcx.hir().get_parent_node(hir_id);
|
||||||
if let Some(Node::Local(ref local)) = self.tcx.hir().find_by_hir_id(parent_node) {
|
if let Some(Node::Local(ref local)) = self.tcx.hir().find_by_hir_id(parent_node) {
|
||||||
if let Some(ref expr) = local.init {
|
if let Some(ref expr) = local.init {
|
||||||
if let hir::ExprKind::Index(_, _) = expr.node {
|
if let hir::ExprKind::Index(_, _) = expr.node {
|
||||||
|
@ -1013,7 +1013,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
trait_ref: &ty::Binder<ty::TraitRef<'tcx>>,
|
trait_ref: &ty::Binder<ty::TraitRef<'tcx>>,
|
||||||
) {
|
) {
|
||||||
let hir = self.tcx.hir();
|
let hir = self.tcx.hir();
|
||||||
let parent_node = hir.get_parent_node_by_hir_id(obligation.cause.body_id);
|
let parent_node = hir.get_parent_node(obligation.cause.body_id);
|
||||||
let node = hir.find_by_hir_id(parent_node);
|
let node = hir.find_by_hir_id(parent_node);
|
||||||
if let Some(hir::Node::Item(hir::Item {
|
if let Some(hir::Node::Item(hir::Item {
|
||||||
node: hir::ItemKind::Fn(decl, _, _, body_id),
|
node: hir::ItemKind::Fn(decl, _, _, body_id),
|
||||||
|
|
|
@ -2880,7 +2880,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
if lint::maybe_lint_level_root(self, id) {
|
if lint::maybe_lint_level_root(self, id) {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
let next = self.hir().get_parent_node_by_hir_id(id);
|
let next = self.hir().get_parent_node(id);
|
||||||
if next == id {
|
if next == id {
|
||||||
bug!("lint traversal reached the root of the crate");
|
bug!("lint traversal reached the root of the crate");
|
||||||
}
|
}
|
||||||
|
@ -2898,7 +2898,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
if let Some(pair) = sets.level_and_source(lint, id, self.sess) {
|
if let Some(pair) = sets.level_and_source(lint, id, self.sess) {
|
||||||
return pair
|
return pair
|
||||||
}
|
}
|
||||||
let next = self.hir().get_parent_node_by_hir_id(id);
|
let next = self.hir().get_parent_node(id);
|
||||||
if next == id {
|
if next == id {
|
||||||
bug!("lint traversal reached the root of the crate");
|
bug!("lint traversal reached the root of the crate");
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ pub enum PatternSource<'tcx> {
|
||||||
/// with a reference to the let
|
/// with a reference to the let
|
||||||
fn get_pattern_source<'tcx>(tcx: TyCtxt<'tcx>, pat: &Pat) -> PatternSource<'tcx> {
|
fn get_pattern_source<'tcx>(tcx: TyCtxt<'tcx>, pat: &Pat) -> PatternSource<'tcx> {
|
||||||
|
|
||||||
let parent = tcx.hir().get_parent_node_by_hir_id(pat.hir_id);
|
let parent = tcx.hir().get_parent_node(pat.hir_id);
|
||||||
|
|
||||||
match tcx.hir().get(parent) {
|
match tcx.hir().get(parent) {
|
||||||
Node::Expr(ref e) => {
|
Node::Expr(ref e) => {
|
||||||
|
|
|
@ -1189,7 +1189,7 @@ impl BorrowckCtxt<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn local_ty(&self, hir_id: hir::HirId) -> (Option<&hir::Ty>, bool) {
|
fn local_ty(&self, hir_id: hir::HirId) -> (Option<&hir::Ty>, bool) {
|
||||||
let parent = self.tcx.hir().get_parent_node_by_hir_id(hir_id);
|
let parent = self.tcx.hir().get_parent_node(hir_id);
|
||||||
let parent_node = self.tcx.hir().get(parent);
|
let parent_node = self.tcx.hir().get(parent);
|
||||||
|
|
||||||
// The parent node is like a fn
|
// The parent node is like a fn
|
||||||
|
@ -1287,7 +1287,7 @@ impl BorrowckCtxt<'_, 'tcx> {
|
||||||
},
|
},
|
||||||
)) = ty.map(|t| &t.node)
|
)) = ty.map(|t| &t.node)
|
||||||
{
|
{
|
||||||
let borrow_expr_id = self.tcx.hir().get_parent_node_by_hir_id(borrowed_hir_id);
|
let borrow_expr_id = self.tcx.hir().get_parent_node(borrowed_hir_id);
|
||||||
db.span_suggestion(
|
db.span_suggestion(
|
||||||
self.tcx.hir().span(borrow_expr_id),
|
self.tcx.hir().span(borrow_expr_id),
|
||||||
"consider removing the `&mut`, as it is an \
|
"consider removing the `&mut`, as it is an \
|
||||||
|
|
|
@ -631,7 +631,7 @@ fn print_flowgraph<'tcx, W: Write>(
|
||||||
if let Some(n) = hir::map::blocks::FnLikeNode::from_node(node) {
|
if let Some(n) = hir::map::blocks::FnLikeNode::from_node(node) {
|
||||||
break n.body();
|
break n.body();
|
||||||
}
|
}
|
||||||
let parent = tcx.hir().get_parent_node_by_hir_id(hir_id);
|
let parent = tcx.hir().get_parent_node(hir_id);
|
||||||
assert_ne!(hir_id, parent);
|
assert_ne!(hir_id, parent);
|
||||||
hir_id = parent;
|
hir_id = parent;
|
||||||
}
|
}
|
||||||
|
|
|
@ -275,7 +275,7 @@ fn lint_int_literal<'a, 'tcx>(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let par_id = cx.tcx.hir().get_parent_node_by_hir_id(e.hir_id);
|
let par_id = cx.tcx.hir().get_parent_node(e.hir_id);
|
||||||
if let Node::Expr(par_e) = cx.tcx.hir().get(par_id) {
|
if let Node::Expr(par_e) = cx.tcx.hir().get(par_id) {
|
||||||
if let hir::ExprKind::Struct(..) = par_e.node {
|
if let hir::ExprKind::Struct(..) = par_e.node {
|
||||||
if is_range_literal(cx.sess(), par_e)
|
if is_range_literal(cx.sess(), par_e)
|
||||||
|
@ -314,7 +314,7 @@ fn lint_uint_literal<'a, 'tcx>(
|
||||||
_ => bug!(),
|
_ => bug!(),
|
||||||
};
|
};
|
||||||
if lit_val < min || lit_val > max {
|
if lit_val < min || lit_val > max {
|
||||||
let parent_id = cx.tcx.hir().get_parent_node_by_hir_id(e.hir_id);
|
let parent_id = cx.tcx.hir().get_parent_node(e.hir_id);
|
||||||
if let Node::Expr(par_e) = cx.tcx.hir().get(parent_id) {
|
if let Node::Expr(par_e) = cx.tcx.hir().get(parent_id) {
|
||||||
match par_e.node {
|
match par_e.node {
|
||||||
hir::ExprKind::Cast(..) => {
|
hir::ExprKind::Cast(..) => {
|
||||||
|
|
|
@ -909,7 +909,7 @@ fn convert_path_expr<'a, 'tcx>(
|
||||||
|
|
||||||
Res::Def(DefKind::ConstParam, def_id) => {
|
Res::Def(DefKind::ConstParam, def_id) => {
|
||||||
let hir_id = cx.tcx.hir().as_local_hir_id(def_id).unwrap();
|
let hir_id = cx.tcx.hir().as_local_hir_id(def_id).unwrap();
|
||||||
let item_id = cx.tcx.hir().get_parent_node_by_hir_id(hir_id);
|
let item_id = cx.tcx.hir().get_parent_node(hir_id);
|
||||||
let item_def_id = cx.tcx.hir().local_def_id_from_hir_id(item_id);
|
let item_def_id = cx.tcx.hir().local_def_id_from_hir_id(item_id);
|
||||||
let generics = cx.tcx.generics_of(item_def_id);
|
let generics = cx.tcx.generics_of(item_def_id);
|
||||||
let local_def_id = cx.tcx.hir().local_def_id_from_hir_id(hir_id);
|
let local_def_id = cx.tcx.hir().local_def_id_from_hir_id(hir_id);
|
||||||
|
|
|
@ -570,7 +570,7 @@ fn is_enclosed(
|
||||||
used_unsafe: &FxHashSet<hir::HirId>,
|
used_unsafe: &FxHashSet<hir::HirId>,
|
||||||
id: hir::HirId,
|
id: hir::HirId,
|
||||||
) -> Option<(String, hir::HirId)> {
|
) -> Option<(String, hir::HirId)> {
|
||||||
let parent_id = tcx.hir().get_parent_node_by_hir_id(id);
|
let parent_id = tcx.hir().get_parent_node(id);
|
||||||
if parent_id != id {
|
if parent_id != id {
|
||||||
if used_unsafe.contains(&parent_id) {
|
if used_unsafe.contains(&parent_id) {
|
||||||
Some(("block".to_string(), parent_id))
|
Some(("block".to_string(), parent_id))
|
||||||
|
|
|
@ -247,7 +247,7 @@ fn def_id_visibility<'tcx>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Node::Ctor(vdata) => {
|
Node::Ctor(vdata) => {
|
||||||
let parent_hir_id = tcx.hir().get_parent_node_by_hir_id(hir_id);
|
let parent_hir_id = tcx.hir().get_parent_node(hir_id);
|
||||||
match tcx.hir().get(parent_hir_id) {
|
match tcx.hir().get(parent_hir_id) {
|
||||||
Node::Variant(..) => {
|
Node::Variant(..) => {
|
||||||
let parent_did = tcx.hir().local_def_id_from_hir_id(parent_hir_id);
|
let parent_did = tcx.hir().local_def_id_from_hir_id(parent_hir_id);
|
||||||
|
@ -784,7 +784,7 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> {
|
||||||
if module_id == hir::CRATE_HIR_ID {
|
if module_id == hir::CRATE_HIR_ID {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
module_id = self.tcx.hir().get_parent_node_by_hir_id(module_id);
|
module_id = self.tcx.hir().get_parent_node(module_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1674,7 +1674,7 @@ impl<'a, 'tcx> PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> {
|
||||||
has_old_errors = true;
|
has_old_errors = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
let parent = self.tcx.hir().get_parent_node_by_hir_id(id);
|
let parent = self.tcx.hir().get_parent_node(id);
|
||||||
if parent == id {
|
if parent == id {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -622,7 +622,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
|
||||||
match seg.res {
|
match seg.res {
|
||||||
Some(res) if res != Res::Err => res,
|
Some(res) if res != Res::Err => res,
|
||||||
_ => {
|
_ => {
|
||||||
let parent_node = self.tcx.hir().get_parent_node_by_hir_id(hir_id);
|
let parent_node = self.tcx.hir().get_parent_node(hir_id);
|
||||||
self.get_path_res(self.tcx.hir().hir_to_node_id(parent_node))
|
self.get_path_res(self.tcx.hir().hir_to_node_id(parent_node))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -2000,7 +2000,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
self.prohibit_generics(&path.segments);
|
self.prohibit_generics(&path.segments);
|
||||||
|
|
||||||
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
|
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
|
||||||
let item_id = tcx.hir().get_parent_node_by_hir_id(hir_id);
|
let item_id = tcx.hir().get_parent_node(hir_id);
|
||||||
let item_def_id = tcx.hir().local_def_id_from_hir_id(item_id);
|
let item_def_id = tcx.hir().local_def_id_from_hir_id(item_id);
|
||||||
let generics = tcx.generics_of(item_def_id);
|
let generics = tcx.generics_of(item_def_id);
|
||||||
let index = generics.param_def_id_to_index[&def_id];
|
let index = generics.param_def_id_to_index[&def_id];
|
||||||
|
@ -2190,7 +2190,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
// Find the name and index of the const parameter by indexing the generics of the
|
// Find the name and index of the const parameter by indexing the generics of the
|
||||||
// parent item and construct a `ParamConst`.
|
// parent item and construct a `ParamConst`.
|
||||||
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
|
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
|
||||||
let item_id = tcx.hir().get_parent_node_by_hir_id(hir_id);
|
let item_id = tcx.hir().get_parent_node(hir_id);
|
||||||
let item_def_id = tcx.hir().local_def_id_from_hir_id(item_id);
|
let item_def_id = tcx.hir().local_def_id_from_hir_id(item_id);
|
||||||
let generics = tcx.generics_of(item_def_id);
|
let generics = tcx.generics_of(item_def_id);
|
||||||
let index = generics.param_def_id_to_index[&tcx.hir().local_def_id_from_hir_id(hir_id)];
|
let index = generics.param_def_id_to_index[&tcx.hir().local_def_id_from_hir_id(hir_id)];
|
||||||
|
|
|
@ -546,7 +546,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
) {
|
) {
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
if let PatKind::Binding(..) = inner.node {
|
if let PatKind::Binding(..) = inner.node {
|
||||||
let parent_id = tcx.hir().get_parent_node_by_hir_id(pat.hir_id);
|
let parent_id = tcx.hir().get_parent_node(pat.hir_id);
|
||||||
let parent = tcx.hir().get(parent_id);
|
let parent = tcx.hir().get(parent_id);
|
||||||
debug!("inner {:?} pat {:?} parent {:?}", inner, pat, parent);
|
debug!("inner {:?} pat {:?} parent {:?}", inner, pat, parent);
|
||||||
match parent {
|
match parent {
|
||||||
|
@ -808,16 +808,16 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
|
||||||
use hir::Node::{Block, Item, Local};
|
use hir::Node::{Block, Item, Local};
|
||||||
|
|
||||||
let hir = self.tcx.hir();
|
let hir = self.tcx.hir();
|
||||||
let arm_id = hir.get_parent_node_by_hir_id(hir_id);
|
let arm_id = hir.get_parent_node(hir_id);
|
||||||
let match_id = hir.get_parent_node_by_hir_id(arm_id);
|
let match_id = hir.get_parent_node(arm_id);
|
||||||
let containing_id = hir.get_parent_node_by_hir_id(match_id);
|
let containing_id = hir.get_parent_node(match_id);
|
||||||
|
|
||||||
let node = hir.get(containing_id);
|
let node = hir.get(containing_id);
|
||||||
if let Block(block) = node {
|
if let Block(block) = node {
|
||||||
// check that the body's parent is an fn
|
// check that the body's parent is an fn
|
||||||
let parent = hir.get(
|
let parent = hir.get(
|
||||||
hir.get_parent_node_by_hir_id(
|
hir.get_parent_node(
|
||||||
hir.get_parent_node_by_hir_id(block.hir_id),
|
hir.get_parent_node(block.hir_id),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
if let (Some(expr), Item(hir::Item {
|
if let (Some(expr), Item(hir::Item {
|
||||||
|
|
|
@ -244,7 +244,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
callee_node: &hir::ExprKind,
|
callee_node: &hir::ExprKind,
|
||||||
callee_span: Span,
|
callee_span: Span,
|
||||||
) {
|
) {
|
||||||
let hir_id = self.tcx.hir().get_parent_node_by_hir_id(hir_id);
|
let hir_id = self.tcx.hir().get_parent_node(hir_id);
|
||||||
let parent_node = self.tcx.hir().get(hir_id);
|
let parent_node = self.tcx.hir().get(hir_id);
|
||||||
if let (
|
if let (
|
||||||
hir::Node::Expr(hir::Expr { node: hir::ExprKind::Closure(_, _, _, sp, ..), .. }),
|
hir::Node::Expr(hir::Expr { node: hir::ExprKind::Closure(_, _, _, sp, ..), .. }),
|
||||||
|
|
|
@ -1231,7 +1231,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
|
||||||
db.span_label(cause.span, "return type is not `()`");
|
db.span_label(cause.span, "return type is not `()`");
|
||||||
}
|
}
|
||||||
ObligationCauseCode::BlockTailExpression(blk_id) => {
|
ObligationCauseCode::BlockTailExpression(blk_id) => {
|
||||||
let parent_id = fcx.tcx.hir().get_parent_node_by_hir_id(blk_id);
|
let parent_id = fcx.tcx.hir().get_parent_node(blk_id);
|
||||||
db = self.report_return_mismatched_types(
|
db = self.report_return_mismatched_types(
|
||||||
cause,
|
cause,
|
||||||
expected,
|
expected,
|
||||||
|
@ -1281,7 +1281,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
|
||||||
// Verify that this is a tail expression of a function, otherwise the
|
// Verify that this is a tail expression of a function, otherwise the
|
||||||
// label pointing out the cause for the type coercion will be wrong
|
// label pointing out the cause for the type coercion will be wrong
|
||||||
// as prior return coercions would not be relevant (#57664).
|
// as prior return coercions would not be relevant (#57664).
|
||||||
let parent_id = fcx.tcx.hir().get_parent_node_by_hir_id(id);
|
let parent_id = fcx.tcx.hir().get_parent_node(id);
|
||||||
let fn_decl = if let Some((expr, blk_id)) = expression {
|
let fn_decl = if let Some((expr, blk_id)) = expression {
|
||||||
pointing_at_return_type = fcx.suggest_mismatched_types_on_tail(
|
pointing_at_return_type = fcx.suggest_mismatched_types_on_tail(
|
||||||
&mut db,
|
&mut db,
|
||||||
|
|
|
@ -236,13 +236,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
) -> Option<(Span, &'static str, String)> {
|
) -> Option<(Span, &'static str, String)> {
|
||||||
if let hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) = expr.node {
|
if let hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) = expr.node {
|
||||||
if let hir::def::Res::Local(id) = path.res {
|
if let hir::def::Res::Local(id) = path.res {
|
||||||
let parent = self.tcx.hir().get_parent_node_by_hir_id(id);
|
let parent = self.tcx.hir().get_parent_node(id);
|
||||||
if let Some(Node::Expr(hir::Expr {
|
if let Some(Node::Expr(hir::Expr {
|
||||||
hir_id,
|
hir_id,
|
||||||
node: hir::ExprKind::Closure(_, decl, ..),
|
node: hir::ExprKind::Closure(_, decl, ..),
|
||||||
..
|
..
|
||||||
})) = self.tcx.hir().find_by_hir_id(parent) {
|
})) = self.tcx.hir().find_by_hir_id(parent) {
|
||||||
let parent = self.tcx.hir().get_parent_node_by_hir_id(*hir_id);
|
let parent = self.tcx.hir().get_parent_node(*hir_id);
|
||||||
if let (Some(Node::Expr(hir::Expr {
|
if let (Some(Node::Expr(hir::Expr {
|
||||||
node: hir::ExprKind::MethodCall(path, span, expr),
|
node: hir::ExprKind::MethodCall(path, span, expr),
|
||||||
..
|
..
|
||||||
|
@ -276,7 +276,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
sp: Span,
|
sp: Span,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let cm = self.sess().source_map();
|
let cm = self.sess().source_map();
|
||||||
let parent_id = self.tcx.hir().get_parent_node_by_hir_id(hir_id);
|
let parent_id = self.tcx.hir().get_parent_node(hir_id);
|
||||||
if let Some(parent) = self.tcx.hir().find_by_hir_id(parent_id) {
|
if let Some(parent) = self.tcx.hir().find_by_hir_id(parent_id) {
|
||||||
// Account for fields
|
// Account for fields
|
||||||
if let Node::Expr(hir::Expr {
|
if let Node::Expr(hir::Expr {
|
||||||
|
@ -422,7 +422,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
node: hir::ExprKind::Assign(left_expr, _),
|
node: hir::ExprKind::Assign(left_expr, _),
|
||||||
..
|
..
|
||||||
})) = self.tcx.hir().find_by_hir_id(
|
})) = self.tcx.hir().find_by_hir_id(
|
||||||
self.tcx.hir().get_parent_node_by_hir_id(expr.hir_id),
|
self.tcx.hir().get_parent_node(expr.hir_id),
|
||||||
) {
|
) {
|
||||||
if mutability == hir::Mutability::MutMutable {
|
if mutability == hir::Mutability::MutMutable {
|
||||||
// Found the following case:
|
// Found the following case:
|
||||||
|
@ -551,7 +551,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
if let Some(hir::Node::Expr(hir::Expr {
|
if let Some(hir::Node::Expr(hir::Expr {
|
||||||
node: hir::ExprKind::Struct(_, fields, _),
|
node: hir::ExprKind::Struct(_, fields, _),
|
||||||
..
|
..
|
||||||
})) = self.tcx.hir().find_by_hir_id(self.tcx.hir().get_parent_node_by_hir_id(expr.hir_id)) {
|
})) = self.tcx.hir().find_by_hir_id(self.tcx.hir().get_parent_node(expr.hir_id)) {
|
||||||
// `expr` is a literal field for a struct, only suggest if appropriate
|
// `expr` is a literal field for a struct, only suggest if appropriate
|
||||||
for field in fields {
|
for field in fields {
|
||||||
if field.expr.hir_id == expr.hir_id && field.is_shorthand {
|
if field.expr.hir_id == expr.hir_id && field.is_shorthand {
|
||||||
|
|
|
@ -269,7 +269,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let filename = tcx.sess.source_map().span_to_filename(span);
|
let filename = tcx.sess.source_map().span_to_filename(span);
|
||||||
|
|
||||||
let parent_node = self.tcx.hir().get(
|
let parent_node = self.tcx.hir().get(
|
||||||
self.tcx.hir().get_parent_node_by_hir_id(hir_id),
|
self.tcx.hir().get_parent_node(hir_id),
|
||||||
);
|
);
|
||||||
let msg = format!(
|
let msg = format!(
|
||||||
"you must specify a type for this binding, like `{}`",
|
"you must specify a type for this binding, like `{}`",
|
||||||
|
@ -390,7 +390,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
let call_expr = self.tcx.hir().expect_expr(
|
let call_expr = self.tcx.hir().expect_expr(
|
||||||
self.tcx.hir().get_parent_node_by_hir_id(expr.hir_id),
|
self.tcx.hir().get_parent_node(expr.hir_id),
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Some(span) = call_expr.span.trim_start(item_name.span) {
|
if let Some(span) = call_expr.span.trim_start(item_name.span) {
|
||||||
|
|
|
@ -4259,7 +4259,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
// If our calling expression is indeed the function itself, we're good!
|
// If our calling expression is indeed the function itself, we're good!
|
||||||
// If not, generate an error that this can only be called directly.
|
// If not, generate an error that this can only be called directly.
|
||||||
if let Node::Expr(expr) = self.tcx.hir().get(
|
if let Node::Expr(expr) = self.tcx.hir().get(
|
||||||
self.tcx.hir().get_parent_node_by_hir_id(hir_id))
|
self.tcx.hir().get_parent_node(hir_id))
|
||||||
{
|
{
|
||||||
if let ExprKind::Call(ref callee, ..) = expr.node {
|
if let ExprKind::Call(ref callee, ..) = expr.node {
|
||||||
if callee.hir_id == hir_id {
|
if callee.hir_id == hir_id {
|
||||||
|
@ -4334,7 +4334,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let mut contained_in_place = false;
|
let mut contained_in_place = false;
|
||||||
|
|
||||||
while let hir::Node::Expr(parent_expr) =
|
while let hir::Node::Expr(parent_expr) =
|
||||||
self.tcx.hir().get(self.tcx.hir().get_parent_node_by_hir_id(expr_id))
|
self.tcx.hir().get(self.tcx.hir().get_parent_node(expr_id))
|
||||||
{
|
{
|
||||||
match &parent_expr.node {
|
match &parent_expr.node {
|
||||||
hir::ExprKind::Assign(lhs, ..) | hir::ExprKind::AssignOp(_, lhs, ..) => {
|
hir::ExprKind::Assign(lhs, ..) | hir::ExprKind::AssignOp(_, lhs, ..) => {
|
||||||
|
|
|
@ -1298,7 +1298,7 @@ pub fn checked_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, fail: bool) -> Op
|
||||||
}
|
}
|
||||||
|
|
||||||
Node::AnonConst(_) => {
|
Node::AnonConst(_) => {
|
||||||
let parent_node = tcx.hir().get(tcx.hir().get_parent_node_by_hir_id(hir_id));
|
let parent_node = tcx.hir().get(tcx.hir().get_parent_node(hir_id));
|
||||||
match parent_node {
|
match parent_node {
|
||||||
Node::Ty(&hir::Ty {
|
Node::Ty(&hir::Ty {
|
||||||
node: hir::TyKind::Array(_, ref constant),
|
node: hir::TyKind::Array(_, ref constant),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue