Rollup merge of #61984 - ljedrz:more_node_id_pruning, r=Zoxc
More NodeId pruning Just another round of the `HirId`ification initiative. r? @Zoxc
This commit is contained in:
commit
dc0ef823be
63 changed files with 141 additions and 177 deletions
|
@ -15,7 +15,7 @@ use crate::hir as ast;
|
||||||
use crate::hir::map;
|
use crate::hir::map;
|
||||||
use crate::hir::{Expr, FnDecl, Node};
|
use crate::hir::{Expr, FnDecl, Node};
|
||||||
use crate::hir::intravisit::FnKind;
|
use crate::hir::intravisit::FnKind;
|
||||||
use syntax::ast::{Attribute, Ident, NodeId};
|
use syntax::ast::{Attribute, Ident};
|
||||||
use syntax_pos::Span;
|
use syntax_pos::Span;
|
||||||
|
|
||||||
/// An FnLikeNode is a Node that is like a fn, in that it has a decl
|
/// An FnLikeNode is a Node that is like a fn, in that it has a decl
|
||||||
|
@ -83,11 +83,11 @@ impl<'a> Code<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attempts to construct a Code from presumed FnLike or Expr node input.
|
/// Attempts to construct a Code from presumed FnLike or Expr node input.
|
||||||
pub fn from_node(map: &map::Map<'a>, id: NodeId) -> Option<Code<'a>> {
|
pub fn from_node(map: &map::Map<'a>, id: ast::HirId) -> Option<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(id))
|
Code::from_node(map, map.get_parent_node_by_hir_id(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)
|
||||||
|
|
|
@ -397,11 +397,6 @@ impl Definitions {
|
||||||
self.node_to_hir_id[node_id]
|
self.node_to_hir_id[node_id]
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn def_index_to_node_id(&self, def_index: DefIndex) -> ast::NodeId {
|
|
||||||
self.as_local_node_id(DefId::local(def_index)).unwrap()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Retrieves the span of the given `DefId` if `DefId` is in the local crate, the span exists
|
/// Retrieves the span of the given `DefId` if `DefId` is in the local crate, the span exists
|
||||||
/// and it's not `DUMMY_SP`.
|
/// and it's not `DUMMY_SP`.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -291,8 +291,8 @@ impl<'hir> Map<'hir> {
|
||||||
self.definitions.def_index_to_hir_id(def_id.to_def_id().index)
|
self.definitions.def_index_to_hir_id(def_id.to_def_id().index)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn def_kind(&self, node_id: NodeId) -> Option<DefKind> {
|
fn def_kind(&self, hir_id: HirId) -> Option<DefKind> {
|
||||||
let node = if let Some(node) = self.find(node_id) {
|
let node = if let Some(node) = self.find_by_hir_id(hir_id) {
|
||||||
node
|
node
|
||||||
} else {
|
} else {
|
||||||
return None
|
return None
|
||||||
|
@ -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(self.get_parent_node(node_id)) {
|
let ctor_of = match self.find_by_hir_id(self.get_parent_node_by_hir_id(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!(),
|
||||||
|
@ -458,7 +458,7 @@ impl<'hir> Map<'hir> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn body_owner_kind(&self, id: HirId) -> BodyOwnerKind {
|
pub fn body_owner_kind(&self, id: HirId) -> BodyOwnerKind {
|
||||||
match self.get_by_hir_id(id) {
|
match self.get(id) {
|
||||||
Node::Item(&Item { node: ItemKind::Const(..), .. }) |
|
Node::Item(&Item { node: ItemKind::Const(..), .. }) |
|
||||||
Node::TraitItem(&TraitItem { node: TraitItemKind::Const(..), .. }) |
|
Node::TraitItem(&TraitItem { node: TraitItemKind::Const(..), .. }) |
|
||||||
Node::ImplItem(&ImplItem { node: ImplItemKind::Const(..), .. }) |
|
Node::ImplItem(&ImplItem { node: ImplItemKind::Const(..), .. }) |
|
||||||
|
@ -482,7 +482,7 @@ impl<'hir> Map<'hir> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ty_param_owner(&self, id: HirId) -> HirId {
|
pub fn ty_param_owner(&self, id: HirId) -> HirId {
|
||||||
match self.get_by_hir_id(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_by_hir_id(id),
|
||||||
|
@ -491,7 +491,7 @@ impl<'hir> Map<'hir> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ty_param_name(&self, id: HirId) -> Name {
|
pub fn ty_param_name(&self, id: HirId) -> Name {
|
||||||
match self.get_by_hir_id(id) {
|
match self.get(id) {
|
||||||
Node::Item(&Item { node: ItemKind::Trait(..), .. }) |
|
Node::Item(&Item { node: ItemKind::Trait(..), .. }) |
|
||||||
Node::Item(&Item { node: ItemKind::TraitAlias(..), .. }) => kw::SelfUpper,
|
Node::Item(&Item { node: ItemKind::TraitAlias(..), .. }) => kw::SelfUpper,
|
||||||
Node::GenericParam(param) => param.name.ident().name,
|
Node::GenericParam(param) => param.name.ident().name,
|
||||||
|
@ -561,20 +561,14 @@ impl<'hir> Map<'hir> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves the `Node` corresponding to `id`, panicking if it cannot be found.
|
/// Retrieves the `Node` corresponding to `id`, panicking if it cannot be found.
|
||||||
pub fn get(&self, id: NodeId) -> Node<'hir> {
|
pub fn get(&self, id: HirId) -> Node<'hir> {
|
||||||
let hir_id = self.node_to_hir_id(id);
|
|
||||||
self.get_by_hir_id(hir_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME(@ljedrz): replace the `NodeId` variant.
|
|
||||||
pub fn get_by_hir_id(&self, id: HirId) -> Node<'hir> {
|
|
||||||
// read recorded by `find`
|
// read recorded by `find`
|
||||||
self.find_by_hir_id(id).unwrap_or_else(||
|
self.find_by_hir_id(id).unwrap_or_else(||
|
||||||
bug!("couldn't find hir id {} in the HIR map", id))
|
bug!("couldn't find hir id {} in the HIR map", id))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_if_local(&self, id: DefId) -> Option<Node<'hir>> {
|
pub fn get_if_local(&self, id: DefId) -> Option<Node<'hir>> {
|
||||||
self.as_local_node_id(id).map(|id| self.get(id)) // read recorded by `get`
|
self.as_local_hir_id(id).map(|id| self.get(id)) // read recorded by `get`
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_generics(&self, id: DefId) -> Option<&'hir Generics> {
|
pub fn get_generics(&self, id: DefId) -> Option<&'hir Generics> {
|
||||||
|
@ -846,7 +840,7 @@ impl<'hir> Map<'hir> {
|
||||||
if scope == CRATE_HIR_ID {
|
if scope == CRATE_HIR_ID {
|
||||||
return Some(CRATE_HIR_ID);
|
return Some(CRATE_HIR_ID);
|
||||||
}
|
}
|
||||||
match self.get_by_hir_id(scope) {
|
match self.get(scope) {
|
||||||
Node::Item(i) => {
|
Node::Item(i) => {
|
||||||
match i.node {
|
match i.node {
|
||||||
ItemKind::Existential(ExistTy { impl_trait_fn: None, .. }) => {}
|
ItemKind::Existential(ExistTy { impl_trait_fn: None, .. }) => {}
|
||||||
|
@ -927,28 +921,15 @@ impl<'hir> Map<'hir> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn expect_expr(&self, id: NodeId) -> &'hir Expr {
|
pub fn expect_expr(&self, id: HirId) -> &'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
|
match self.find_by_hir_id(id) { // read recorded by find
|
||||||
Some(Node::Expr(expr)) => expr,
|
Some(Node::Expr(expr)) => expr,
|
||||||
_ => bug!("expected expr, found {}", self.node_to_string(id))
|
_ => bug!("expected expr, found {}", self.node_to_string(id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the name associated with the given `NodeId`'s AST.
|
pub fn name(&self, id: HirId) -> Name {
|
||||||
pub fn name(&self, id: NodeId) -> Name {
|
match self.get(id) {
|
||||||
let hir_id = self.node_to_hir_id(id);
|
|
||||||
self.name_by_hir_id(hir_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME(@ljedrz): replace the `NodeId` variant.
|
|
||||||
pub fn name_by_hir_id(&self, id: HirId) -> Name {
|
|
||||||
match self.get_by_hir_id(id) {
|
|
||||||
Node::Item(i) => i.ident.name,
|
Node::Item(i) => i.ident.name,
|
||||||
Node::ForeignItem(fi) => fi.ident.name,
|
Node::ForeignItem(fi) => fi.ident.name,
|
||||||
Node::ImplItem(ii) => ii.ident.name,
|
Node::ImplItem(ii) => ii.ident.name,
|
||||||
|
@ -958,7 +939,7 @@ impl<'hir> Map<'hir> {
|
||||||
Node::Lifetime(lt) => lt.name.ident().name,
|
Node::Lifetime(lt) => lt.name.ident().name,
|
||||||
Node::GenericParam(param) => param.name.ident().name,
|
Node::GenericParam(param) => param.name.ident().name,
|
||||||
Node::Binding(&Pat { node: PatKind::Binding(_, _, l, _), .. }) => l.name,
|
Node::Binding(&Pat { node: PatKind::Binding(_, _, l, _), .. }) => l.name,
|
||||||
Node::Ctor(..) => self.name_by_hir_id(self.get_parent_item(id)),
|
Node::Ctor(..) => self.name(self.get_parent_item(id)),
|
||||||
_ => bug!("no name for {}", self.node_to_string(id))
|
_ => bug!("no name for {}", self.node_to_string(id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1080,7 +1061,7 @@ impl<'hir> Map<'hir> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn hir_to_pretty_string(&self, id: HirId) -> String {
|
pub fn hir_to_pretty_string(&self, id: HirId) -> String {
|
||||||
print::to_string(self, |s| s.print_node(self.get_by_hir_id(id)))
|
print::to_string(self, |s| s.print_node(self.get(id)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1407,8 +1388,8 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
|
||||||
|
|
||||||
pub fn provide(providers: &mut Providers<'_>) {
|
pub fn provide(providers: &mut Providers<'_>) {
|
||||||
providers.def_kind = |tcx, def_id| {
|
providers.def_kind = |tcx, def_id| {
|
||||||
if let Some(node_id) = tcx.hir().as_local_node_id(def_id) {
|
if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) {
|
||||||
tcx.hir().def_kind(node_id)
|
tcx.hir().def_kind(hir_id)
|
||||||
} else {
|
} else {
|
||||||
bug!("calling local def_kind query provider for upstream DefId: {:?}",
|
bug!("calling local def_kind query provider for upstream DefId: {:?}",
|
||||||
def_id
|
def_id
|
||||||
|
|
|
@ -617,7 +617,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
hir::MatchSource::TryDesugar => {
|
hir::MatchSource::TryDesugar => {
|
||||||
if let Some(ty::error::ExpectedFound { expected, .. }) = exp_found {
|
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 discrim_ty = if let hir::ExprKind::Call(_, args) = &discrim_expr.node {
|
||||||
let arg_expr = args.first().expect("try desugaring call w/out arg");
|
let arg_expr = args.first().expect("try desugaring call w/out arg");
|
||||||
self.in_progress_tables.and_then(|tables| {
|
self.in_progress_tables.and_then(|tables| {
|
||||||
|
@ -1335,7 +1335,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
// We do this to avoid suggesting code that ends up as `T: 'a'b`,
|
// We do this to avoid suggesting code that ends up as `T: 'a'b`,
|
||||||
// instead we suggest `T: 'a + 'b` in that case.
|
// instead we suggest `T: 'a + 'b` in that case.
|
||||||
let mut has_bounds = false;
|
let mut has_bounds = false;
|
||||||
if let Node::GenericParam(ref param) = hir.get_by_hir_id(id) {
|
if let Node::GenericParam(ref param) = hir.get(id) {
|
||||||
has_bounds = !param.bounds.is_empty();
|
has_bounds = !param.bounds.is_empty();
|
||||||
}
|
}
|
||||||
let sp = hir.span(id);
|
let sp = hir.span(id);
|
||||||
|
@ -1583,7 +1583,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
format!(" for lifetime parameter `{}` in coherence check", name)
|
format!(" for lifetime parameter `{}` in coherence check", name)
|
||||||
}
|
}
|
||||||
infer::UpvarRegion(ref upvar_id, _) => {
|
infer::UpvarRegion(ref upvar_id, _) => {
|
||||||
let var_name = self.tcx.hir().name_by_hir_id(upvar_id.var_path.hir_id);
|
let var_name = self.tcx.hir().name(upvar_id.var_path.hir_id);
|
||||||
format!(" for capture of `{}` by closure", var_name)
|
format!(" for capture of `{}` by closure", var_name)
|
||||||
}
|
}
|
||||||
infer::NLL(..) => bug!("NLL variable found in lexical phase"),
|
infer::NLL(..) => bug!("NLL variable found in lexical phase"),
|
||||||
|
|
|
@ -133,7 +133,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(body_id) = body_id {
|
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);
|
local_visitor.visit_expr(expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||||
if let Some(anon_reg) = self.tcx().is_suitable_region(region) {
|
if let Some(anon_reg) = self.tcx().is_suitable_region(region) {
|
||||||
let def_id = anon_reg.def_id;
|
let def_id = anon_reg.def_id;
|
||||||
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) {
|
||||||
let fndecl = match self.tcx().hir().get_by_hir_id(hir_id) {
|
let fndecl = match self.tcx().hir().get(hir_id) {
|
||||||
Node::Item(&hir::Item {
|
Node::Item(&hir::Item {
|
||||||
node: hir::ItemKind::Fn(ref fndecl, ..),
|
node: hir::ItemKind::Fn(ref fndecl, ..),
|
||||||
..
|
..
|
||||||
|
|
|
@ -52,7 +52,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||||
if let Node::Expr(Expr {
|
if let Node::Expr(Expr {
|
||||||
node: Closure(_, _, _, closure_span, None),
|
node: Closure(_, _, _, closure_span, None),
|
||||||
..
|
..
|
||||||
}) = hir.get_by_hir_id(hir_id) {
|
}) = hir.get(hir_id) {
|
||||||
let sup_sp = sup_origin.span();
|
let sup_sp = sup_origin.span();
|
||||||
let origin_sp = origin.span();
|
let origin_sp = origin.span();
|
||||||
let mut err = self.tcx().sess.struct_span_err(
|
let mut err = self.tcx().sess.struct_span_err(
|
||||||
|
|
|
@ -31,7 +31,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
"...so that reference does not outlive borrowed content");
|
"...so that reference does not outlive borrowed content");
|
||||||
}
|
}
|
||||||
infer::ReborrowUpvar(span, ref upvar_id) => {
|
infer::ReborrowUpvar(span, ref upvar_id) => {
|
||||||
let var_name = self.tcx.hir().name_by_hir_id(upvar_id.var_path.hir_id);
|
let var_name = self.tcx.hir().name(upvar_id.var_path.hir_id);
|
||||||
err.span_note(span,
|
err.span_note(span,
|
||||||
&format!("...so that closure can access `{}`", var_name));
|
&format!("...so that closure can access `{}`", var_name));
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
infer::ReborrowUpvar(span, ref upvar_id) => {
|
infer::ReborrowUpvar(span, ref upvar_id) => {
|
||||||
let var_name = self.tcx.hir().name_by_hir_id(upvar_id.var_path.hir_id);
|
let var_name = self.tcx.hir().name(upvar_id.var_path.hir_id);
|
||||||
let mut err = struct_span_err!(self.tcx.sess,
|
let mut err = struct_span_err!(self.tcx.sess,
|
||||||
span,
|
span,
|
||||||
E0313,
|
E0313,
|
||||||
|
|
|
@ -265,7 +265,7 @@ pub enum SubregionOrigin<'tcx> {
|
||||||
DerefPointer(Span),
|
DerefPointer(Span),
|
||||||
|
|
||||||
/// Closure bound must not outlive captured variables
|
/// Closure bound must not outlive captured variables
|
||||||
ClosureCapture(Span, ast::NodeId),
|
ClosureCapture(Span, hir::HirId),
|
||||||
|
|
||||||
/// Index into slice must be within its lifetime
|
/// Index into slice must be within its lifetime
|
||||||
IndexSlice(Span),
|
IndexSlice(Span),
|
||||||
|
|
|
@ -945,8 +945,8 @@ pub fn may_define_existential_type(
|
||||||
let mut hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
|
let mut hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
|
||||||
trace!(
|
trace!(
|
||||||
"may_define_existential_type(def={:?}, opaque_node={:?})",
|
"may_define_existential_type(def={:?}, opaque_node={:?})",
|
||||||
tcx.hir().get_by_hir_id(hir_id),
|
tcx.hir().get(hir_id),
|
||||||
tcx.hir().get_by_hir_id(opaque_hir_id)
|
tcx.hir().get(opaque_hir_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Named existential types can be defined by any siblings or children of siblings.
|
// Named existential types can be defined by any siblings or children of siblings.
|
||||||
|
|
|
@ -1630,7 +1630,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||||
);
|
);
|
||||||
|
|
||||||
if self.ir.variable_is_shorthand(var) {
|
if self.ir.variable_is_shorthand(var) {
|
||||||
if let Node::Binding(pat) = self.ir.tcx.hir().get_by_hir_id(hir_id) {
|
if let Node::Binding(pat) = self.ir.tcx.hir().get(hir_id) {
|
||||||
// Handle `ref` and `ref mut`.
|
// Handle `ref` and `ref mut`.
|
||||||
let spans = spans.iter()
|
let spans = spans.iter()
|
||||||
.map(|_span| (pat.span, format!("{}: _", name)))
|
.map(|_span| (pat.span, format!("{}: _", name)))
|
||||||
|
|
|
@ -344,7 +344,7 @@ impl MutabilityCategory {
|
||||||
tables: &ty::TypeckTables<'_>,
|
tables: &ty::TypeckTables<'_>,
|
||||||
id: hir::HirId,
|
id: hir::HirId,
|
||||||
) -> MutabilityCategory {
|
) -> MutabilityCategory {
|
||||||
let ret = match tcx.hir().get_by_hir_id(id) {
|
let ret = match tcx.hir().get(id) {
|
||||||
Node::Binding(p) => match p.node {
|
Node::Binding(p) => match p.node {
|
||||||
PatKind::Binding(..) => {
|
PatKind::Binding(..) => {
|
||||||
let bm = *tables.pat_binding_modes()
|
let bm = *tables.pat_binding_modes()
|
||||||
|
|
|
@ -190,7 +190,7 @@ impl Scope {
|
||||||
}
|
}
|
||||||
let span = tcx.hir().span(hir_id);
|
let span = tcx.hir().span(hir_id);
|
||||||
if let ScopeData::Remainder(first_statement_index) = self.data {
|
if let ScopeData::Remainder(first_statement_index) = self.data {
|
||||||
if let Node::Block(ref blk) = tcx.hir().get_by_hir_id(hir_id) {
|
if let Node::Block(ref blk) = tcx.hir().get(hir_id) {
|
||||||
// Want span for scope starting after the
|
// Want span for scope starting after the
|
||||||
// indexed statement and ending at end of
|
// indexed statement and ending at end of
|
||||||
// `blk`; reuse span of `blk` and shift `lo`
|
// `blk`; reuse span of `blk` and shift `lo`
|
||||||
|
@ -1368,7 +1368,7 @@ fn region_scope_tree<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx ScopeTree
|
||||||
// If the item is an associated const or a method,
|
// If the item is an associated const or a method,
|
||||||
// record its impl/trait parent, as it can also have
|
// record its impl/trait parent, as it can also have
|
||||||
// lifetime parameters free in this body.
|
// lifetime parameters free in this body.
|
||||||
match tcx.hir().get_by_hir_id(id) {
|
match tcx.hir().get(id) {
|
||||||
Node::ImplItem(_) |
|
Node::ImplItem(_) |
|
||||||
Node::TraitItem(_) => {
|
Node::TraitItem(_) => {
|
||||||
visitor.scope_tree.root_parent = Some(tcx.hir().get_parent_item(id));
|
visitor.scope_tree.root_parent = Some(tcx.hir().get_parent_item(id));
|
||||||
|
|
|
@ -1488,7 +1488,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if let Node::Lifetime(hir_lifetime) = self.tcx.hir().get_by_hir_id(lifetime.hir_id) {
|
if let Node::Lifetime(hir_lifetime) = self.tcx.hir().get(lifetime.hir_id) {
|
||||||
if let Some(parent) = self.tcx.hir().find_by_hir_id(
|
if let Some(parent) = self.tcx.hir().find_by_hir_id(
|
||||||
self.tcx.hir().get_parent_item(hir_lifetime.hir_id))
|
self.tcx.hir().get_parent_item(hir_lifetime.hir_id))
|
||||||
{
|
{
|
||||||
|
@ -1569,7 +1569,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||||
Some(LifetimeUseSet::One(lifetime)) => {
|
Some(LifetimeUseSet::One(lifetime)) => {
|
||||||
let hir_id = self.tcx.hir().as_local_hir_id(def_id).unwrap();
|
let hir_id = self.tcx.hir().as_local_hir_id(def_id).unwrap();
|
||||||
debug!("hir id first={:?}", hir_id);
|
debug!("hir id first={:?}", hir_id);
|
||||||
if let Some((id, span, name)) = match self.tcx.hir().get_by_hir_id(hir_id) {
|
if let Some((id, span, name)) = match self.tcx.hir().get(hir_id) {
|
||||||
Node::Lifetime(hir_lifetime) => Some((
|
Node::Lifetime(hir_lifetime) => Some((
|
||||||
hir_lifetime.hir_id,
|
hir_lifetime.hir_id,
|
||||||
hir_lifetime.span,
|
hir_lifetime.span,
|
||||||
|
@ -1620,7 +1620,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
let hir_id = self.tcx.hir().as_local_hir_id(def_id).unwrap();
|
let hir_id = self.tcx.hir().as_local_hir_id(def_id).unwrap();
|
||||||
if let Some((id, span, name)) = match self.tcx.hir().get_by_hir_id(hir_id) {
|
if let Some((id, span, name)) = match self.tcx.hir().get(hir_id) {
|
||||||
Node::Lifetime(hir_lifetime) => Some((
|
Node::Lifetime(hir_lifetime) => Some((
|
||||||
hir_lifetime.hir_id,
|
hir_lifetime.hir_id,
|
||||||
hir_lifetime.span,
|
hir_lifetime.span,
|
||||||
|
@ -1823,7 +1823,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||||
// Do not free early-bound regions, only late-bound ones.
|
// Do not free early-bound regions, only late-bound ones.
|
||||||
} else if let Some(body_id) = outermost_body {
|
} else if let Some(body_id) = outermost_body {
|
||||||
let fn_id = self.tcx.hir().body_owner(body_id);
|
let fn_id = self.tcx.hir().body_owner(body_id);
|
||||||
match self.tcx.hir().get_by_hir_id(fn_id) {
|
match self.tcx.hir().get(fn_id) {
|
||||||
Node::Item(&hir::Item {
|
Node::Item(&hir::Item {
|
||||||
node: hir::ItemKind::Fn(..),
|
node: hir::ItemKind::Fn(..),
|
||||||
..
|
..
|
||||||
|
@ -2052,7 +2052,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||||
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_by_hir_id(output.hir_id);
|
||||||
let body = match self.tcx.hir().get_by_hir_id(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 {
|
||||||
node: hir::ItemKind::Fn(.., body),
|
node: hir::ItemKind::Fn(.., body),
|
||||||
|
|
|
@ -580,7 +580,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
|
|
||||||
let mut diag = self.struct_span_lint_hir(lint, id, span, &msg);
|
let mut diag = self.struct_span_lint_hir(lint, id, span, &msg);
|
||||||
if let Some(suggestion) = suggestion {
|
if let Some(suggestion) = suggestion {
|
||||||
if let hir::Node::Expr(_) = self.hir().get_by_hir_id(id) {
|
if let hir::Node::Expr(_) = self.hir().get(id) {
|
||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
span,
|
span,
|
||||||
"replace the use of the deprecated item",
|
"replace the use of the deprecated item",
|
||||||
|
|
|
@ -2573,7 +2573,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
|
||||||
|
|
||||||
if let Some(upvars) = tcx.upvars(def_id) {
|
if let Some(upvars) = tcx.upvars(def_id) {
|
||||||
for (&var_id, place) in upvars.keys().zip(places) {
|
for (&var_id, place) in upvars.keys().zip(places) {
|
||||||
let var_name = tcx.hir().name_by_hir_id(var_id);
|
let var_name = tcx.hir().name(var_id);
|
||||||
struct_fmt.field(&var_name.as_str(), place);
|
struct_fmt.field(&var_name.as_str(), place);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2592,7 +2592,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
|
||||||
|
|
||||||
if let Some(upvars) = tcx.upvars(def_id) {
|
if let Some(upvars) = tcx.upvars(def_id) {
|
||||||
for (&var_id, place) in upvars.keys().zip(places) {
|
for (&var_id, place) in upvars.keys().zip(places) {
|
||||||
let var_name = tcx.hir().name_by_hir_id(var_id);
|
let var_name = tcx.hir().name(var_id);
|
||||||
struct_fmt.field(&var_name.as_str(), place);
|
struct_fmt.field(&var_name.as_str(), place);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -937,9 +937,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
code: &ObligationCauseCode<'tcx>,
|
code: &ObligationCauseCode<'tcx>,
|
||||||
err: &mut DiagnosticBuilder<'tcx>,
|
err: &mut DiagnosticBuilder<'tcx>,
|
||||||
) {
|
) {
|
||||||
if let &ObligationCauseCode::VariableType(node_id) = code {
|
if let &ObligationCauseCode::VariableType(hir_id) = code {
|
||||||
let parent_node = self.tcx.hir().get_parent_node(node_id);
|
let parent_node = self.tcx.hir().get_parent_node_by_hir_id(hir_id);
|
||||||
if let Some(Node::Local(ref local)) = self.tcx.hir().find(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 {
|
||||||
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(expr.span) {
|
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(expr.span) {
|
||||||
|
|
|
@ -188,7 +188,7 @@ pub enum ObligationCauseCode<'tcx> {
|
||||||
/// S { ... } must be Sized
|
/// S { ... } must be Sized
|
||||||
StructInitializerSized,
|
StructInitializerSized,
|
||||||
/// Type of each variable must be Sized
|
/// Type of each variable must be Sized
|
||||||
VariableType(ast::NodeId),
|
VariableType(hir::HirId),
|
||||||
/// Argument type must be Sized
|
/// Argument type must be Sized
|
||||||
SizedArgumentType,
|
SizedArgumentType,
|
||||||
/// Return type must be Sized
|
/// Return type must be Sized
|
||||||
|
|
|
@ -73,7 +73,7 @@ pub fn provide<'tcx>(providers: &mut Providers<'tcx>) {
|
||||||
let hir_id = tcx.hir().as_local_hir_id(def_id)
|
let hir_id = tcx.hir().as_local_hir_id(def_id)
|
||||||
.expect("Non-local call to local provider is_const_fn");
|
.expect("Non-local call to local provider is_const_fn");
|
||||||
|
|
||||||
let node = tcx.hir().get_by_hir_id(hir_id);
|
let node = tcx.hir().get(hir_id);
|
||||||
if let Some(fn_like) = FnLikeNode::from_node(node) {
|
if let Some(fn_like) = FnLikeNode::from_node(node) {
|
||||||
fn_like.constness() == hir::Constness::Const
|
fn_like.constness() == hir::Constness::Const
|
||||||
} else if let hir::Node::Ctor(_) = node {
|
} else if let hir::Node::Ctor(_) = node {
|
||||||
|
|
|
@ -1610,7 +1610,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
) -> Option<Ty<'tcx>> {
|
) -> Option<Ty<'tcx>> {
|
||||||
// HACK: `type_of_def_id()` will fail on these (#55796), so return None
|
// HACK: `type_of_def_id()` will fail on these (#55796), so return None
|
||||||
let hir_id = self.hir().as_local_hir_id(scope_def_id).unwrap();
|
let hir_id = self.hir().as_local_hir_id(scope_def_id).unwrap();
|
||||||
match self.hir().get_by_hir_id(hir_id) {
|
match self.hir().get(hir_id) {
|
||||||
Node::Item(item) => {
|
Node::Item(item) => {
|
||||||
match item.node {
|
match item.node {
|
||||||
ItemKind::Fn(..) => { /* type_of_def_id() will work */ }
|
ItemKind::Fn(..) => { /* type_of_def_id() will work */ }
|
||||||
|
|
|
@ -2777,20 +2777,6 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn expr_span(self, id: NodeId) -> Span {
|
|
||||||
match self.hir().find(id) {
|
|
||||||
Some(Node::Expr(e)) => {
|
|
||||||
e.span
|
|
||||||
}
|
|
||||||
Some(f) => {
|
|
||||||
bug!("node-ID {} is not an expr: {:?}", id, f);
|
|
||||||
}
|
|
||||||
None => {
|
|
||||||
bug!("node-ID {} is not present in the node map", id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn provided_trait_methods(self, id: DefId) -> Vec<AssocItem> {
|
pub fn provided_trait_methods(self, id: DefId) -> Vec<AssocItem> {
|
||||||
self.associated_items(id)
|
self.associated_items(id)
|
||||||
.filter(|item| item.kind == AssocKind::Method && item.defaultness.has_value())
|
.filter(|item| item.kind == AssocKind::Method && item.defaultness.has_value())
|
||||||
|
@ -2805,7 +2791,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
|
|
||||||
pub fn opt_associated_item(self, def_id: DefId) -> Option<AssocItem> {
|
pub fn opt_associated_item(self, def_id: DefId) -> Option<AssocItem> {
|
||||||
let is_associated_item = if let Some(hir_id) = self.hir().as_local_hir_id(def_id) {
|
let is_associated_item = if let Some(hir_id) = self.hir().as_local_hir_id(def_id) {
|
||||||
match self.hir().get_by_hir_id(hir_id) {
|
match self.hir().get(hir_id) {
|
||||||
Node::TraitItem(_) | Node::ImplItem(_) => true,
|
Node::TraitItem(_) | Node::ImplItem(_) => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
|
@ -3227,7 +3213,7 @@ fn trait_of_item<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Option<DefId> {
|
||||||
/// Yields the parent function's `DefId` if `def_id` is an `impl Trait` definition.
|
/// Yields the parent function's `DefId` if `def_id` is an `impl Trait` definition.
|
||||||
pub fn is_impl_trait_defn(tcx: TyCtxt<'_>, def_id: DefId) -> Option<DefId> {
|
pub fn is_impl_trait_defn(tcx: TyCtxt<'_>, def_id: DefId) -> Option<DefId> {
|
||||||
if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) {
|
if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) {
|
||||||
if let Node::Item(item) = tcx.hir().get_by_hir_id(hir_id) {
|
if let Node::Item(item) = tcx.hir().get(hir_id) {
|
||||||
if let hir::ItemKind::Existential(ref exist_ty) = item.node {
|
if let hir::ItemKind::Existential(ref exist_ty) = item.node {
|
||||||
return exist_ty.impl_trait_fn;
|
return exist_ty.impl_trait_fn;
|
||||||
}
|
}
|
||||||
|
|
|
@ -600,7 +600,7 @@ pub trait PrettyPrinter<'tcx>:
|
||||||
p!(
|
p!(
|
||||||
write("{}{}:",
|
write("{}{}:",
|
||||||
sep,
|
sep,
|
||||||
self.tcx().hir().name_by_hir_id(var_id)),
|
self.tcx().hir().name(var_id)),
|
||||||
print(upvar_ty));
|
print(upvar_ty));
|
||||||
sep = ", ";
|
sep = ", ";
|
||||||
}
|
}
|
||||||
|
@ -643,7 +643,7 @@ pub trait PrettyPrinter<'tcx>:
|
||||||
p!(
|
p!(
|
||||||
write("{}{}:",
|
write("{}{}:",
|
||||||
sep,
|
sep,
|
||||||
self.tcx().hir().name_by_hir_id(var_id)),
|
self.tcx().hir().name(var_id)),
|
||||||
print(upvar_ty));
|
print(upvar_ty));
|
||||||
sep = ", ";
|
sep = ", ";
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ impl fmt::Debug for ty::ClosureUpvar<'tcx> {
|
||||||
impl fmt::Debug for ty::UpvarId {
|
impl fmt::Debug for ty::UpvarId {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
let name = ty::tls::with(|tcx| {
|
let name = ty::tls::with(|tcx| {
|
||||||
tcx.hir().name_by_hir_id(self.var_path.hir_id)
|
tcx.hir().name(self.var_path.hir_id)
|
||||||
});
|
});
|
||||||
write!(f, "UpvarId({:?};`{}`;{:?})",
|
write!(f, "UpvarId({:?};`{}`;{:?})",
|
||||||
self.var_path.hir_id,
|
self.var_path.hir_id,
|
||||||
|
|
|
@ -191,7 +191,7 @@ pub fn check_loans<'a, 'tcx>(
|
||||||
let def_id = bccx.tcx.hir().body_owner_def_id(body.id());
|
let def_id = bccx.tcx.hir().body_owner_def_id(body.id());
|
||||||
|
|
||||||
let hir_id = bccx.tcx.hir().as_local_hir_id(def_id).unwrap();
|
let hir_id = bccx.tcx.hir().as_local_hir_id(def_id).unwrap();
|
||||||
let movable_generator = !match bccx.tcx.hir().get_by_hir_id(hir_id) {
|
let movable_generator = !match bccx.tcx.hir().get(hir_id) {
|
||||||
Node::Expr(&hir::Expr {
|
Node::Expr(&hir::Expr {
|
||||||
node: hir::ExprKind::Closure(.., Some(hir::GeneratorMovability::Static)),
|
node: hir::ExprKind::Closure(.., Some(hir::GeneratorMovability::Static)),
|
||||||
..
|
..
|
||||||
|
|
|
@ -49,7 +49,7 @@ 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_by_hir_id(pat.hir_id);
|
||||||
|
|
||||||
match tcx.hir().get_by_hir_id(parent) {
|
match tcx.hir().get(parent) {
|
||||||
Node::Expr(ref e) => {
|
Node::Expr(ref e) => {
|
||||||
// the enclosing expression must be a `match` or something else
|
// the enclosing expression must be a `match` or something else
|
||||||
assert!(match e.node {
|
assert!(match e.node {
|
||||||
|
|
|
@ -80,7 +80,7 @@ fn borrowck<'tcx>(tcx: TyCtxt<'tcx>, owner_def_id: DefId) -> &'tcx BorrowCheckRe
|
||||||
|
|
||||||
let owner_id = tcx.hir().as_local_hir_id(owner_def_id).unwrap();
|
let owner_id = tcx.hir().as_local_hir_id(owner_def_id).unwrap();
|
||||||
|
|
||||||
match tcx.hir().get_by_hir_id(owner_id) {
|
match tcx.hir().get(owner_id) {
|
||||||
Node::Ctor(..) => {
|
Node::Ctor(..) => {
|
||||||
// We get invoked with anything that has MIR, but some of
|
// We get invoked with anything that has MIR, but some of
|
||||||
// those things (notably the synthesized constructors from
|
// those things (notably the synthesized constructors from
|
||||||
|
@ -390,7 +390,7 @@ pub enum LoanPathElem<'tcx> {
|
||||||
|
|
||||||
fn closure_to_block(closure_id: LocalDefId, tcx: TyCtxt<'_>) -> HirId {
|
fn closure_to_block(closure_id: LocalDefId, tcx: TyCtxt<'_>) -> HirId {
|
||||||
let closure_id = tcx.hir().local_def_id_to_hir_id(closure_id);
|
let closure_id = tcx.hir().local_def_id_to_hir_id(closure_id);
|
||||||
match tcx.hir().get_by_hir_id(closure_id) {
|
match tcx.hir().get(closure_id) {
|
||||||
Node::Expr(expr) => match expr.node {
|
Node::Expr(expr) => match expr.node {
|
||||||
hir::ExprKind::Closure(.., body_id, _, _) => {
|
hir::ExprKind::Closure(.., body_id, _, _) => {
|
||||||
body_id.hir_id
|
body_id.hir_id
|
||||||
|
@ -702,7 +702,7 @@ impl BorrowckCtxt<'_, 'tcx> {
|
||||||
move_data::MovePat => (self.tcx.hir().span(hir_id), ""),
|
move_data::MovePat => (self.tcx.hir().span(hir_id), ""),
|
||||||
|
|
||||||
move_data::Captured =>
|
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,
|
hir::ExprKind::Closure(.., fn_decl_span, _) => fn_decl_span,
|
||||||
ref r => bug!("Captured({:?}) maps to non-closure: {:?}",
|
ref r => bug!("Captured({:?}) maps to non-closure: {:?}",
|
||||||
the_move.id, r),
|
the_move.id, r),
|
||||||
|
@ -896,7 +896,7 @@ impl BorrowckCtxt<'_, 'tcx> {
|
||||||
// to implement two traits for "one operator" is not very intuitive for
|
// to implement two traits for "one operator" is not very intuitive for
|
||||||
// many programmers.
|
// many programmers.
|
||||||
if err.cmt.note == mc::NoteIndex {
|
if err.cmt.note == mc::NoteIndex {
|
||||||
let node = self.tcx.hir().get_by_hir_id(err.cmt.hir_id);
|
let node = self.tcx.hir().get(err.cmt.hir_id);
|
||||||
|
|
||||||
// This pattern probably always matches.
|
// This pattern probably always matches.
|
||||||
if let Node::Expr(
|
if let Node::Expr(
|
||||||
|
@ -1172,7 +1172,7 @@ impl BorrowckCtxt<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn local_binding_mode(&self, hir_id: hir::HirId) -> ty::BindingMode {
|
fn local_binding_mode(&self, hir_id: hir::HirId) -> ty::BindingMode {
|
||||||
let pat = match self.tcx.hir().get_by_hir_id(hir_id) {
|
let pat = match self.tcx.hir().get(hir_id) {
|
||||||
Node::Binding(pat) => pat,
|
Node::Binding(pat) => pat,
|
||||||
node => bug!("bad node for local: {:?}", node)
|
node => bug!("bad node for local: {:?}", node)
|
||||||
};
|
};
|
||||||
|
@ -1190,7 +1190,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_by_hir_id(hir_id);
|
||||||
let parent_node = self.tcx.hir().get_by_hir_id(parent);
|
let parent_node = self.tcx.hir().get(parent);
|
||||||
|
|
||||||
// The parent node is like a fn
|
// The parent node is like a fn
|
||||||
if let Some(fn_like) = FnLikeNode::from_node(parent_node) {
|
if let Some(fn_like) = FnLikeNode::from_node(parent_node) {
|
||||||
|
@ -1255,7 +1255,7 @@ impl BorrowckCtxt<'_, 'tcx> {
|
||||||
None => return
|
None => return
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Node::Field(ref field) = self.tcx.hir().get_by_hir_id(hir_id) {
|
if let Node::Field(ref field) = self.tcx.hir().get(hir_id) {
|
||||||
if let Some(msg) = self.suggest_mut_for_immutable(&field.ty, false) {
|
if let Some(msg) = self.suggest_mut_for_immutable(&field.ty, false) {
|
||||||
db.span_label(field.ty.span, msg);
|
db.span_label(field.ty.span, msg);
|
||||||
}
|
}
|
||||||
|
@ -1394,10 +1394,10 @@ impl BorrowckCtxt<'_, 'tcx> {
|
||||||
out: &mut String) {
|
out: &mut String) {
|
||||||
match loan_path.kind {
|
match loan_path.kind {
|
||||||
LpUpvar(ty::UpvarId { var_path: ty::UpvarPath { hir_id: id }, closure_expr_id: _ }) => {
|
LpUpvar(ty::UpvarId { var_path: ty::UpvarPath { hir_id: id }, closure_expr_id: _ }) => {
|
||||||
out.push_str(&self.tcx.hir().name_by_hir_id(id).as_str());
|
out.push_str(&self.tcx.hir().name(id).as_str());
|
||||||
}
|
}
|
||||||
LpVar(id) => {
|
LpVar(id) => {
|
||||||
out.push_str(&self.tcx.hir().name_by_hir_id(id).as_str());
|
out.push_str(&self.tcx.hir().name(id).as_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
LpDowncast(ref lp_base, variant_def_id) => {
|
LpDowncast(ref lp_base, variant_def_id) => {
|
||||||
|
|
|
@ -210,7 +210,7 @@ impl CodegenCx<'ll, 'tcx> {
|
||||||
let g = if let Some(id) = self.tcx.hir().as_local_hir_id(def_id) {
|
let g = if let Some(id) = self.tcx.hir().as_local_hir_id(def_id) {
|
||||||
|
|
||||||
let llty = self.layout_of(ty).llvm_type(self);
|
let llty = self.layout_of(ty).llvm_type(self);
|
||||||
let (g, attrs) = match self.tcx.hir().get_by_hir_id(id) {
|
let (g, attrs) = match self.tcx.hir().get(id) {
|
||||||
Node::Item(&hir::Item {
|
Node::Item(&hir::Item {
|
||||||
ref attrs, span, node: hir::ItemKind::Static(..), ..
|
ref attrs, span, node: hir::ItemKind::Static(..), ..
|
||||||
}) => {
|
}) => {
|
||||||
|
|
|
@ -82,7 +82,7 @@ fn reachable_non_generics_provider<'tcx>(
|
||||||
//
|
//
|
||||||
// As a result, if this id is an FFI item (foreign item) then we only
|
// As a result, if this id is an FFI item (foreign item) then we only
|
||||||
// let it through if it's included statically.
|
// let it through if it's included statically.
|
||||||
match tcx.hir().get_by_hir_id(hir_id) {
|
match tcx.hir().get(hir_id) {
|
||||||
Node::ForeignItem(..) => {
|
Node::ForeignItem(..) => {
|
||||||
let def_id = tcx.hir().local_def_id_from_hir_id(hir_id);
|
let def_id = tcx.hir().local_def_id_from_hir_id(hir_id);
|
||||||
if tcx.is_statically_included_foreign_item(def_id) {
|
if tcx.is_statically_included_foreign_item(def_id) {
|
||||||
|
|
|
@ -135,7 +135,7 @@ fn symbol_name(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> InternedString {
|
||||||
|
|
||||||
// FIXME(eddyb) Precompute a custom symbol name based on attributes.
|
// FIXME(eddyb) Precompute a custom symbol name based on attributes.
|
||||||
let is_foreign = if let Some(id) = hir_id {
|
let is_foreign = if let Some(id) = hir_id {
|
||||||
match tcx.hir().get_by_hir_id(id) {
|
match tcx.hir().get(id) {
|
||||||
Node::ForeignItem(_) => true,
|
Node::ForeignItem(_) => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
|
|
|
@ -627,7 +627,7 @@ fn print_flowgraph<'tcx, W: Write>(
|
||||||
// Find the function this expression is from.
|
// Find the function this expression is from.
|
||||||
let mut hir_id = expr.hir_id;
|
let mut hir_id = expr.hir_id;
|
||||||
loop {
|
loop {
|
||||||
let node = tcx.hir().get_by_hir_id(hir_id);
|
let node = tcx.hir().get(hir_id);
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
@ -830,7 +830,8 @@ pub fn print_after_hir_lowering<'tcx>(
|
||||||
box out,
|
box out,
|
||||||
annotation.pp_ann());
|
annotation.pp_ann());
|
||||||
for node_id in uii.all_matching_node_ids(hir_map) {
|
for node_id in uii.all_matching_node_ids(hir_map) {
|
||||||
let node = hir_map.get(node_id);
|
let hir_id = tcx.hir().node_to_hir_id(node_id);
|
||||||
|
let node = hir_map.get(hir_id);
|
||||||
pp_state.print_node(node)?;
|
pp_state.print_node(node)?;
|
||||||
pp_state.s.space()?;
|
pp_state.s.space()?;
|
||||||
let path = annotation.node_path(node_id)
|
let path = annotation.node_path(node_id)
|
||||||
|
@ -847,7 +848,8 @@ pub fn print_after_hir_lowering<'tcx>(
|
||||||
s.call_with_pp_support_hir(tcx, move |_annotation, _krate| {
|
s.call_with_pp_support_hir(tcx, move |_annotation, _krate| {
|
||||||
debug!("pretty printing source code {:?}", s);
|
debug!("pretty printing source code {:?}", s);
|
||||||
for node_id in uii.all_matching_node_ids(tcx.hir()) {
|
for node_id in uii.all_matching_node_ids(tcx.hir()) {
|
||||||
let node = tcx.hir().get(node_id);
|
let hir_id = tcx.hir().node_to_hir_id(node_id);
|
||||||
|
let node = tcx.hir().get(hir_id);
|
||||||
write!(out, "{:#?}", node)?;
|
write!(out, "{:#?}", node)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -909,7 +911,8 @@ fn print_with_analysis<'tcx>(
|
||||||
tcx.sess.fatal(&format!("--pretty flowgraph couldn't find id: {}", nodeid))
|
tcx.sess.fatal(&format!("--pretty flowgraph couldn't find id: {}", nodeid))
|
||||||
});
|
});
|
||||||
|
|
||||||
match blocks::Code::from_node(&tcx.hir(), nodeid) {
|
let hir_id = tcx.hir().node_to_hir_id(nodeid);
|
||||||
|
match blocks::Code::from_node(&tcx.hir(), hir_id) {
|
||||||
Some(code) => {
|
Some(code) => {
|
||||||
let variants = gather_flowgraph_variants(tcx.sess);
|
let variants = gather_flowgraph_variants(tcx.sess);
|
||||||
|
|
||||||
|
|
|
@ -322,7 +322,7 @@ impl DirtyCleanVisitor<'tcx> {
|
||||||
/// Return all DepNode labels that should be asserted for this item.
|
/// Return all DepNode labels that should be asserted for this item.
|
||||||
/// index=0 is the "name" used for error messages
|
/// index=0 is the "name" used for error messages
|
||||||
fn auto_labels(&mut self, item_id: hir::HirId, attr: &Attribute) -> (&'static str, Labels) {
|
fn auto_labels(&mut self, item_id: hir::HirId, attr: &Attribute) -> (&'static str, Labels) {
|
||||||
let node = self.tcx.hir().get_by_hir_id(item_id);
|
let node = self.tcx.hir().get(item_id);
|
||||||
let (name, labels) = match node {
|
let (name, labels) = match node {
|
||||||
HirNode::Item(item) => {
|
HirNode::Item(item) => {
|
||||||
match item.node {
|
match item.node {
|
||||||
|
|
|
@ -276,7 +276,7 @@ fn lint_int_literal<'a, 'tcx>(
|
||||||
}
|
}
|
||||||
|
|
||||||
let par_id = cx.tcx.hir().get_parent_node_by_hir_id(e.hir_id);
|
let par_id = cx.tcx.hir().get_parent_node_by_hir_id(e.hir_id);
|
||||||
if let Node::Expr(par_e) = cx.tcx.hir().get_by_hir_id(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)
|
||||||
&& lint_overflowing_range_endpoint(cx, lit, v, max, e, par_e, t)
|
&& lint_overflowing_range_endpoint(cx, lit, v, max, e, par_e, t)
|
||||||
|
@ -315,7 +315,7 @@ fn lint_uint_literal<'a, 'tcx>(
|
||||||
};
|
};
|
||||||
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_by_hir_id(e.hir_id);
|
||||||
if let Node::Expr(par_e) = cx.tcx.hir().get_by_hir_id(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(..) => {
|
||||||
if let ty::Char = cx.tables.expr_ty(par_e).sty {
|
if let ty::Char = cx.tables.expr_ty(par_e).sty {
|
||||||
|
|
|
@ -853,7 +853,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
format!(
|
format!(
|
||||||
"...but `{}` will be dropped here, when the function `{}` returns",
|
"...but `{}` will be dropped here, when the function `{}` returns",
|
||||||
name,
|
name,
|
||||||
self.infcx.tcx.hir().name_by_hir_id(fn_hir_id),
|
self.infcx.tcx.hir().name(fn_hir_id),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -349,7 +349,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
let (&var_id, _) = self.infcx.tcx.upvars(def_id).unwrap()
|
let (&var_id, _) = self.infcx.tcx.upvars(def_id).unwrap()
|
||||||
.get_index(field.index()).unwrap();
|
.get_index(field.index()).unwrap();
|
||||||
|
|
||||||
self.infcx.tcx.hir().name_by_hir_id(var_id).to_string()
|
self.infcx.tcx.hir().name(var_id).to_string()
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
// Might need a revision when the fields in trait RFC is implemented
|
// Might need a revision when the fields in trait RFC is implemented
|
||||||
|
@ -659,7 +659,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
def_id, target_place, places
|
def_id, target_place, places
|
||||||
);
|
);
|
||||||
let hir_id = self.infcx.tcx.hir().as_local_hir_id(def_id)?;
|
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);
|
debug!("closure_span: hir_id={:?} expr={:?}", hir_id, expr);
|
||||||
if let hir::ExprKind::Closure(
|
if let hir::ExprKind::Closure(
|
||||||
.., args_span, _
|
.., args_span, _
|
||||||
|
|
|
@ -124,14 +124,13 @@ fn do_mir_borrowck<'a, 'tcx>(
|
||||||
.flat_map(|v| v.values())
|
.flat_map(|v| v.values())
|
||||||
.map(|upvar_id| {
|
.map(|upvar_id| {
|
||||||
let var_hir_id = upvar_id.var_path.hir_id;
|
let var_hir_id = upvar_id.var_path.hir_id;
|
||||||
let var_node_id = tcx.hir().hir_to_node_id(var_hir_id);
|
|
||||||
let capture = tables.upvar_capture(*upvar_id);
|
let capture = tables.upvar_capture(*upvar_id);
|
||||||
let by_ref = match capture {
|
let by_ref = match capture {
|
||||||
ty::UpvarCapture::ByValue => false,
|
ty::UpvarCapture::ByValue => false,
|
||||||
ty::UpvarCapture::ByRef(..) => true,
|
ty::UpvarCapture::ByRef(..) => true,
|
||||||
};
|
};
|
||||||
let mut upvar = Upvar {
|
let mut upvar = Upvar {
|
||||||
name: tcx.hir().name(var_node_id),
|
name: tcx.hir().name(var_hir_id),
|
||||||
var_hir_id,
|
var_hir_id,
|
||||||
by_ref,
|
by_ref,
|
||||||
mutability: Mutability::Not,
|
mutability: Mutability::Not,
|
||||||
|
@ -231,7 +230,7 @@ fn do_mir_borrowck<'a, 'tcx>(
|
||||||
|bd, i| DebugFormatted::new(&bd.move_data().inits[i]),
|
|bd, i| DebugFormatted::new(&bd.move_data().inits[i]),
|
||||||
));
|
));
|
||||||
|
|
||||||
let movable_generator = match tcx.hir().get_by_hir_id(id) {
|
let movable_generator = match tcx.hir().get(id) {
|
||||||
Node::Expr(&hir::Expr {
|
Node::Expr(&hir::Expr {
|
||||||
node: hir::ExprKind::Closure(.., Some(hir::GeneratorMovability::Static)),
|
node: hir::ExprKind::Closure(.., Some(hir::GeneratorMovability::Static)),
|
||||||
..
|
..
|
||||||
|
|
|
@ -237,7 +237,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||||
|
|
||||||
if let DefiningTy::Closure(def_id, substs) = def_ty {
|
if let DefiningTy::Closure(def_id, substs) = def_ty {
|
||||||
let args_span = if let hir::ExprKind::Closure(_, _, _, span, _) =
|
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
|
span
|
||||||
} else {
|
} else {
|
||||||
|
@ -698,7 +698,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||||
|
|
||||||
let mir_hir_id = tcx.hir().as_local_hir_id(mir_def_id).expect("non-local mir");
|
let mir_hir_id = tcx.hir().as_local_hir_id(mir_def_id).expect("non-local mir");
|
||||||
|
|
||||||
let (return_span, mir_description) = match tcx.hir().get_by_hir_id(mir_hir_id) {
|
let (return_span, mir_description) = match tcx.hir().get(mir_hir_id) {
|
||||||
hir::Node::Expr(hir::Expr {
|
hir::Node::Expr(hir::Expr {
|
||||||
node: hir::ExprKind::Closure(_, return_ty, _, span, gen_move),
|
node: hir::ExprKind::Closure(_, return_ty, _, span, gen_move),
|
||||||
..
|
..
|
||||||
|
@ -761,7 +761,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||||
|
|
||||||
let mir_hir_id = tcx.hir().as_local_hir_id(mir_def_id).expect("non-local mir");
|
let mir_hir_id = tcx.hir().as_local_hir_id(mir_def_id).expect("non-local mir");
|
||||||
|
|
||||||
let yield_span = match tcx.hir().get_by_hir_id(mir_hir_id) {
|
let yield_span = match tcx.hir().get(mir_hir_id) {
|
||||||
hir::Node::Expr(hir::Expr {
|
hir::Node::Expr(hir::Expr {
|
||||||
node: hir::ExprKind::Closure(_, _, _, span, _),
|
node: hir::ExprKind::Closure(_, _, _, span, _),
|
||||||
..
|
..
|
||||||
|
|
|
@ -72,7 +72,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||||
let upvar_hir_id = upvars[upvar_index].var_hir_id;
|
let upvar_hir_id = upvars[upvar_index].var_hir_id;
|
||||||
debug!("get_upvar_name_and_span_for_region: upvar_hir_id={:?}", upvar_hir_id);
|
debug!("get_upvar_name_and_span_for_region: upvar_hir_id={:?}", upvar_hir_id);
|
||||||
|
|
||||||
let upvar_name = tcx.hir().name_by_hir_id(upvar_hir_id);
|
let upvar_name = tcx.hir().name(upvar_hir_id);
|
||||||
let upvar_span = tcx.hir().span(upvar_hir_id);
|
let upvar_span = tcx.hir().span(upvar_hir_id);
|
||||||
debug!("get_upvar_name_and_span_for_region: upvar_name={:?} upvar_span={:?}",
|
debug!("get_upvar_name_and_span_for_region: upvar_name={:?} upvar_span={:?}",
|
||||||
upvar_name, upvar_span);
|
upvar_name, upvar_span);
|
||||||
|
|
|
@ -767,7 +767,7 @@ fn for_each_late_bound_region_defined_on<'tcx>(
|
||||||
owner: fn_def_id.index,
|
owner: fn_def_id.index,
|
||||||
local_id: *late_bound,
|
local_id: *late_bound,
|
||||||
};
|
};
|
||||||
let name = tcx.hir().name_by_hir_id(hir_id).as_interned_str();
|
let name = tcx.hir().name(hir_id).as_interned_str();
|
||||||
let region_def_id = tcx.hir().local_def_id_from_hir_id(hir_id);
|
let region_def_id = tcx.hir().local_def_id_from_hir_id(hir_id);
|
||||||
let liberated_region = tcx.mk_region(ty::ReFree(ty::FreeRegion {
|
let liberated_region = tcx.mk_region(ty::ReFree(ty::FreeRegion {
|
||||||
scope: fn_def_id,
|
scope: fn_def_id,
|
||||||
|
|
|
@ -26,7 +26,7 @@ pub fn mir_build<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Body<'tcx> {
|
||||||
let id = tcx.hir().as_local_hir_id(def_id).unwrap();
|
let id = tcx.hir().as_local_hir_id(def_id).unwrap();
|
||||||
|
|
||||||
// Figure out what primary body this item has.
|
// Figure out what primary body this item has.
|
||||||
let (body_id, return_ty_span) = match tcx.hir().get_by_hir_id(id) {
|
let (body_id, return_ty_span) = match tcx.hir().get(id) {
|
||||||
Node::Expr(hir::Expr { node: hir::ExprKind::Closure(_, decl, body_id, _, _), .. })
|
Node::Expr(hir::Expr { node: hir::ExprKind::Closure(_, decl, body_id, _, _), .. })
|
||||||
| Node::Item(hir::Item { node: hir::ItemKind::Fn(decl, _, _, body_id), .. })
|
| Node::Item(hir::Item { node: hir::ItemKind::Fn(decl, _, _, body_id), .. })
|
||||||
| Node::ImplItem(
|
| Node::ImplItem(
|
||||||
|
|
|
@ -914,7 +914,7 @@ fn convert_path_expr<'a, 'tcx>(
|
||||||
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);
|
||||||
let index = generics.param_def_id_to_index[&local_def_id];
|
let index = generics.param_def_id_to_index[&local_def_id];
|
||||||
let name = cx.tcx.hir().name_by_hir_id(hir_id).as_interned_str();
|
let name = cx.tcx.hir().name(hir_id).as_interned_str();
|
||||||
let val = ConstValue::Param(ty::ParamConst::new(index, name));
|
let val = ConstValue::Param(ty::ParamConst::new(index, name));
|
||||||
ExprKind::Literal {
|
ExprKind::Literal {
|
||||||
literal: cx.tcx.mk_const(
|
literal: cx.tcx.mk_const(
|
||||||
|
|
|
@ -155,7 +155,7 @@ impl<'a, 'tcx> Cx<'a, 'tcx> {
|
||||||
|
|
||||||
pub fn pattern_from_hir(&mut self, p: &hir::Pat) -> Pattern<'tcx> {
|
pub fn pattern_from_hir(&mut self, p: &hir::Pat) -> Pattern<'tcx> {
|
||||||
let tcx = self.tcx.global_tcx();
|
let tcx = self.tcx.global_tcx();
|
||||||
let p = match tcx.hir().get_by_hir_id(p.hir_id) {
|
let p = match tcx.hir().get(p.hir_id) {
|
||||||
Node::Pat(p) | Node::Binding(p) => p,
|
Node::Pat(p) | Node::Binding(p) => p,
|
||||||
node => bug!("pattern became {:?}", node)
|
node => bug!("pattern became {:?}", node)
|
||||||
};
|
};
|
||||||
|
|
|
@ -193,7 +193,7 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, 'tcx, M
|
||||||
// Sometimes the index is beyond the number of upvars (seen
|
// Sometimes the index is beyond the number of upvars (seen
|
||||||
// for a generator).
|
// for a generator).
|
||||||
if let Some((&var_hir_id, _)) = upvars.get_index(field) {
|
if let Some((&var_hir_id, _)) = upvars.get_index(field) {
|
||||||
let node = self.ecx.tcx.hir().get_by_hir_id(var_hir_id);
|
let node = self.ecx.tcx.hir().get(var_hir_id);
|
||||||
if let hir::Node::Binding(pat) = node {
|
if let hir::Node::Binding(pat) = node {
|
||||||
if let hir::PatKind::Binding(_, _, ident, _) = pat.node {
|
if let hir::PatKind::Binding(_, _, ident, _) = pat.node {
|
||||||
name = Some(ident.name);
|
name = Some(ident.name);
|
||||||
|
|
|
@ -10,7 +10,7 @@ use rustc::ty::subst::InternalSubsts;
|
||||||
pub fn check(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, def_id: DefId) {
|
pub fn check(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, def_id: DefId) {
|
||||||
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
|
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
|
||||||
|
|
||||||
if let Some(fn_like_node) = FnLikeNode::from_node(tcx.hir().get_by_hir_id(hir_id)) {
|
if let Some(fn_like_node) = FnLikeNode::from_node(tcx.hir().get(hir_id)) {
|
||||||
check_fn_for_unconditional_recursion(tcx, fn_like_node.kind(), body, def_id);
|
check_fn_for_unconditional_recursion(tcx, fn_like_node.kind(), body, def_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ impl MirPass for ConstProp {
|
||||||
let hir_id = tcx.hir().as_local_hir_id(source.def_id())
|
let hir_id = tcx.hir().as_local_hir_id(source.def_id())
|
||||||
.expect("Non-local call to local provider is_const_fn");
|
.expect("Non-local call to local provider is_const_fn");
|
||||||
|
|
||||||
let is_fn_like = FnLikeNode::from_node(tcx.hir().get_by_hir_id(hir_id)).is_some();
|
let is_fn_like = FnLikeNode::from_node(tcx.hir().get(hir_id)).is_some();
|
||||||
let is_assoc_const = match tcx.def_kind(source.def_id()) {
|
let is_assoc_const = match tcx.def_kind(source.def_id()) {
|
||||||
Some(DefKind::AssocConst) => true,
|
Some(DefKind::AssocConst) => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
|
|
|
@ -116,7 +116,7 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> {
|
||||||
let loop_kind = if loop_id == hir::DUMMY_HIR_ID {
|
let loop_kind = if loop_id == hir::DUMMY_HIR_ID {
|
||||||
None
|
None
|
||||||
} else {
|
} 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::While(..) => LoopKind::WhileLoop,
|
||||||
hir::ExprKind::Loop(_, _, source) => LoopKind::Loop(source),
|
hir::ExprKind::Loop(_, _, source) => LoopKind::Loop(source),
|
||||||
ref r => span_bug!(e.span,
|
ref r => span_bug!(e.span,
|
||||||
|
|
|
@ -229,14 +229,14 @@ fn def_id_visibility<'tcx>(
|
||||||
) -> (ty::Visibility, Span, &'static str) {
|
) -> (ty::Visibility, Span, &'static str) {
|
||||||
match tcx.hir().as_local_hir_id(def_id) {
|
match tcx.hir().as_local_hir_id(def_id) {
|
||||||
Some(hir_id) => {
|
Some(hir_id) => {
|
||||||
let vis = match tcx.hir().get_by_hir_id(hir_id) {
|
let vis = match tcx.hir().get(hir_id) {
|
||||||
Node::Item(item) => &item.vis,
|
Node::Item(item) => &item.vis,
|
||||||
Node::ForeignItem(foreign_item) => &foreign_item.vis,
|
Node::ForeignItem(foreign_item) => &foreign_item.vis,
|
||||||
Node::TraitItem(..) | Node::Variant(..) => {
|
Node::TraitItem(..) | Node::Variant(..) => {
|
||||||
return def_id_visibility(tcx, tcx.hir().get_parent_did(hir_id));
|
return def_id_visibility(tcx, tcx.hir().get_parent_did(hir_id));
|
||||||
}
|
}
|
||||||
Node::ImplItem(impl_item) => {
|
Node::ImplItem(impl_item) => {
|
||||||
match tcx.hir().get_by_hir_id(tcx.hir().get_parent_item(hir_id)) {
|
match tcx.hir().get(tcx.hir().get_parent_item(hir_id)) {
|
||||||
Node::Item(item) => match &item.node {
|
Node::Item(item) => match &item.node {
|
||||||
hir::ItemKind::Impl(.., None, _, _) => &impl_item.vis,
|
hir::ItemKind::Impl(.., None, _, _) => &impl_item.vis,
|
||||||
hir::ItemKind::Impl(.., Some(trait_ref), _, _)
|
hir::ItemKind::Impl(.., Some(trait_ref), _, _)
|
||||||
|
@ -248,7 +248,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_by_hir_id(hir_id);
|
||||||
match tcx.hir().get_by_hir_id(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);
|
||||||
let (mut ctor_vis, mut span, mut descr) = def_id_visibility(
|
let (mut ctor_vis, mut span, mut descr) = def_id_visibility(
|
||||||
|
@ -274,7 +274,7 @@ fn def_id_visibility<'tcx>(
|
||||||
return (ctor_vis, span, descr);
|
return (ctor_vis, span, descr);
|
||||||
}
|
}
|
||||||
Node::Item(..) => {
|
Node::Item(..) => {
|
||||||
let item = match tcx.hir().get_by_hir_id(parent_hir_id) {
|
let item = match tcx.hir().get(parent_hir_id) {
|
||||||
Node::Item(item) => item,
|
Node::Item(item) => item,
|
||||||
node => bug!("unexpected node kind: {:?}", node),
|
node => bug!("unexpected node kind: {:?}", node),
|
||||||
};
|
};
|
||||||
|
|
|
@ -1531,7 +1531,8 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tcx, '
|
||||||
self.process_macro_use(ex.span);
|
self.process_macro_use(ex.span);
|
||||||
match ex.node {
|
match ex.node {
|
||||||
ast::ExprKind::Struct(ref path, ref fields, ref base) => {
|
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(expr_hir_id);
|
||||||
let adt = match self.save_ctxt.tables.expr_ty_opt(&hir_expr) {
|
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(),
|
Some(ty) if ty.ty_adt_def().is_some() => ty.ty_adt_def().unwrap(),
|
||||||
_ => {
|
_ => {
|
||||||
|
|
|
@ -513,7 +513,8 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_expr_data(&self, expr: &ast::Expr) -> Option<Data> {
|
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(expr_hir_id);
|
||||||
let ty = self.tables.expr_ty_adjusted_opt(&hir_node);
|
let ty = self.tables.expr_ty_adjusted_opt(&hir_node);
|
||||||
if ty.is_none() || ty.unwrap().sty == ty::Error {
|
if ty.is_none() || ty.unwrap().sty == ty::Error {
|
||||||
return None;
|
return None;
|
||||||
|
@ -606,7 +607,8 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_path_res(&self, id: NodeId) -> Res {
|
pub fn get_path_res(&self, id: NodeId) -> Res {
|
||||||
match self.tcx.hir().get(id) {
|
let hir_id = self.tcx.hir().node_to_hir_id(id);
|
||||||
|
match self.tcx.hir().get(hir_id) {
|
||||||
Node::TraitRef(tr) => tr.path.res,
|
Node::TraitRef(tr) => tr.path.res,
|
||||||
|
|
||||||
Node::Item(&hir::Item {
|
Node::Item(&hir::Item {
|
||||||
|
@ -627,7 +629,6 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
|
||||||
node: hir::ExprKind::Struct(ref qpath, ..),
|
node: hir::ExprKind::Struct(ref qpath, ..),
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
let hir_id = self.tcx.hir().node_to_hir_id(id);
|
|
||||||
self.tables.qpath_res(qpath, hir_id)
|
self.tables.qpath_res(qpath, hir_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -651,7 +652,6 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
|
||||||
node: hir::TyKind::Path(ref qpath),
|
node: hir::TyKind::Path(ref qpath),
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
let hir_id = self.tcx.hir().node_to_hir_id(id);
|
|
||||||
self.tables.qpath_res(qpath, hir_id)
|
self.tables.qpath_res(qpath, hir_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -185,7 +185,7 @@ crate fn environment<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Environment<'tcx
|
||||||
.map(Clause::ForAll);
|
.map(Clause::ForAll);
|
||||||
|
|
||||||
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 node = tcx.hir().get_by_hir_id(hir_id);
|
let node = tcx.hir().get(hir_id);
|
||||||
|
|
||||||
enum NodeKind {
|
enum NodeKind {
|
||||||
TraitImpl,
|
TraitImpl,
|
||||||
|
|
|
@ -123,7 +123,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
{
|
{
|
||||||
let tcx = self.tcx();
|
let tcx = self.tcx();
|
||||||
let lifetime_name = |def_id| {
|
let lifetime_name = |def_id| {
|
||||||
tcx.hir().name_by_hir_id(tcx.hir().as_local_hir_id(def_id).unwrap()).as_interned_str()
|
tcx.hir().name(tcx.hir().as_local_hir_id(def_id).unwrap()).as_interned_str()
|
||||||
};
|
};
|
||||||
|
|
||||||
let r = match tcx.named_region(lifetime.hir_id) {
|
let r = match tcx.named_region(lifetime.hir_id) {
|
||||||
|
@ -2004,7 +2004,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
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];
|
||||||
tcx.mk_ty_param(index, tcx.hir().name_by_hir_id(hir_id).as_interned_str())
|
tcx.mk_ty_param(index, tcx.hir().name(hir_id).as_interned_str())
|
||||||
}
|
}
|
||||||
Res::SelfTy(Some(_), None) => {
|
Res::SelfTy(Some(_), None) => {
|
||||||
// `Self` in trait or type alias.
|
// `Self` in trait or type alias.
|
||||||
|
@ -2194,7 +2194,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
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)];
|
||||||
let name = tcx.hir().name_by_hir_id(hir_id).as_interned_str();
|
let name = tcx.hir().name(hir_id).as_interned_str();
|
||||||
const_.val = ConstValue::Param(ty::ParamConst::new(index, name));
|
const_.val = ConstValue::Param(ty::ParamConst::new(index, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -547,7 +547,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_by_hir_id(pat.hir_id);
|
||||||
let parent = tcx.hir().get_by_hir_id(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 {
|
||||||
hir::Node::Item(hir::Item { node: hir::ItemKind::Fn(..), .. }) |
|
hir::Node::Item(hir::Item { node: hir::ItemKind::Fn(..), .. }) |
|
||||||
|
@ -812,10 +812,10 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
|
||||||
let match_id = hir.get_parent_node_by_hir_id(arm_id);
|
let match_id = hir.get_parent_node_by_hir_id(arm_id);
|
||||||
let containing_id = hir.get_parent_node_by_hir_id(match_id);
|
let containing_id = hir.get_parent_node_by_hir_id(match_id);
|
||||||
|
|
||||||
let node = hir.get_by_hir_id(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_by_hir_id(
|
let parent = hir.get(
|
||||||
hir.get_parent_node_by_hir_id(
|
hir.get_parent_node_by_hir_id(
|
||||||
hir.get_parent_node_by_hir_id(block.hir_id),
|
hir.get_parent_node_by_hir_id(block.hir_id),
|
||||||
),
|
),
|
||||||
|
|
|
@ -245,7 +245,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
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_by_hir_id(hir_id);
|
||||||
let parent_node = self.tcx.hir().get_by_hir_id(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, ..), .. }),
|
||||||
hir::ExprKind::Block(..),
|
hir::ExprKind::Block(..),
|
||||||
|
|
|
@ -1291,7 +1291,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
|
||||||
cause.span,
|
cause.span,
|
||||||
blk_id,
|
blk_id,
|
||||||
);
|
);
|
||||||
let parent = fcx.tcx.hir().get_by_hir_id(parent_id);
|
let parent = fcx.tcx.hir().get(parent_id);
|
||||||
fcx.get_node_fn_decl(parent).map(|(fn_decl, _, is_main)| (fn_decl, is_main))
|
fcx.get_node_fn_decl(parent).map(|(fn_decl, _, is_main)| (fn_decl, is_main))
|
||||||
} else {
|
} else {
|
||||||
fcx.get_fn_decl(parent_id)
|
fcx.get_fn_decl(parent_id)
|
||||||
|
|
|
@ -268,7 +268,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let snippet = tcx.sess.source_map().span_to_snippet(span);
|
let snippet = tcx.sess.source_map().span_to_snippet(span);
|
||||||
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_by_hir_id(
|
let parent_node = self.tcx.hir().get(
|
||||||
self.tcx.hir().get_parent_node_by_hir_id(hir_id),
|
self.tcx.hir().get_parent_node_by_hir_id(hir_id),
|
||||||
);
|
);
|
||||||
let msg = format!(
|
let msg = format!(
|
||||||
|
@ -389,7 +389,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
} else {
|
} 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),
|
self.tcx.hir().get_parent_node_by_hir_id(expr.hir_id),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -759,7 +759,7 @@ fn primary_body_of<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
id: hir::HirId,
|
id: hir::HirId,
|
||||||
) -> Option<(hir::BodyId, Option<&'tcx hir::FnDecl>)> {
|
) -> Option<(hir::BodyId, Option<&'tcx hir::FnDecl>)> {
|
||||||
match tcx.hir().get_by_hir_id(id) {
|
match tcx.hir().get(id) {
|
||||||
Node::Item(item) => {
|
Node::Item(item) => {
|
||||||
match item.node {
|
match item.node {
|
||||||
hir::ItemKind::Const(_, body) |
|
hir::ItemKind::Const(_, body) |
|
||||||
|
@ -993,10 +993,9 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> {
|
||||||
if let PatKind::Binding(_, _, ident, _) = p.node {
|
if let PatKind::Binding(_, _, ident, _) = p.node {
|
||||||
let var_ty = self.assign(p.span, p.hir_id, None);
|
let var_ty = self.assign(p.span, p.hir_id, None);
|
||||||
|
|
||||||
let node_id = self.fcx.tcx.hir().hir_to_node_id(p.hir_id);
|
|
||||||
if !self.fcx.tcx.features().unsized_locals {
|
if !self.fcx.tcx.features().unsized_locals {
|
||||||
self.fcx.require_type_is_sized(var_ty, p.span,
|
self.fcx.require_type_is_sized(var_ty, p.span,
|
||||||
traits::VariableType(node_id));
|
traits::VariableType(p.hir_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("Pattern binding {} is assigned to {} with type {:?}",
|
debug!("Pattern binding {} is assigned to {} with type {:?}",
|
||||||
|
@ -1214,7 +1213,7 @@ fn check_fn<'a, 'tcx>(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Node::Item(item) = fcx.tcx.hir().get_by_hir_id(fn_id) {
|
if let Node::Item(item) = fcx.tcx.hir().get(fn_id) {
|
||||||
if let ItemKind::Fn(_, _, ref generics, _) = item.node {
|
if let ItemKind::Fn(_, _, ref generics, _) = item.node {
|
||||||
if !generics.params.is_empty() {
|
if !generics.params.is_empty() {
|
||||||
fcx.tcx.sess.span_err(
|
fcx.tcx.sess.span_err(
|
||||||
|
@ -1262,7 +1261,7 @@ fn check_fn<'a, 'tcx>(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Node::Item(item) = fcx.tcx.hir().get_by_hir_id(fn_id) {
|
if let Node::Item(item) = fcx.tcx.hir().get(fn_id) {
|
||||||
if let ItemKind::Fn(_, _, ref generics, _) = item.node {
|
if let ItemKind::Fn(_, _, ref generics, _) = item.node {
|
||||||
if !generics.params.is_empty() {
|
if !generics.params.is_empty() {
|
||||||
fcx.tcx.sess.span_err(
|
fcx.tcx.sess.span_err(
|
||||||
|
@ -3677,7 +3676,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_item_span(&self, id: hir::HirId) -> Option<Span> {
|
fn parent_item_span(&self, id: hir::HirId) -> Option<Span> {
|
||||||
let node = self.tcx.hir().get_by_hir_id(self.tcx.hir().get_parent_item(id));
|
let node = self.tcx.hir().get(self.tcx.hir().get_parent_item(id));
|
||||||
match node {
|
match node {
|
||||||
Node::Item(&hir::Item {
|
Node::Item(&hir::Item {
|
||||||
node: hir::ItemKind::Fn(_, _, _, body_id), ..
|
node: hir::ItemKind::Fn(_, _, _, body_id), ..
|
||||||
|
@ -3697,7 +3696,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
/// Given a function block's `HirId`, returns its `FnDecl` if it exists, or `None` otherwise.
|
/// Given a function block's `HirId`, returns its `FnDecl` if it exists, or `None` otherwise.
|
||||||
fn get_parent_fn_decl(&self, blk_id: hir::HirId) -> Option<(&'tcx hir::FnDecl, ast::Ident)> {
|
fn get_parent_fn_decl(&self, blk_id: hir::HirId) -> Option<(&'tcx hir::FnDecl, ast::Ident)> {
|
||||||
let parent = self.tcx.hir().get_by_hir_id(self.tcx.hir().get_parent_item(blk_id));
|
let parent = self.tcx.hir().get(self.tcx.hir().get_parent_item(blk_id));
|
||||||
self.get_node_fn_decl(parent).map(|(fn_decl, ident, _)| (fn_decl, ident))
|
self.get_node_fn_decl(parent).map(|(fn_decl, ident, _)| (fn_decl, ident))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3732,7 +3731,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
// Get enclosing Fn, if it is a function or a trait method, unless there's a `loop` or
|
// Get enclosing Fn, if it is a function or a trait method, unless there's a `loop` or
|
||||||
// `while` before reaching it, as block tail returns are not available in them.
|
// `while` before reaching it, as block tail returns are not available in them.
|
||||||
self.tcx.hir().get_return_block(blk_id).and_then(|blk_id| {
|
self.tcx.hir().get_return_block(blk_id).and_then(|blk_id| {
|
||||||
let parent = self.tcx.hir().get_by_hir_id(blk_id);
|
let parent = self.tcx.hir().get(blk_id);
|
||||||
self.get_node_fn_decl(parent).map(|(fn_decl, _, is_main)| (fn_decl, is_main))
|
self.get_node_fn_decl(parent).map(|(fn_decl, _, is_main)| (fn_decl, is_main))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -4259,7 +4258,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_by_hir_id(
|
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_by_hir_id(hir_id))
|
||||||
{
|
{
|
||||||
if let ExprKind::Call(ref callee, ..) = expr.node {
|
if let ExprKind::Call(ref callee, ..) = expr.node {
|
||||||
|
@ -4335,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_by_hir_id(self.tcx.hir().get_parent_node_by_hir_id(expr_id))
|
self.tcx.hir().get(self.tcx.hir().get_parent_node_by_hir_id(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, ..) => {
|
||||||
|
|
|
@ -652,5 +652,5 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn var_name(tcx: TyCtxt<'_>, var_hir_id: hir::HirId) -> ast::Name {
|
fn var_name(tcx: TyCtxt<'_>, var_hir_id: hir::HirId) -> ast::Name {
|
||||||
tcx.hir().name_by_hir_id(var_hir_id)
|
tcx.hir().name(var_hir_id)
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,7 +284,7 @@ fn type_param_predicates<'tcx>(
|
||||||
let mut extend = None;
|
let mut extend = None;
|
||||||
|
|
||||||
let item_hir_id = tcx.hir().as_local_hir_id(item_def_id).unwrap();
|
let item_hir_id = tcx.hir().as_local_hir_id(item_def_id).unwrap();
|
||||||
let ast_generics = match tcx.hir().get_by_hir_id(item_hir_id) {
|
let ast_generics = match tcx.hir().get(item_hir_id) {
|
||||||
Node::TraitItem(item) => &item.generics,
|
Node::TraitItem(item) => &item.generics,
|
||||||
|
|
||||||
Node::ImplItem(item) => &item.generics,
|
Node::ImplItem(item) => &item.generics,
|
||||||
|
@ -623,7 +623,7 @@ fn adt_def<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx ty::AdtDef {
|
||||||
use rustc::hir::*;
|
use rustc::hir::*;
|
||||||
|
|
||||||
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 = match tcx.hir().get_by_hir_id(hir_id) {
|
let item = match tcx.hir().get(hir_id) {
|
||||||
Node::Item(item) => item,
|
Node::Item(item) => item,
|
||||||
_ => bug!(),
|
_ => bug!(),
|
||||||
};
|
};
|
||||||
|
@ -693,7 +693,7 @@ fn super_predicates_of<'tcx>(
|
||||||
debug!("super_predicates(trait_def_id={:?})", trait_def_id);
|
debug!("super_predicates(trait_def_id={:?})", trait_def_id);
|
||||||
let trait_hir_id = tcx.hir().as_local_hir_id(trait_def_id).unwrap();
|
let trait_hir_id = tcx.hir().as_local_hir_id(trait_def_id).unwrap();
|
||||||
|
|
||||||
let item = match tcx.hir().get_by_hir_id(trait_hir_id) {
|
let item = match tcx.hir().get(trait_hir_id) {
|
||||||
Node::Item(item) => item,
|
Node::Item(item) => item,
|
||||||
_ => bug!("trait_node_id {} is not an item", trait_hir_id),
|
_ => bug!("trait_node_id {} is not an item", trait_hir_id),
|
||||||
};
|
};
|
||||||
|
@ -884,7 +884,7 @@ fn generics_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx ty::Generics {
|
||||||
|
|
||||||
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 node = tcx.hir().get_by_hir_id(hir_id);
|
let node = tcx.hir().get(hir_id);
|
||||||
let parent_def_id = match node {
|
let parent_def_id = match node {
|
||||||
Node::ImplItem(_) | Node::TraitItem(_) | Node::Variant(_) |
|
Node::ImplItem(_) | Node::TraitItem(_) | Node::Variant(_) |
|
||||||
Node::Ctor(..) | Node::Field(_) => {
|
Node::Ctor(..) | Node::Field(_) => {
|
||||||
|
@ -1154,7 +1154,7 @@ pub fn checked_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, fail: bool) -> Op
|
||||||
|
|
||||||
let icx = ItemCtxt::new(tcx, def_id);
|
let icx = ItemCtxt::new(tcx, def_id);
|
||||||
|
|
||||||
Some(match tcx.hir().get_by_hir_id(hir_id) {
|
Some(match tcx.hir().get(hir_id) {
|
||||||
Node::TraitItem(item) => match item.node {
|
Node::TraitItem(item) => match item.node {
|
||||||
TraitItemKind::Method(..) => {
|
TraitItemKind::Method(..) => {
|
||||||
let substs = InternalSubsts::identity_for_item(tcx, def_id);
|
let substs = InternalSubsts::identity_for_item(tcx, def_id);
|
||||||
|
@ -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_by_hir_id(tcx.hir().get_parent_node_by_hir_id(hir_id));
|
let parent_node = tcx.hir().get(tcx.hir().get_parent_node_by_hir_id(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),
|
||||||
|
@ -1660,8 +1660,8 @@ fn find_existential_constraints<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Ty<'t
|
||||||
if scope == hir::CRATE_HIR_ID {
|
if scope == hir::CRATE_HIR_ID {
|
||||||
intravisit::walk_crate(&mut locator, tcx.hir().krate());
|
intravisit::walk_crate(&mut locator, tcx.hir().krate());
|
||||||
} else {
|
} else {
|
||||||
debug!("find_existential_constraints: scope={:?}", tcx.hir().get_by_hir_id(scope));
|
debug!("find_existential_constraints: scope={:?}", tcx.hir().get(scope));
|
||||||
match tcx.hir().get_by_hir_id(scope) {
|
match tcx.hir().get(scope) {
|
||||||
Node::Item(ref it) => intravisit::walk_item(&mut locator, it),
|
Node::Item(ref it) => intravisit::walk_item(&mut locator, it),
|
||||||
Node::ImplItem(ref it) => intravisit::walk_impl_item(&mut locator, it),
|
Node::ImplItem(ref it) => intravisit::walk_impl_item(&mut locator, it),
|
||||||
Node::TraitItem(ref it) => intravisit::walk_trait_item(&mut locator, it),
|
Node::TraitItem(ref it) => intravisit::walk_trait_item(&mut locator, it),
|
||||||
|
@ -1690,7 +1690,7 @@ fn fn_sig<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> ty::PolyFnSig<'tcx> {
|
||||||
|
|
||||||
let icx = ItemCtxt::new(tcx, def_id);
|
let icx = ItemCtxt::new(tcx, def_id);
|
||||||
|
|
||||||
match tcx.hir().get_by_hir_id(hir_id) {
|
match tcx.hir().get(hir_id) {
|
||||||
TraitItem(hir::TraitItem {
|
TraitItem(hir::TraitItem {
|
||||||
node: TraitItemKind::Method(sig, _),
|
node: TraitItemKind::Method(sig, _),
|
||||||
..
|
..
|
||||||
|
@ -1903,7 +1903,7 @@ fn explicit_predicates_of<'tcx>(
|
||||||
Some(hir_id) => hir_id,
|
Some(hir_id) => hir_id,
|
||||||
None => return tcx.predicates_of(def_id),
|
None => return tcx.predicates_of(def_id),
|
||||||
};
|
};
|
||||||
let node = tcx.hir().get_by_hir_id(hir_id);
|
let node = tcx.hir().get(hir_id);
|
||||||
|
|
||||||
let mut is_trait = None;
|
let mut is_trait = None;
|
||||||
let mut is_default_impl_trait = None;
|
let mut is_default_impl_trait = None;
|
||||||
|
|
|
@ -61,7 +61,7 @@ impl<'cx, 'tcx> ItemLikeVisitor<'tcx> for InferVisitor<'cx, 'tcx> {
|
||||||
.hir()
|
.hir()
|
||||||
.as_local_hir_id(item_did)
|
.as_local_hir_id(item_did)
|
||||||
.expect("expected local def-id");
|
.expect("expected local def-id");
|
||||||
let item = match self.tcx.hir().get_by_hir_id(hir_id) {
|
let item = match self.tcx.hir().get(hir_id) {
|
||||||
Node::Item(item) => item,
|
Node::Item(item) => item,
|
||||||
_ => bug!(),
|
_ => bug!(),
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,7 +29,7 @@ fn inferred_outlives_of<'tcx>(
|
||||||
.as_local_hir_id(item_def_id)
|
.as_local_hir_id(item_def_id)
|
||||||
.expect("expected local def-id");
|
.expect("expected local def-id");
|
||||||
|
|
||||||
match tcx.hir().get_by_hir_id(id) {
|
match tcx.hir().get(id) {
|
||||||
Node::Item(item) => match item.node {
|
Node::Item(item) => match item.node {
|
||||||
hir::ItemKind::Struct(..) | hir::ItemKind::Enum(..) | hir::ItemKind::Union(..) => {
|
hir::ItemKind::Struct(..) | hir::ItemKind::Enum(..) | hir::ItemKind::Union(..) => {
|
||||||
let crate_map = tcx.inferred_outlives_crate(LOCAL_CRATE);
|
let crate_map = tcx.inferred_outlives_crate(LOCAL_CRATE);
|
||||||
|
|
|
@ -48,7 +48,7 @@ fn variances_of<'tcx>(tcx: TyCtxt<'tcx>, item_def_id: DefId) -> &'tcx [ty::Varia
|
||||||
// Variance not relevant.
|
// Variance not relevant.
|
||||||
span_bug!(tcx.hir().span(id), "asked to compute variance for wrong kind of item")
|
span_bug!(tcx.hir().span(id), "asked to compute variance for wrong kind of item")
|
||||||
};
|
};
|
||||||
match tcx.hir().get_by_hir_id(id) {
|
match tcx.hir().get(id) {
|
||||||
Node::Item(item) => match item.node {
|
Node::Item(item) => match item.node {
|
||||||
hir::ItemKind::Enum(..) |
|
hir::ItemKind::Enum(..) |
|
||||||
hir::ItemKind::Struct(..) |
|
hir::ItemKind::Struct(..) |
|
||||||
|
|
|
@ -246,7 +246,7 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
|
||||||
match parent_node.or(self.mod_ids.last().cloned()) {
|
match parent_node.or(self.mod_ids.last().cloned()) {
|
||||||
Some(parent) if parent != hir::CRATE_HIR_ID => {
|
Some(parent) if parent != hir::CRATE_HIR_ID => {
|
||||||
// FIXME: can we pull the parent module's name from elsewhere?
|
// FIXME: can we pull the parent module's name from elsewhere?
|
||||||
Some(self.cx.tcx.hir().name_by_hir_id(parent).to_string())
|
Some(self.cx.tcx.hir().name(parent).to_string())
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
|
|
|
@ -337,7 +337,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||||
|
|
||||||
if !self.view_item_stack.insert(res_hir_id) { return false }
|
if !self.view_item_stack.insert(res_hir_id) { return false }
|
||||||
|
|
||||||
let ret = match tcx.hir().get_by_hir_id(res_hir_id) {
|
let ret = match tcx.hir().get(res_hir_id) {
|
||||||
Node::Item(&hir::Item { node: hir::ItemKind::Mod(ref m), .. }) if glob => {
|
Node::Item(&hir::Item { node: hir::ItemKind::Mod(ref m), .. }) if glob => {
|
||||||
let prev = mem::replace(&mut self.inlining, true);
|
let prev = mem::replace(&mut self.inlining, true);
|
||||||
for i in &m.item_ids {
|
for i in &m.item_ids {
|
||||||
|
|
|
@ -43,7 +43,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingWhitelistedAttrPass {
|
||||||
span: source_map::Span,
|
span: source_map::Span,
|
||||||
id: hir::HirId) {
|
id: hir::HirId) {
|
||||||
|
|
||||||
let item = match cx.tcx.hir().get_by_hir_id(id) {
|
let item = match cx.tcx.hir().get(id) {
|
||||||
Node::Item(item) => item,
|
Node::Item(item) => item,
|
||||||
_ => cx.tcx.hir().expect_item(cx.tcx.hir().get_parent_item(id)),
|
_ => cx.tcx.hir().expect_item(cx.tcx.hir().get_parent_item(id)),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue