Auto merge of #58561 - ljedrz:HirIdify_some_nodes, r=Zoxc

Remove NodeId from some HIR nodes

The next iteration of https://github.com/rust-lang/rust/pull/57578.

Removes `NodeId` from:

- [x] `Lifetime`
- [x] `Ty`
- [x] `GenericParam`
- [x] `WhereClause`
- [x] `WhereEqPredicate`
- [x] `MacroDef`
- [x] `Block`
- [x] `Expr`

r? @Zoxc
This commit is contained in:
bors 2019-02-26 06:13:27 +00:00
commit ea43c3c688
70 changed files with 642 additions and 673 deletions

View File

@ -398,7 +398,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
args: I) -> CFGIndex {
let func_or_rcvr_exit = self.expr(func_or_rcvr, pred);
let ret = self.straightline(call_expr, func_or_rcvr_exit, args);
let m = self.tcx.hir().get_module_parent(call_expr.id);
let m = self.tcx.hir().get_module_parent_by_hir_id(call_expr.hir_id);
if self.tcx.is_ty_uninhabited_from(m, self.tables.expr_ty(call_expr)) {
self.add_unreachable_node()
} else {

View File

@ -780,7 +780,6 @@ impl<'a> LoweringContext<'a> {
);
hir::GenericParam {
id: node_id,
hir_id,
name: hir_name,
attrs: hir_vec![],
@ -964,7 +963,6 @@ impl<'a> LoweringContext<'a> {
let closure_hir_id = self.lower_node_id(closure_node_id).hir_id;
let decl = self.lower_fn_decl(&decl, None, /* impl trait allowed */ false, None);
let generator = hir::Expr {
id: closure_node_id,
hir_id: closure_hir_id,
node: hir::ExprKind::Closure(capture_clause, decl, body_id, span,
Some(hir::GeneratorMovability::Static)),
@ -1300,7 +1298,6 @@ impl<'a> LoweringContext<'a> {
// Set the name to `impl Bound1 + Bound2`.
let ident = Ident::from_str(&pprust::ty_to_string(t)).with_span_pos(span);
in_band_ty_params.push(hir::GenericParam {
id: def_node_id,
hir_id,
name: ParamName::Plain(ident),
pure_wrt_drop: false,
@ -1350,9 +1347,8 @@ impl<'a> LoweringContext<'a> {
TyKind::Mac(_) => panic!("TyMac should have been expanded by now."),
};
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(t.id);
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(t.id);
hir::Ty {
id: node_id,
node: kind,
span: t.span,
hir_id,
@ -1394,12 +1390,11 @@ impl<'a> LoweringContext<'a> {
);
self.with_hir_id_owner(exist_ty_node_id, |lctx| {
let LoweredNodeId { node_id, hir_id } = lctx.next_id();
let LoweredNodeId { node_id: _, hir_id } = lctx.next_id();
let exist_ty_item_kind = hir::ItemKind::Existential(hir::ExistTy {
generics: hir::Generics {
params: lifetime_defs,
where_clause: hir::WhereClause {
id: node_id,
hir_id,
predicates: Vec::new().into(),
},
@ -1533,9 +1528,8 @@ impl<'a> LoweringContext<'a> {
&& !self.already_defined_lifetimes.contains(&name) {
self.already_defined_lifetimes.insert(name);
let LoweredNodeId { node_id, hir_id } = self.context.next_id();
let LoweredNodeId { node_id: _, hir_id } = self.context.next_id();
self.output_lifetimes.push(hir::GenericArg::Lifetime(hir::Lifetime {
id: node_id,
hir_id,
span: lifetime.span,
name,
@ -1569,7 +1563,6 @@ impl<'a> LoweringContext<'a> {
};
self.output_lifetime_params.push(hir::GenericParam {
id: def_node_id,
hir_id,
name,
span: lifetime.span,
@ -1980,8 +1973,8 @@ impl<'a> LoweringContext<'a> {
.map(|ty| this.lower_ty_direct(ty, ImplTraitContext::disallowed()))
.collect();
let mk_tup = |this: &mut Self, tys, span| {
let LoweredNodeId { node_id, hir_id } = this.next_id();
hir::Ty { node: hir::TyKind::Tup(tys), id: node_id, hir_id, span }
let LoweredNodeId { node_id: _, hir_id } = this.next_id();
hir::Ty { node: hir::TyKind::Tup(tys), hir_id, span }
};
let LoweredNodeId { node_id, hir_id } = this.next_id();
@ -2318,9 +2311,8 @@ impl<'a> LoweringContext<'a> {
this.lower_ty(ty, ImplTraitContext::Existential(Some(fn_def_id)))
}
FunctionRetTy::Default(span) => {
let LoweredNodeId { node_id, hir_id } = this.next_id();
let LoweredNodeId { node_id: _, hir_id } = this.next_id();
P(hir::Ty {
id: node_id,
hir_id,
node: hir::TyKind::Tup(hir_vec![]),
span: *span,
@ -2362,17 +2354,16 @@ impl<'a> LoweringContext<'a> {
];
if let Some((name, span)) = bound_lifetime {
let LoweredNodeId { node_id, hir_id } = this.next_id();
let LoweredNodeId { node_id: _, hir_id } = this.next_id();
bounds.push(hir::GenericBound::Outlives(
hir::Lifetime { id: node_id, hir_id, name, span }));
hir::Lifetime { hir_id, name, span }));
}
hir::HirVec::from(bounds)
});
let LoweredNodeId { node_id, hir_id } = self.next_id();
let LoweredNodeId { node_id: _, hir_id } = self.next_id();
let impl_trait_ty = P(hir::Ty {
id: node_id,
node: impl_trait_ty,
span,
hir_id,
@ -2431,10 +2422,9 @@ impl<'a> LoweringContext<'a> {
span: Span,
name: hir::LifetimeName,
) -> hir::Lifetime {
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(id);
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(id);
hir::Lifetime {
id: node_id,
hir_id,
span,
name: name,
@ -2524,10 +2514,9 @@ impl<'a> LoweringContext<'a> {
}
};
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(param.id);
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(param.id);
hir::GenericParam {
id: node_id,
hir_id,
name,
span: param.ident.span,
@ -2608,10 +2597,9 @@ impl<'a> LoweringContext<'a> {
self.with_anonymous_lifetime_mode(
AnonymousLifetimeMode::ReportError,
|this| {
let LoweredNodeId { node_id, hir_id } = this.lower_node_id(wc.id);
let LoweredNodeId { node_id: _, hir_id } = this.lower_node_id(wc.id);
hir::WhereClause {
id: node_id,
hir_id,
predicates: wc.predicates
.iter()
@ -2672,10 +2660,9 @@ impl<'a> LoweringContext<'a> {
ref rhs_ty,
span,
}) => {
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(id);
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(id);
hir::WherePredicate::EqPredicate(hir::WhereEqPredicate {
id: node_id,
hir_id,
lhs_ty: self.lower_ty(lhs_ty, ImplTraitContext::disallowed()),
rhs_ty: self.lower_ty(rhs_ty, ImplTraitContext::disallowed()),
@ -2816,10 +2803,9 @@ impl<'a> LoweringContext<'a> {
}
}
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(b.id);
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(b.id);
P(hir::Block {
id: node_id,
hir_id,
stmts: stmts.into(),
expr,
@ -3544,7 +3530,6 @@ impl<'a> LoweringContext<'a> {
name: ident.name,
vis,
attrs,
id: i.id,
hir_id,
span: i.span,
body,
@ -3900,11 +3885,10 @@ impl<'a> LoweringContext<'a> {
// Wrap the `if let` expr in a block.
let span = els.span;
let els = P(self.lower_expr(els));
let LoweredNodeId { node_id, hir_id } = self.next_id();
let LoweredNodeId { node_id: _, hir_id } = self.next_id();
let blk = P(hir::Block {
stmts: hir_vec![],
expr: Some(els),
id: node_id,
hir_id,
rules: hir::DefaultBlock,
span,
@ -3947,10 +3931,9 @@ impl<'a> LoweringContext<'a> {
let mut block = this.lower_block(body, true).into_inner();
let tail = block.expr.take().map_or_else(
|| {
let LoweredNodeId { node_id, hir_id } = this.next_id();
let LoweredNodeId { node_id: _, hir_id } = this.next_id();
let span = this.sess.source_map().end_point(unstable_span);
hir::Expr {
id: node_id,
span,
node: hir::ExprKind::Tup(hir_vec![]),
attrs: ThinVec::new(),
@ -4135,10 +4118,9 @@ impl<'a> LoweringContext<'a> {
let struct_path = self.std_path(e.span, &struct_path, None, is_unit);
let struct_path = hir::QPath::Resolved(None, P(struct_path));
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(e.id);
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(e.id);
return hir::Expr {
id: node_id,
hir_id,
node: if is_unit {
hir::ExprKind::Path(struct_path)
@ -4488,9 +4470,8 @@ impl<'a> LoweringContext<'a> {
self.lower_label(opt_label),
hir::LoopSource::ForLoop,
);
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(e.id);
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(e.id);
let loop_expr = P(hir::Expr {
id: node_id,
hir_id,
node: loop_expr,
span: e.span,
@ -4635,10 +4616,9 @@ impl<'a> LoweringContext<'a> {
ExprKind::Mac(_) => panic!("Shouldn't exist here"),
};
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(e.id);
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(e.id);
hir::Expr {
id: node_id,
hir_id,
node: kind,
span: e.span,
@ -4910,9 +4890,8 @@ impl<'a> LoweringContext<'a> {
}
fn expr(&mut self, span: Span, node: hir::ExprKind, attrs: ThinVec<Attribute>) -> hir::Expr {
let LoweredNodeId { node_id, hir_id } = self.next_id();
let LoweredNodeId { node_id: _, hir_id } = self.next_id();
hir::Expr {
id: node_id,
hir_id,
node,
span,
@ -4978,12 +4957,11 @@ impl<'a> LoweringContext<'a> {
stmts: hir::HirVec<hir::Stmt>,
expr: Option<P<hir::Expr>>,
) -> hir::Block {
let LoweredNodeId { node_id, hir_id } = self.next_id();
let LoweredNodeId { node_id: _, hir_id } = self.next_id();
hir::Block {
stmts,
expr,
id: node_id,
hir_id,
rules: hir::DefaultBlock,
span,
@ -5108,7 +5086,6 @@ impl<'a> LoweringContext<'a> {
_ => hir::TyKind::Path(qpath),
};
hir::Ty {
id: id.node_id,
hir_id: id.hir_id,
node,
span,
@ -5124,9 +5101,8 @@ impl<'a> LoweringContext<'a> {
// `'f`.
AnonymousLifetimeMode::CreateParameter => {
let fresh_name = self.collect_fresh_in_band_lifetime(span);
let LoweredNodeId { node_id, hir_id } = self.next_id();
let LoweredNodeId { node_id: _, hir_id } = self.next_id();
hir::Lifetime {
id: node_id,
hir_id,
span,
name: hir::LifetimeName::Param(fresh_name),
@ -5227,10 +5203,9 @@ impl<'a> LoweringContext<'a> {
}
fn new_implicit_lifetime(&mut self, span: Span) -> hir::Lifetime {
let LoweredNodeId { node_id, hir_id } = self.next_id();
let LoweredNodeId { node_id: _, hir_id } = self.next_id();
hir::Lifetime {
id: node_id,
hir_id,
span,
name: hir::LifetimeName::Implicit,

View File

@ -75,10 +75,10 @@ pub enum Code<'a> {
}
impl<'a> Code<'a> {
pub fn id(&self) -> NodeId {
pub fn id(&self) -> ast::HirId {
match *self {
Code::FnLike(node) => node.id(),
Code::Expr(block) => block.id,
Code::Expr(block) => block.hir_id,
}
}
@ -104,7 +104,7 @@ struct ItemFnParts<'a> {
vis: &'a ast::Visibility,
generics: &'a ast::Generics,
body: ast::BodyId,
id: NodeId,
id: ast::HirId,
span: Span,
attrs: &'a [Attribute],
}
@ -114,13 +114,13 @@ struct ItemFnParts<'a> {
struct ClosureParts<'a> {
decl: &'a FnDecl,
body: ast::BodyId,
id: NodeId,
id: ast::HirId,
span: Span,
attrs: &'a [Attribute],
}
impl<'a> ClosureParts<'a> {
fn new(d: &'a FnDecl, b: ast::BodyId, id: NodeId, s: Span, attrs: &'a [Attribute]) -> Self {
fn new(d: &'a FnDecl, b: ast::BodyId, id: ast::HirId, s: Span, attrs: &'a [Attribute]) -> Self {
ClosureParts {
decl: d,
body: b,
@ -168,7 +168,7 @@ impl<'a> FnLikeNode<'a> {
|c: ClosureParts<'_>| c.span)
}
pub fn id(self) -> NodeId {
pub fn id(self) -> ast::HirId {
self.handle(|i: ItemFnParts<'_>| i.id,
|id, _, _: &'a ast::MethodSig, _, _, _, _| id,
|c: ClosureParts<'_>| c.id)
@ -213,7 +213,7 @@ impl<'a> FnLikeNode<'a> {
fn handle<A, I, M, C>(self, item_fn: I, method: M, closure: C) -> A where
I: FnOnce(ItemFnParts<'a>) -> A,
M: FnOnce(NodeId,
M: FnOnce(ast::HirId,
Ident,
&'a ast::MethodSig,
Option<&'a ast::Visibility>,
@ -227,7 +227,7 @@ impl<'a> FnLikeNode<'a> {
map::Node::Item(i) => match i.node {
ast::ItemKind::Fn(ref decl, header, ref generics, block) =>
item_fn(ItemFnParts {
id: i.id,
id: i.hir_id,
ident: i.ident,
decl: &decl,
body: block,
@ -241,21 +241,21 @@ impl<'a> FnLikeNode<'a> {
},
map::Node::TraitItem(ti) => match ti.node {
ast::TraitItemKind::Method(ref sig, ast::TraitMethod::Provided(body)) => {
method(ti.id, ti.ident, sig, None, body, ti.span, &ti.attrs)
method(ti.hir_id, ti.ident, sig, None, body, ti.span, &ti.attrs)
}
_ => bug!("trait method FnLikeNode that is not fn-like"),
},
map::Node::ImplItem(ii) => {
match ii.node {
ast::ImplItemKind::Method(ref sig, body) => {
method(ii.id, ii.ident, sig, Some(&ii.vis), body, ii.span, &ii.attrs)
method(ii.hir_id, ii.ident, sig, Some(&ii.vis), body, ii.span, &ii.attrs)
}
_ => bug!("impl method FnLikeNode that is not fn-like")
}
},
map::Node::Expr(e) => match e.node {
ast::ExprKind::Closure(_, ref decl, block, _fn_decl_span, _gen) =>
closure(ClosureParts::new(&decl, block, e.id, e.span, &e.attrs)),
closure(ClosureParts::new(&decl, block, e.hir_id, e.span, &e.attrs)),
_ => bug!("expr FnLikeNode that is not fn-like"),
},
_ => bug!("other FnLikeNode that is not fn-like"),

View File

@ -507,7 +507,8 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
}
fn visit_macro_def(&mut self, macro_def: &'hir MacroDef) {
let def_index = self.definitions.opt_def_index(macro_def.id).unwrap();
let node_id = self.hir_to_node_id[&macro_def.hir_id];
let def_index = self.definitions.opt_def_index(node_id).unwrap();
self.with_dep_node_owner(def_index, macro_def, |this| {
this.insert(macro_def.span, macro_def.hir_id, Node::MacroDef(macro_def));

View File

@ -390,14 +390,19 @@ impl<'hir> Map<'hir> {
Some(Def::Local(local.id))
}
Node::MacroDef(macro_def) => {
Some(Def::Macro(self.local_def_id(macro_def.id),
Some(Def::Macro(self.local_def_id_from_hir_id(macro_def.hir_id),
MacroKind::Bang))
}
Node::GenericParam(param) => {
Some(match param.kind {
GenericParamKind::Lifetime { .. } => Def::Local(param.id),
GenericParamKind::Type { .. } => Def::TyParam(self.local_def_id(param.id)),
GenericParamKind::Const { .. } => Def::ConstParam(self.local_def_id(param.id)),
GenericParamKind::Lifetime { .. } => {
let node_id = self.hir_to_node_id(param.hir_id);
Def::Local(node_id)
},
GenericParamKind::Type { .. } => Def::TyParam(
self.local_def_id_from_hir_id(param.hir_id)),
GenericParamKind::Const { .. } => Def::ConstParam(
self.local_def_id_from_hir_id(param.hir_id)),
})
}
}
@ -794,7 +799,7 @@ impl<'hir> Map<'hir> {
/// false
/// }
/// ```
pub fn get_return_block(&self, id: NodeId) -> Option<NodeId> {
pub fn get_return_block(&self, id: HirId) -> Option<HirId> {
let match_fn = |node: &Node<'_>| {
match *node {
Node::Item(_) |
@ -817,7 +822,10 @@ impl<'hir> Map<'hir> {
}
};
self.walk_parent_nodes(id, match_fn, match_non_returning_block).ok()
let node_id = self.hir_to_node_id(id);
self.walk_parent_nodes(node_id, match_fn, match_non_returning_block)
.ok()
.map(|return_node_id| self.node_to_hir_id(return_node_id))
}
/// Retrieves the `NodeId` for `id`'s parent item, or `id` itself if no

View File

@ -19,7 +19,7 @@ use errors::FatalError;
use syntax_pos::{Span, DUMMY_SP, symbol::InternedString};
use syntax::source_map::Spanned;
use rustc_target::spec::abi::Abi;
use syntax::ast::{self, CrateSugar, Ident, Name, NodeId, DUMMY_NODE_ID, AsmDialect};
use syntax::ast::{self, CrateSugar, Ident, Name, NodeId, AsmDialect};
use syntax::ast::{Attribute, Label, Lit, StrStyle, FloatTy, IntTy, UintTy};
use syntax::attr::{InlineAttr, OptimizeAttr};
use syntax::ext::hygiene::SyntaxContext;
@ -112,6 +112,12 @@ impl serialize::UseSpecializedDecodable for HirId {
}
}
impl fmt::Display for HirId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", self)
}
}
// hack to ensure that we don't try to access the private parts of `ItemLocalId` in this module
mod item_local_id_inner {
use rustc_data_structures::indexed_vec::Idx;
@ -145,7 +151,6 @@ pub const DUMMY_ITEM_LOCAL_ID: ItemLocalId = ItemLocalId::MAX;
#[derive(Clone, RustcEncodable, RustcDecodable, Copy)]
pub struct Lifetime {
pub id: NodeId,
pub hir_id: HirId,
pub span: Span,
@ -266,7 +271,7 @@ impl fmt::Debug for Lifetime {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f,
"lifetime({}: {})",
self.id,
self.hir_id,
print::to_string(print::NO_ANN, |s| s.print_lifetime(self)))
}
}
@ -411,11 +416,11 @@ impl GenericArg {
}
}
pub fn id(&self) -> NodeId {
pub fn id(&self) -> HirId {
match self {
GenericArg::Lifetime(l) => l.id,
GenericArg::Type(t) => t.id,
GenericArg::Const(c) => c.value.id,
GenericArg::Lifetime(l) => l.hir_id,
GenericArg::Type(t) => t.hir_id,
GenericArg::Const(c) => c.value.hir_id,
}
}
}
@ -547,7 +552,6 @@ pub enum GenericParamKind {
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct GenericParam {
pub id: NodeId,
pub hir_id: HirId,
pub name: ParamName,
pub attrs: HirVec<Attribute>,
@ -579,7 +583,6 @@ impl Generics {
Generics {
params: HirVec::new(),
where_clause: WhereClause {
id: DUMMY_NODE_ID,
hir_id: DUMMY_HIR_ID,
predicates: HirVec::new(),
},
@ -624,7 +627,6 @@ pub enum SyntheticTyParamKind {
/// A where-clause in a definition.
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct WhereClause {
pub id: NodeId,
pub hir_id: HirId,
pub predicates: HirVec<WherePredicate>,
}
@ -685,7 +687,6 @@ pub struct WhereRegionPredicate {
/// An equality predicate (e.g., `T = int`); currently unsupported.
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct WhereEqPredicate {
pub id: NodeId,
pub hir_id: HirId,
pub span: Span,
pub lhs_ty: P<Ty>,
@ -808,7 +809,6 @@ pub struct MacroDef {
pub name: Name,
pub vis: Visibility,
pub attrs: HirVec<Attribute>,
pub id: NodeId,
pub hir_id: HirId,
pub span: Span,
pub body: TokenStream,
@ -822,7 +822,6 @@ pub struct Block {
/// An expression at the end of the block
/// without a semicolon, if any.
pub expr: Option<P<Expr>>,
pub id: NodeId,
pub hir_id: HirId,
/// Distinguishes between `unsafe { ... }` and `{ ... }`.
pub rules: BlockCheckMode,
@ -1334,7 +1333,6 @@ pub struct AnonConst {
/// An expression
#[derive(Clone, RustcEncodable, RustcDecodable)]
pub struct Expr {
pub id: NodeId,
pub span: Span,
pub node: ExprKind,
pub attrs: ThinVec<Attribute>,
@ -1437,7 +1435,7 @@ impl Expr {
impl fmt::Debug for Expr {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "expr({}: {})", self.id,
write!(f, "expr({}: {})", self.hir_id,
print::to_string(print::NO_ANN, |s| s.print_expr(self)))
}
}
@ -1754,7 +1752,6 @@ pub struct TypeBinding {
#[derive(Clone, RustcEncodable, RustcDecodable)]
pub struct Ty {
pub id: NodeId,
pub node: TyKind,
pub span: Span,
pub hir_id: HirId,

View File

@ -2248,7 +2248,6 @@ impl<'a> State<'a> {
let generics = hir::Generics {
params: hir::HirVec::new(),
where_clause: hir::WhereClause {
id: ast::DUMMY_NODE_ID,
hir_id: hir::DUMMY_HIR_ID,
predicates: hir::HirVec::new(),
},

View File

@ -158,7 +158,6 @@ impl_stable_hash_for!(struct ast::Label {
});
impl_stable_hash_for!(struct hir::Lifetime {
id,
hir_id,
span,
name
@ -207,7 +206,6 @@ impl_stable_hash_for!(enum hir::TraitBoundModifier {
});
impl_stable_hash_for!(struct hir::GenericParam {
id,
hir_id,
name,
pure_wrt_drop,
@ -255,7 +253,6 @@ impl_stable_hash_for!(enum hir::SyntheticTyParamKind {
});
impl_stable_hash_for!(struct hir::WhereClause {
id,
hir_id,
predicates
});
@ -280,7 +277,6 @@ impl_stable_hash_for!(struct hir::WhereRegionPredicate {
});
impl_stable_hash_for!(struct hir::WhereEqPredicate {
id,
hir_id,
span,
lhs_ty,
@ -318,7 +314,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::Ty {
hasher: &mut StableHasher<W>) {
hcx.while_hashing_hir_bodies(true, |hcx| {
let hir::Ty {
id: _,
hir_id: _,
ref node,
ref span,
@ -411,7 +406,6 @@ impl_stable_hash_for!(struct hir::MacroDef {
name,
vis,
attrs,
id,
hir_id,
span,
legacy,
@ -421,7 +415,6 @@ impl_stable_hash_for!(struct hir::MacroDef {
impl_stable_hash_for!(struct hir::Block {
stmts,
expr,
id -> _,
hir_id -> _,
rules,
span,
@ -566,7 +559,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::Expr {
hasher: &mut StableHasher<W>) {
hcx.while_hashing_hir_bodies(true, |hcx| {
let hir::Expr {
id: _,
hir_id: _,
ref span,
ref node,

View File

@ -101,7 +101,7 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
let (span_1, span_2, main_label, span_label) = match (sup_is_ret_type, sub_is_ret_type) {
(None, None) => {
let (main_label_1, span_label_1) = if ty_sup.id == ty_sub.id {
let (main_label_1, span_label_1) = if ty_sup.hir_id == ty_sub.hir_id {
(
"this type is declared with multiple lifetimes...".to_owned(),
"...but data with one lifetime flows into the other here".to_owned()

View File

@ -723,7 +723,7 @@ fn lint_levels<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, cnum: CrateNum)
};
let krate = tcx.hir().krate();
builder.with_lint_attrs(ast::CRATE_NODE_ID, &krate.attrs, |builder| {
builder.with_lint_attrs(hir::CRATE_HIR_ID, &krate.attrs, |builder| {
intravisit::walk_crate(builder, krate);
});
@ -737,13 +737,13 @@ struct LintLevelMapBuilder<'a, 'tcx: 'a> {
impl<'a, 'tcx> LintLevelMapBuilder<'a, 'tcx> {
fn with_lint_attrs<F>(&mut self,
id: ast::NodeId,
id: hir::HirId,
attrs: &[ast::Attribute],
f: F)
where F: FnOnce(&mut Self)
{
let push = self.levels.push(attrs);
self.levels.register_id(self.tcx.hir().definitions().node_to_hir_id(id));
self.levels.register_id(id);
f(self);
self.levels.pop(push);
}
@ -755,25 +755,25 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for LintLevelMapBuilder<'a, 'tcx> {
}
fn visit_item(&mut self, it: &'tcx hir::Item) {
self.with_lint_attrs(it.id, &it.attrs, |builder| {
self.with_lint_attrs(it.hir_id, &it.attrs, |builder| {
intravisit::walk_item(builder, it);
});
}
fn visit_foreign_item(&mut self, it: &'tcx hir::ForeignItem) {
self.with_lint_attrs(it.id, &it.attrs, |builder| {
self.with_lint_attrs(it.hir_id, &it.attrs, |builder| {
intravisit::walk_foreign_item(builder, it);
})
}
fn visit_expr(&mut self, e: &'tcx hir::Expr) {
self.with_lint_attrs(e.id, &e.attrs, |builder| {
self.with_lint_attrs(e.hir_id, &e.attrs, |builder| {
intravisit::walk_expr(builder, e);
})
}
fn visit_struct_field(&mut self, s: &'tcx hir::StructField) {
self.with_lint_attrs(s.id, &s.attrs, |builder| {
self.with_lint_attrs(s.hir_id, &s.attrs, |builder| {
intravisit::walk_struct_field(builder, s);
})
}
@ -782,25 +782,25 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for LintLevelMapBuilder<'a, 'tcx> {
v: &'tcx hir::Variant,
g: &'tcx hir::Generics,
item_id: hir::HirId) {
self.with_lint_attrs(v.node.data.id(), &v.node.attrs, |builder| {
self.with_lint_attrs(v.node.data.hir_id(), &v.node.attrs, |builder| {
intravisit::walk_variant(builder, v, g, item_id);
})
}
fn visit_local(&mut self, l: &'tcx hir::Local) {
self.with_lint_attrs(l.id, &l.attrs, |builder| {
self.with_lint_attrs(l.hir_id, &l.attrs, |builder| {
intravisit::walk_local(builder, l);
})
}
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) {
self.with_lint_attrs(trait_item.id, &trait_item.attrs, |builder| {
self.with_lint_attrs(trait_item.hir_id, &trait_item.attrs, |builder| {
intravisit::walk_trait_item(builder, trait_item);
});
}
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
self.with_lint_attrs(impl_item.id, &impl_item.attrs, |builder| {
self.with_lint_attrs(impl_item.hir_id, &impl_item.attrs, |builder| {
intravisit::walk_impl_item(builder, impl_item);
});
}

View File

@ -99,10 +99,10 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
}
}
fn handle_field_access(&mut self, lhs: &hir::Expr, node_id: ast::NodeId) {
fn handle_field_access(&mut self, lhs: &hir::Expr, hir_id: hir::HirId) {
match self.tables.expr_ty_adjusted(lhs).sty {
ty::Adt(def, _) => {
let index = self.tcx.field_index(node_id, self.tables);
let index = self.tcx.field_index(hir_id, self.tables);
self.insert_def_id(def.non_enum_variant().fields[index].did);
}
ty::Tuple(..) => {}
@ -120,7 +120,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
if let PatKind::Wild = pat.node.pat.node {
continue;
}
let index = self.tcx.field_index(pat.node.id, self.tables);
let index = self.tcx.field_index(pat.node.hir_id, self.tables);
self.insert_def_id(variant.fields[index].did);
}
}
@ -190,7 +190,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
fn mark_as_used_if_union(&mut self, adt: &ty::AdtDef, fields: &hir::HirVec<hir::Field>) {
if adt.is_union() && adt.non_enum_variant().fields.len() > 1 && adt.did.is_local() {
for field in fields {
let index = self.tcx.field_index(field.id, self.tables);
let index = self.tcx.field_index(field.hir_id, self.tables);
self.insert_def_id(adt.non_enum_variant().fields[index].did);
}
}
@ -232,7 +232,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
self.lookup_and_handle_method(expr.hir_id);
}
hir::ExprKind::Field(ref lhs, ..) => {
self.handle_field_access(&lhs, expr.id);
self.handle_field_access(&lhs, expr.hir_id);
}
hir::ExprKind::Struct(_, ref fields, _) => {
if let ty::Adt(ref adt, _) = self.tables.expr_ty(expr).sty {

View File

@ -33,7 +33,7 @@ pub trait Delegate<'tcx> {
// The value found at `cmt` is either copied or moved, depending
// on mode.
fn consume(&mut self,
consume_id: ast::NodeId,
consume_id: hir::HirId,
consume_span: Span,
cmt: &mc::cmt_<'tcx>,
mode: ConsumeMode);
@ -65,7 +65,7 @@ pub trait Delegate<'tcx> {
// The value found at `borrow` is being borrowed at the point
// `borrow_id` for the region `loan_region` with kind `bk`.
fn borrow(&mut self,
borrow_id: ast::NodeId,
borrow_id: hir::HirId,
borrow_span: Span,
cmt: &mc::cmt_<'tcx>,
loan_region: ty::Region<'tcx>,
@ -79,7 +79,7 @@ pub trait Delegate<'tcx> {
// The path at `cmt` is being assigned to.
fn mutate(&mut self,
assignment_id: ast::NodeId,
assignment_id: hir::HirId,
assignment_span: Span,
assignee_cmt: &mc::cmt_<'tcx>,
mode: MutateMode);
@ -329,7 +329,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
}
fn delegate_consume(&mut self,
consume_id: ast::NodeId,
consume_id: hir::HirId,
consume_span: Span,
cmt: &mc::cmt_<'tcx>) {
debug!("delegate_consume(consume_id={}, cmt={:?})",
@ -349,7 +349,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
debug!("consume_expr(expr={:?})", expr);
let cmt = return_if_err!(self.mc.cat_expr(expr));
self.delegate_consume(expr.id, expr.span, &cmt);
self.delegate_consume(expr.hir_id, expr.span, &cmt);
self.walk_expr(expr);
}
@ -359,7 +359,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
expr: &hir::Expr,
mode: MutateMode) {
let cmt = return_if_err!(self.mc.cat_expr(expr));
self.delegate.mutate(assignment_expr.id, span, &cmt, mode);
self.delegate.mutate(assignment_expr.hir_id, span, &cmt, mode);
self.walk_expr(expr);
}
@ -372,7 +372,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
expr, r, bk);
let cmt = return_if_err!(self.mc.cat_expr(expr));
self.delegate.borrow(expr.id, expr.span, &cmt, r, bk, cause);
self.delegate.borrow(expr.hir_id, expr.span, &cmt, r, bk, cause);
self.walk_expr(expr)
}
@ -629,7 +629,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
/// Indicates that the value of `blk` will be consumed, meaning either copied or moved
/// depending on its type.
fn walk_block(&mut self, blk: &hir::Block) {
debug!("walk_block(blk.id={})", blk.id);
debug!("walk_block(blk.hir_id={})", blk.hir_id);
for stmt in &blk.stmts {
self.walk_stmt(stmt);
@ -662,7 +662,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
// Consume those fields of the with expression that are needed.
for (f_index, with_field) in adt.non_enum_variant().fields.iter().enumerate() {
let is_mentioned = fields.iter().any(|f| {
self.tcx().field_index(f.id, self.mc.tables) == f_index
self.tcx().field_index(f.hir_id, self.mc.tables) == f_index
});
if !is_mentioned {
let cmt_field = self.mc.cat_field(
@ -672,7 +672,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
with_field.ident,
with_field.ty(self.tcx(), substs)
);
self.delegate_consume(with_expr.id, with_expr.span, &cmt_field);
self.delegate_consume(with_expr.hir_id, with_expr.span, &cmt_field);
}
}
}
@ -711,7 +711,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
adjustment::Adjust::Unsize => {
// Creating a closure/fn-pointer or unsizing consumes
// the input and stores it into the resulting rvalue.
self.delegate_consume(expr.id, expr.span, &cmt);
self.delegate_consume(expr.hir_id, expr.span, &cmt);
}
adjustment::Adjust::Deref(None) => {}
@ -723,7 +723,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
// this is an autoref of `x`.
adjustment::Adjust::Deref(Some(ref deref)) => {
let bk = ty::BorrowKind::from_mutbl(deref.mutbl);
self.delegate.borrow(expr.id, expr.span, &cmt, deref.region, bk, AutoRef);
self.delegate.borrow(expr.hir_id, expr.span, &cmt, deref.region, bk, AutoRef);
}
adjustment::Adjust::Borrow(ref autoref) => {
@ -741,14 +741,14 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
expr: &hir::Expr,
cmt_base: &mc::cmt_<'tcx>,
autoref: &adjustment::AutoBorrow<'tcx>) {
debug!("walk_autoref(expr.id={} cmt_base={:?} autoref={:?})",
expr.id,
debug!("walk_autoref(expr.hir_id={} cmt_base={:?} autoref={:?})",
expr.hir_id,
cmt_base,
autoref);
match *autoref {
adjustment::AutoBorrow::Ref(r, m) => {
self.delegate.borrow(expr.id,
self.delegate.borrow(expr.hir_id,
expr.span,
cmt_base,
r,
@ -757,8 +757,8 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
}
adjustment::AutoBorrow::RawPtr(m) => {
debug!("walk_autoref: expr.id={} cmt_base={:?}",
expr.id,
debug!("walk_autoref: expr.hir_id={} cmt_base={:?}",
expr.hir_id,
cmt_base);
// Converting from a &T to *T (or &mut T to *mut T) is
@ -770,7 +770,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
data: region::ScopeData::Node
}));
self.delegate.borrow(expr.id,
self.delegate.borrow(expr.hir_id,
expr.span,
cmt_base,
r,
@ -864,7 +864,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
// binding being produced.
let def = Def::Local(canonical_id);
if let Ok(ref binding_cmt) = mc.cat_def(pat.hir_id, pat.span, pat_ty, def) {
delegate.mutate(pat.id, pat.span, binding_cmt, MutateMode::Init);
delegate.mutate(pat.hir_id, pat.span, binding_cmt, MutateMode::Init);
}
// It is also a borrow or copy/move of the value being matched.
@ -872,7 +872,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
ty::BindByReference(m) => {
if let ty::Ref(r, _, _) = pat_ty.sty {
let bk = ty::BorrowKind::from_mutbl(m);
delegate.borrow(pat.id, pat.span, &cmt_pat, r, bk, RefBinding);
delegate.borrow(pat.hir_id, pat.span, &cmt_pat, r, bk, RefBinding);
}
}
ty::BindByValue(..) => {
@ -920,10 +920,11 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
fn walk_captures(&mut self, closure_expr: &hir::Expr, fn_decl_span: Span) {
debug!("walk_captures({:?})", closure_expr);
self.tcx().with_freevars(closure_expr.id, |freevars| {
let closure_node_id = self.tcx().hir().hir_to_node_id(closure_expr.hir_id);
let closure_def_id = self.tcx().hir().local_def_id(closure_node_id);
self.tcx().with_freevars(closure_node_id, |freevars| {
for freevar in freevars {
let var_hir_id = self.tcx().hir().node_to_hir_id(freevar.var_id());
let closure_def_id = self.tcx().hir().local_def_id(closure_expr.id);
let upvar_id = ty::UpvarId {
var_path: ty::UpvarPath { hir_id: var_hir_id },
closure_expr_id: closure_def_id.to_local(),
@ -938,10 +939,10 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
self.param_env,
&cmt_var,
CaptureMove);
self.delegate.consume(closure_expr.id, freevar.span, &cmt_var, mode);
self.delegate.consume(closure_expr.hir_id, freevar.span, &cmt_var, mode);
}
ty::UpvarCapture::ByRef(upvar_borrow) => {
self.delegate.borrow(closure_expr.id,
self.delegate.borrow(closure_expr.hir_id,
fn_decl_span,
&cmt_var,
upvar_borrow.region,

View File

@ -265,7 +265,7 @@ struct IrMaps<'a, 'tcx: 'a> {
num_vars: usize,
live_node_map: HirIdMap<LiveNode>,
variable_map: HirIdMap<Variable>,
capture_info_map: NodeMap<Rc<Vec<CaptureInfo>>>,
capture_info_map: HirIdMap<Rc<Vec<CaptureInfo>>>,
var_kinds: Vec<VarKind>,
lnks: Vec<LiveNodeKind>,
}
@ -344,8 +344,8 @@ impl<'a, 'tcx> IrMaps<'a, 'tcx> {
}
}
fn set_captures(&mut self, node_id: NodeId, cs: Vec<CaptureInfo>) {
self.capture_info_map.insert(node_id, Rc::new(cs));
fn set_captures(&mut self, hir_id: HirId, cs: Vec<CaptureInfo>) {
self.capture_info_map.insert(hir_id, Rc::new(cs));
}
fn lnk(&self, ln: LiveNode) -> LiveNodeKind {
@ -460,7 +460,7 @@ fn visit_expr<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, expr: &'tcx Expr) {
match expr.node {
// live nodes required for uses or definitions of variables:
hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => {
debug!("expr {}: path that leads to {:?}", expr.id, path.def);
debug!("expr {}: path that leads to {:?}", expr.hir_id, path.def);
if let Def::Local(..) = path.def {
ir.add_live_node_for_node(expr.hir_id, ExprNode(expr.span));
}
@ -476,7 +476,8 @@ fn visit_expr<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, expr: &'tcx Expr) {
// in better error messages than just pointing at the closure
// construction site.
let mut call_caps = Vec::new();
ir.tcx.with_freevars(expr.id, |freevars| {
let node_id = ir.tcx.hir().hir_to_node_id(expr.hir_id);
ir.tcx.with_freevars(node_id, |freevars| {
call_caps.extend(freevars.iter().filter_map(|fv| {
if let Def::Local(rv) = fv.def {
let fv_ln = ir.add_live_node(FreeVarNode(fv.span));
@ -487,7 +488,7 @@ fn visit_expr<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, expr: &'tcx Expr) {
}
}));
});
ir.set_captures(expr.id, call_caps);
ir.set_captures(expr.hir_id, call_caps);
intravisit::walk_expr(ir, expr);
}
@ -925,7 +926,8 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
}
fn compute(&mut self, body: &hir::Expr) -> LiveNode {
debug!("compute: using id for body, {}", self.ir.tcx.hir().node_to_pretty_string(body.id));
debug!("compute: using id for body, {}",
self.ir.tcx.hir().hir_to_pretty_string(body.hir_id));
// the fallthrough exit is only for those cases where we do not
// explicitly return:
@ -940,7 +942,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
for ln_idx in 0..self.ir.num_live_nodes {
debug!("{:?}", self.ln_str(LiveNode(ln_idx as u32)));
}
body.id
body.hir_id
},
entry_ln);
@ -950,7 +952,8 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
fn propagate_through_block(&mut self, blk: &hir::Block, succ: LiveNode)
-> LiveNode {
if blk.targeted_by_break {
self.break_ln.insert(blk.id, succ);
let node_id = self.ir.tcx.hir().hir_to_node_id(blk.hir_id);
self.break_ln.insert(node_id, succ);
}
let succ = self.propagate_through_opt_expr(blk.expr.as_ref().map(|e| &**e), succ);
blk.stmts.iter().rev().fold(succ, |succ, stmt| {
@ -1002,7 +1005,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode)
-> LiveNode {
debug!("propagate_through_expr: {}", self.ir.tcx.hir().node_to_pretty_string(expr.id));
debug!("propagate_through_expr: {}", self.ir.tcx.hir().hir_to_pretty_string(expr.hir_id));
match expr.node {
// Interesting cases with control flow or which gen/kill
@ -1016,11 +1019,11 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
hir::ExprKind::Closure(..) => {
debug!("{} is an ExprKind::Closure",
self.ir.tcx.hir().node_to_pretty_string(expr.id));
self.ir.tcx.hir().hir_to_pretty_string(expr.hir_id));
// the construction of a closure itself is not important,
// but we have to consider the closed over variables.
let caps = self.ir.capture_info_map.get(&expr.id).cloned().unwrap_or_else(||
let caps = self.ir.capture_info_map.get(&expr.hir_id).cloned().unwrap_or_else(||
span_bug!(expr.span, "no registered caps"));
caps.iter().rev().fold(succ, |succ, cap| {
@ -1169,7 +1172,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
}
hir::ExprKind::Call(ref f, ref args) => {
let m = self.ir.tcx.hir().get_module_parent(expr.id);
let m = self.ir.tcx.hir().get_module_parent_by_hir_id(expr.hir_id);
let succ = if self.ir.tcx.is_ty_uninhabited_from(m, self.tables.expr_ty(expr)) {
self.s.exit_ln
} else {
@ -1180,7 +1183,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
}
hir::ExprKind::MethodCall(.., ref args) => {
let m = self.ir.tcx.hir().get_module_parent(expr.id);
let m = self.ir.tcx.hir().get_module_parent_by_hir_id(expr.hir_id);
let succ = if self.ir.tcx.is_ty_uninhabited_from(m, self.tables.expr_ty(expr)) {
self.s.exit_ln
} else {
@ -1386,17 +1389,17 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
}
}
debug!("propagate_through_loop: using id for loop body {} {}",
expr.id, self.ir.tcx.hir().node_to_pretty_string(body.id));
expr.hir_id, self.ir.tcx.hir().hir_to_pretty_string(body.hir_id));
self.break_ln.insert(expr.id, succ);
let node_id = self.ir.tcx.hir().hir_to_node_id(expr.hir_id);
self.break_ln.insert(node_id, succ);
let cond_ln = match kind {
LoopLoop => ln,
WhileLoop(ref cond) => self.propagate_through_expr(&cond, ln),
};
self.cont_ln.insert(expr.id, cond_ln);
self.cont_ln.insert(node_id, cond_ln);
let body_ln = self.propagate_through_block(body, cond_ln);

View File

@ -632,7 +632,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
}
pub fn cat_expr_unadjusted(&self, expr: &hir::Expr) -> McResult<cmt_<'tcx>> {
debug!("cat_expr: id={} expr={:?}", expr.id, expr);
debug!("cat_expr: id={} expr={:?}", expr.hir_id, expr);
let expr_ty = self.expr_ty(expr)?;
match expr.node {
@ -648,10 +648,10 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
hir::ExprKind::Field(ref base, f_ident) => {
let base_cmt = Rc::new(self.cat_expr(&base)?);
debug!("cat_expr(cat_field): id={} expr={:?} base={:?}",
expr.id,
expr.hir_id,
expr,
base_cmt);
let f_index = self.tcx.field_index(expr.id, self.tables);
let f_index = self.tcx.field_index(expr.hir_id, self.tables);
Ok(self.cat_field(expr, base_cmt, f_index, f_ident, expr_ty))
}
@ -1321,7 +1321,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
for fp in field_pats {
let field_ty = self.pat_ty_adjusted(&fp.node.pat)?; // see (*2)
let f_index = self.tcx.field_index(fp.node.id, self.tables);
let f_index = self.tcx.field_index(fp.node.hir_id, self.tables);
let cmt_field = Rc::new(self.cat_field(pat, cmt.clone(), f_index,
fp.node.ident, field_ty));
self.cat_pattern_(cmt_field, &fp.node.pat, op)?;

View File

@ -745,7 +745,7 @@ fn record_var_lifetime(visitor: &mut RegionResolutionVisitor<'_, '_>,
}
fn resolve_block<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, blk: &'tcx hir::Block) {
debug!("resolve_block(blk.id={:?})", blk.id);
debug!("resolve_block(blk.hir_id={:?})", blk.hir_id);
let prev_cx = visitor.cx;

View File

@ -13,7 +13,7 @@ use crate::ty::{self, DefIdTree, GenericParamDefKind, TyCtxt};
use crate::rustc::lint;
use crate::session::Session;
use crate::util::nodemap::{DefIdMap, FxHashMap, FxHashSet, NodeMap, NodeSet};
use crate::util::nodemap::{DefIdMap, FxHashMap, FxHashSet, HirIdMap, HirIdSet, NodeMap};
use errors::{Applicability, DiagnosticBuilder};
use rustc_data_structures::sync::Lrc;
use std::borrow::Cow;
@ -83,7 +83,7 @@ impl Region {
fn early(hir_map: &Map<'_>, index: &mut u32, param: &GenericParam) -> (ParamName, Region) {
let i = *index;
*index += 1;
let def_id = hir_map.local_def_id(param.id);
let def_id = hir_map.local_def_id_from_hir_id(param.hir_id);
let origin = LifetimeDefOrigin::from_param(param);
debug!("Region::early: index={} def_id={:?}", i, def_id);
(param.name.modern(), Region::EarlyBound(i, def_id, origin))
@ -91,7 +91,7 @@ impl Region {
fn late(hir_map: &Map<'_>, param: &GenericParam) -> (ParamName, Region) {
let depth = ty::INNERMOST;
let def_id = hir_map.local_def_id(param.id);
let def_id = hir_map.local_def_id_from_hir_id(param.hir_id);
let origin = LifetimeDefOrigin::from_param(param);
debug!(
"Region::late: param={:?} depth={:?} def_id={:?} origin={:?}",
@ -151,7 +151,7 @@ impl Region {
if let Region::EarlyBound(index, _, _) = self {
params
.nth(index as usize)
.and_then(|lifetime| map.defs.get(&lifetime.id).cloned())
.and_then(|lifetime| map.defs.get(&lifetime.hir_id).cloned())
} else {
Some(self)
}
@ -195,12 +195,12 @@ pub type ObjectLifetimeDefault = Set1<Region>;
struct NamedRegionMap {
// maps from every use of a named (not anonymous) lifetime to a
// `Region` describing how that region is bound
pub defs: NodeMap<Region>,
pub defs: HirIdMap<Region>,
// the set of lifetime def ids that are late-bound; a region can
// be late-bound if (a) it does NOT appear in a where-clause and
// (b) it DOES appear in the arguments.
pub late_bound: NodeSet,
pub late_bound: HirIdSet,
// For each type and trait definition, maps type parameters
// to the trait object lifetime defaults computed from them.
@ -385,13 +385,11 @@ fn resolve_lifetimes<'tcx>(
let mut rl = ResolveLifetimes::default();
for (k, v) in named_region_map.defs {
let hir_id = tcx.hir().node_to_hir_id(k);
for (hir_id, v) in named_region_map.defs {
let map = rl.defs.entry(hir_id.owner_local_def_id()).or_default();
Lrc::get_mut(map).unwrap().insert(hir_id.local_id, v);
}
for k in named_region_map.late_bound {
let hir_id = tcx.hir().node_to_hir_id(k);
for hir_id in named_region_map.late_bound {
let map = rl.late_bound
.entry(hir_id.owner_local_def_id())
.or_default();
@ -570,7 +568,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
}
fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
debug!("visit_ty: id={:?} ty={:?}", ty.id, ty);
debug!("visit_ty: id={:?} ty={:?}", ty.hir_id, ty);
match ty.node {
hir::TyKind::BareFn(ref c) => {
let next_early_index = self.next_early_index();
@ -629,7 +627,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
hir::TyKind::Rptr(ref lifetime_ref, ref mt) => {
self.visit_lifetime(lifetime_ref);
let scope = Scope::ObjectLifetimeDefault {
lifetime: self.map.defs.get(&lifetime_ref.id).cloned(),
lifetime: self.map.defs.get(&lifetime_ref.hir_id).cloned(),
s: self.scope,
};
self.with(scope, |_, this| this.visit_ty(&mt.ty));
@ -672,7 +670,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
// and ban them. Type variables instantiated inside binders aren't
// well-supported at the moment, so this doesn't work.
// In the future, this should be fixed and this error should be removed.
let def = self.map.defs.get(&lifetime.id).cloned();
let def = self.map.defs.get(&lifetime.hir_id).cloned();
if let Some(Region::LateBound(_, def_id, _)) = def {
if let Some(node_id) = self.tcx.hir().as_local_node_id(def_id) {
// Ensure that the parent of the def is an item, not HRTB
@ -1339,7 +1337,7 @@ fn object_lifetime_defaults_for_item(
add_bounds(&mut set, &param.bounds);
let param_def_id = tcx.hir().local_def_id(param.id);
let param_def_id = tcx.hir().local_def_id_from_hir_id(param.hir_id);
for predicate in &generics.where_clause.predicates {
// Look for `type: ...` where clauses.
let data = match *predicate {
@ -1374,7 +1372,7 @@ fn object_lifetime_defaults_for_item(
.iter()
.filter_map(|param| match param.kind {
GenericParamKind::Lifetime { .. } => Some((
param.id,
param.hir_id,
hir::LifetimeName::Param(param.name),
LifetimeDefOrigin::from_param(param),
)),
@ -1383,7 +1381,7 @@ fn object_lifetime_defaults_for_item(
.enumerate()
.find(|&(_, (_, lt_name, _))| lt_name == name)
.map_or(Set1::Many, |(i, (id, _, origin))| {
let def_id = tcx.hir().local_def_id(id);
let def_id = tcx.hir().local_def_id_from_hir_id(id);
Set1::One(Region::EarlyBound(i as u32, def_id, origin))
})
}
@ -1501,8 +1499,10 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
}
}
};
if let Node::Lifetime(hir_lifetime) = self.tcx.hir().get(lifetime.id) {
if let Some(parent) = self.tcx.hir().find(self.tcx.hir().get_parent(hir_lifetime.id)) {
if let Node::Lifetime(hir_lifetime) = self.tcx.hir().get_by_hir_id(lifetime.hir_id) {
if let Some(parent) = self.tcx.hir().find_by_hir_id(
self.tcx.hir().get_parent_item(hir_lifetime.hir_id))
{
match parent {
Node::Item(item) => {
if let hir::ItemKind::Fn(decl, _, _, _) = &item.node {
@ -1582,22 +1582,22 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
debug!("node id first={:?}", node_id);
if let Some((id, span, name)) = match self.tcx.hir().get(node_id) {
Node::Lifetime(hir_lifetime) => Some((
hir_lifetime.id,
hir_lifetime.hir_id,
hir_lifetime.span,
hir_lifetime.name.ident(),
)),
Node::GenericParam(param) => {
Some((param.id, param.span, param.name.ident()))
Some((param.hir_id, param.span, param.name.ident()))
}
_ => None,
} {
debug!("id = {:?} span = {:?} name = {:?}", node_id, span, name);
debug!("id = {:?} span = {:?} name = {:?}", id, span, name);
if name == keywords::UnderscoreLifetime.ident() {
continue;
}
let mut err = self.tcx.struct_span_lint_node(
let mut err = self.tcx.struct_span_lint_hir(
lint::builtin::SINGLE_USE_LIFETIMES,
id,
span,
@ -1622,17 +1622,17 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
let node_id = self.tcx.hir().as_local_node_id(def_id).unwrap();
if let Some((id, span, name)) = match self.tcx.hir().get(node_id) {
Node::Lifetime(hir_lifetime) => Some((
hir_lifetime.id,
hir_lifetime.hir_id,
hir_lifetime.span,
hir_lifetime.name.ident(),
)),
Node::GenericParam(param) => {
Some((param.id, param.span, param.name.ident()))
Some((param.hir_id, param.span, param.name.ident()))
}
_ => None,
} {
debug!("id ={:?} span = {:?} name = {:?}", node_id, span, name);
let mut err = self.tcx.struct_span_lint_node(
debug!("id ={:?} span = {:?} name = {:?}", id, span, name);
let mut err = self.tcx.struct_span_lint_hir(
lint::builtin::UNUSED_LIFETIMES,
id,
span,
@ -1706,7 +1706,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
let mut non_lifetime_count = 0;
let lifetimes = generics.params.iter().filter_map(|param| match param.kind {
GenericParamKind::Lifetime { .. } => {
if self.map.late_bound.contains(&param.id) {
if self.map.late_bound.contains(&param.hir_id) {
Some(Region::late(&self.tcx.hir(), param))
} else {
Some(Region::early(&self.tcx.hir(), &mut index, param))
@ -2049,8 +2049,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
// and whether there's a `self` argument (treated specially).
let mut assoc_item_kind = None;
let mut impl_self = None;
let parent = self.tcx.hir().get_parent_node(output.id);
let body = match self.tcx.hir().get(parent) {
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) {
// `fn` definitions and methods.
Node::Item(&hir::Item {
node: hir::ItemKind::Fn(.., body),
@ -2063,12 +2063,13 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
}) => {
if let hir::ItemKind::Trait(.., ref trait_items) = self.tcx
.hir()
.expect_item(self.tcx.hir().get_parent(parent))
.expect_item_by_hir_id(self.tcx.hir().get_parent_item(parent))
.node
{
let parent_node_id = self.tcx.hir().hir_to_node_id(parent);
assoc_item_kind = trait_items
.iter()
.find(|ti| ti.id.node_id == parent)
.find(|ti| ti.id.node_id == parent_node_id)
.map(|ti| ti.kind);
}
match *m {
@ -2083,13 +2084,14 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
}) => {
if let hir::ItemKind::Impl(.., ref self_ty, ref impl_items) = self.tcx
.hir()
.expect_item(self.tcx.hir().get_parent(parent))
.expect_item_by_hir_id(self.tcx.hir().get_parent_item(parent))
.node
{
impl_self = Some(self_ty);
let parent_node_id = self.tcx.hir().hir_to_node_id(parent);
assoc_item_kind = impl_items
.iter()
.find(|ii| ii.id.node_id == parent)
.find(|ii| ii.id.node_id == parent_node_id)
.map(|ii| ii.kind);
}
Some(body)
@ -2143,7 +2145,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
if let hir::TyKind::Rptr(lifetime_ref, ref mt) = inputs[0].node {
if let hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) = mt.ty.node {
if is_self_ty(path.def) {
if let Some(&lifetime) = self.map.defs.get(&lifetime_ref.id) {
if let Some(&lifetime) = self.map.defs.get(&lifetime_ref.hir_id) {
let scope = Scope::Elision {
elide: Elide::Exact(lifetime),
s: self.scope,
@ -2262,7 +2264,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
}
fn visit_lifetime(&mut self, lifetime_ref: &hir::Lifetime) {
if let Some(&lifetime) = self.map.defs.get(&lifetime_ref.id) {
if let Some(&lifetime) = self.map.defs.get(&lifetime_ref.hir_id) {
match lifetime {
Region::LateBound(debruijn, _, _) | Region::LateBoundAnon(debruijn, _)
if debruijn < self.outer_index =>
@ -2653,7 +2655,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
}
fn insert_lifetime(&mut self, lifetime_ref: &'tcx hir::Lifetime, def: Region) {
if lifetime_ref.id == ast::DUMMY_NODE_ID {
if lifetime_ref.hir_id == hir::DUMMY_HIR_ID {
span_bug!(
lifetime_ref.span,
"lifetime reference not renumbered, \
@ -2663,11 +2665,11 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
debug!(
"insert_lifetime: {} resolved to {:?} span={:?}",
self.tcx.hir().node_to_string(lifetime_ref.id),
self.tcx.hir().hir_to_string(lifetime_ref.hir_id),
def,
self.tcx.sess.source_map().span_to_string(lifetime_ref.span)
);
self.map.defs.insert(lifetime_ref.id, def);
self.map.defs.insert(lifetime_ref.hir_id, def);
match def {
Region::LateBoundAnon(..) | Region::Static => {
@ -2699,7 +2701,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
/// error (esp. around impl trait). In that case, we remove the
/// entry into `map.defs` so as not to confuse later code.
fn uninsert_lifetime_on_error(&mut self, lifetime_ref: &'tcx hir::Lifetime, bad_def: Region) {
let old_value = self.map.defs.remove(&lifetime_ref.id);
let old_value = self.map.defs.remove(&lifetime_ref.hir_id);
assert_eq!(old_value, Some(bad_def));
}
}
@ -2789,11 +2791,11 @@ fn insert_late_bound_lifetimes(
debug!(
"insert_late_bound_lifetimes: lifetime {:?} with id {:?} is late-bound",
param.name.ident(),
param.id
param.hir_id
);
let inserted = map.late_bound.insert(param.id);
assert!(inserted, "visited lifetime {:?} twice", param.id);
let inserted = map.late_bound.insert(param.hir_id);
assert!(inserted, "visited lifetime {:?} twice", param.hir_id);
}
return;

View File

@ -14,7 +14,7 @@ use crate::session::{DiagnosticMessageId, Session};
use syntax::symbol::Symbol;
use syntax_pos::{Span, MultiSpan};
use syntax::ast;
use syntax::ast::{NodeId, Attribute};
use syntax::ast::Attribute;
use syntax::errors::Applicability;
use syntax::feature_gate::{GateIssue, emit_feature_err};
use syntax::attr::{self, Stability, Deprecation};
@ -117,13 +117,13 @@ struct Annotator<'a, 'tcx: 'a> {
impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
// Determine the stability for a node based on its attributes and inherited
// stability. The stability is recorded in the index and used as the parent.
fn annotate<F>(&mut self, id: NodeId, attrs: &[Attribute],
fn annotate<F>(&mut self, hir_id: HirId, attrs: &[Attribute],
item_sp: Span, kind: AnnotationKind, visit_children: F)
where F: FnOnce(&mut Self)
{
if self.tcx.features().staged_api {
// This crate explicitly wants staged API.
debug!("annotate(id = {:?}, attrs = {:?})", id, attrs);
debug!("annotate(id = {:?}, attrs = {:?})", hir_id, attrs);
if let Some(..) = attr::find_deprecation(&self.tcx.sess.parse_sess, attrs, item_sp) {
self.tcx.sess.span_err(item_sp, "`#[deprecated]` cannot be used in staged api, \
use `#[rustc_deprecated]` instead");
@ -178,7 +178,6 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
}
}
let hir_id = self.tcx.hir().node_to_hir_id(id);
self.index.stab_map.insert(hir_id, stab);
let orig_parent_stab = replace(&mut self.parent_stab, Some(stab));
@ -188,7 +187,6 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
debug!("annotate: not found, parent = {:?}", self.parent_stab);
if let Some(stab) = self.parent_stab {
if stab.level.is_unstable() {
let hir_id = self.tcx.hir().node_to_hir_id(id);
self.index.stab_map.insert(hir_id, stab);
}
}
@ -209,7 +207,6 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
// -Zforce-unstable-if-unmarked is set.
if let Some(stab) = self.parent_stab {
if stab.level.is_unstable() {
let hir_id = self.tcx.hir().node_to_hir_id(id);
self.index.stab_map.insert(hir_id, stab);
}
}
@ -220,7 +217,6 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
}
// `Deprecation` is just two pointers, no need to intern it
let hir_id = self.tcx.hir().node_to_hir_id(id);
let depr_entry = DeprecationEntry::local(depr, hir_id);
self.index.depr_map.insert(hir_id, depr_entry.clone());
@ -229,7 +225,6 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
visit_children(self);
self.parent_depr = orig_parent_depr;
} else if let Some(parent_depr) = self.parent_depr.clone() {
let hir_id = self.tcx.hir().node_to_hir_id(id);
self.index.depr_map.insert(hir_id, parent_depr);
visit_children(self);
} else {
@ -264,20 +259,20 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
}
hir::ItemKind::Struct(ref sd, _) => {
if !sd.is_struct() {
self.annotate(sd.id(), &i.attrs, i.span, AnnotationKind::Required, |_| {})
self.annotate(sd.hir_id(), &i.attrs, i.span, AnnotationKind::Required, |_| {})
}
}
_ => {}
}
self.annotate(i.id, &i.attrs, i.span, kind, |v| {
self.annotate(i.hir_id, &i.attrs, i.span, kind, |v| {
intravisit::walk_item(v, i)
});
self.in_trait_impl = orig_in_trait_impl;
}
fn visit_trait_item(&mut self, ti: &'tcx hir::TraitItem) {
self.annotate(ti.id, &ti.attrs, ti.span, AnnotationKind::Required, |v| {
self.annotate(ti.hir_id, &ti.attrs, ti.span, AnnotationKind::Required, |v| {
intravisit::walk_trait_item(v, ti);
});
}
@ -288,31 +283,30 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
} else {
AnnotationKind::Required
};
self.annotate(ii.id, &ii.attrs, ii.span, kind, |v| {
self.annotate(ii.hir_id, &ii.attrs, ii.span, kind, |v| {
intravisit::walk_impl_item(v, ii);
});
}
fn visit_variant(&mut self, var: &'tcx Variant, g: &'tcx Generics, item_id: HirId) {
self.annotate(var.node.data.id(), &var.node.attrs, var.span, AnnotationKind::Required, |v| {
intravisit::walk_variant(v, var, g, item_id);
})
self.annotate(var.node.data.hir_id(), &var.node.attrs, var.span, AnnotationKind::Required,
|v| { intravisit::walk_variant(v, var, g, item_id) })
}
fn visit_struct_field(&mut self, s: &'tcx StructField) {
self.annotate(s.id, &s.attrs, s.span, AnnotationKind::Required, |v| {
self.annotate(s.hir_id, &s.attrs, s.span, AnnotationKind::Required, |v| {
intravisit::walk_struct_field(v, s);
});
}
fn visit_foreign_item(&mut self, i: &'tcx hir::ForeignItem) {
self.annotate(i.id, &i.attrs, i.span, AnnotationKind::Required, |v| {
self.annotate(i.hir_id, &i.attrs, i.span, AnnotationKind::Required, |v| {
intravisit::walk_foreign_item(v, i);
});
}
fn visit_macro_def(&mut self, md: &'tcx hir::MacroDef) {
self.annotate(md.id, &md.attrs, md.span, AnnotationKind::Required, |_| {});
self.annotate(md.hir_id, &md.attrs, md.span, AnnotationKind::Required, |_| {});
}
}
@ -322,12 +316,12 @@ struct MissingStabilityAnnotations<'a, 'tcx: 'a> {
}
impl<'a, 'tcx: 'a> MissingStabilityAnnotations<'a, 'tcx> {
fn check_missing_stability(&self, id: NodeId, span: Span, name: &str) {
let hir_id = self.tcx.hir().node_to_hir_id(id);
fn check_missing_stability(&self, hir_id: HirId, span: Span, name: &str) {
let stab = self.tcx.stability().local_stability(hir_id);
let node_id = self.tcx.hir().hir_to_node_id(hir_id);
let is_error = !self.tcx.sess.opts.test &&
stab.is_none() &&
self.access_levels.is_reachable(id);
self.access_levels.is_reachable(node_id);
if is_error {
self.tcx.sess.span_err(
span,
@ -350,42 +344,42 @@ impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> {
// optional. They inherit stability from their parents when unannotated.
hir::ItemKind::Impl(.., None, _, _) | hir::ItemKind::ForeignMod(..) => {}
_ => self.check_missing_stability(i.id, i.span, i.node.descriptive_variant())
_ => self.check_missing_stability(i.hir_id, i.span, i.node.descriptive_variant())
}
intravisit::walk_item(self, i)
}
fn visit_trait_item(&mut self, ti: &'tcx hir::TraitItem) {
self.check_missing_stability(ti.id, ti.span, "item");
self.check_missing_stability(ti.hir_id, ti.span, "item");
intravisit::walk_trait_item(self, ti);
}
fn visit_impl_item(&mut self, ii: &'tcx hir::ImplItem) {
let impl_def_id = self.tcx.hir().local_def_id(self.tcx.hir().get_parent(ii.id));
if self.tcx.impl_trait_ref(impl_def_id).is_none() {
self.check_missing_stability(ii.id, ii.span, "item");
self.check_missing_stability(ii.hir_id, ii.span, "item");
}
intravisit::walk_impl_item(self, ii);
}
fn visit_variant(&mut self, var: &'tcx Variant, g: &'tcx Generics, item_id: HirId) {
self.check_missing_stability(var.node.data.id(), var.span, "variant");
self.check_missing_stability(var.node.data.hir_id(), var.span, "variant");
intravisit::walk_variant(self, var, g, item_id);
}
fn visit_struct_field(&mut self, s: &'tcx StructField) {
self.check_missing_stability(s.id, s.span, "field");
self.check_missing_stability(s.hir_id, s.span, "field");
intravisit::walk_struct_field(self, s);
}
fn visit_foreign_item(&mut self, i: &'tcx hir::ForeignItem) {
self.check_missing_stability(i.id, i.span, i.node.descriptive_variant());
self.check_missing_stability(i.hir_id, i.span, i.node.descriptive_variant());
intravisit::walk_foreign_item(self, i);
}
fn visit_macro_def(&mut self, md: &'tcx hir::MacroDef) {
self.check_missing_stability(md.id, md.span, "macro");
self.check_missing_stability(md.hir_id, md.span, "macro");
}
}
@ -441,7 +435,7 @@ impl<'a, 'tcx> Index<'tcx> {
annotator.parent_stab = Some(stability);
}
annotator.annotate(ast::CRATE_NODE_ID,
annotator.annotate(hir::CRATE_HIR_ID,
&krate.attrs,
krate.span,
AnnotationKind::Required,
@ -563,9 +557,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
/// If `id` is `Some(_)`, this function will also check if the item at `def_id` has been
/// deprecated. If the item is indeed deprecated, we will emit a deprecation lint attached to
/// `id`.
pub fn eval_stability(self, def_id: DefId, id: Option<NodeId>, span: Span) -> EvalResult {
pub fn eval_stability(self, def_id: DefId, id: Option<HirId>, span: Span) -> EvalResult {
let lint_deprecated = |def_id: DefId,
id: NodeId,
id: HirId,
note: Option<Symbol>,
suggestion: Option<Symbol>,
message: &str,
@ -576,9 +570,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
format!("{}", message)
};
let mut diag = self.struct_span_lint_node(lint, id, span, &msg);
let mut diag = self.struct_span_lint_hir(lint, id, span, &msg);
if let Some(suggestion) = suggestion {
if let hir::Node::Expr(_) = self.hir().get(id) {
if let hir::Node::Expr(_) = self.hir().get_by_hir_id(id) {
diag.span_suggestion(
span,
&msg,
@ -588,15 +582,16 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
}
}
diag.emit();
if id == ast::DUMMY_NODE_ID {
span_bug!(span, "emitted a {} lint with dummy node id: {:?}", lint.name, def_id);
if id == hir::DUMMY_HIR_ID {
span_bug!(span, "emitted a {} lint with dummy HIR id: {:?}", lint.name, def_id);
}
};
// Deprecated attributes apply in-crate and cross-crate.
if let Some(id) = id {
if let Some(depr_entry) = self.lookup_deprecation_entry(def_id) {
let parent_def_id = self.hir().local_def_id(self.hir().get_parent(id));
let parent_def_id = self.hir().local_def_id_from_hir_id(
self.hir().get_parent_item(id));
let skip = self.lookup_deprecation_entry(parent_def_id)
.map_or(false, |parent_depr| parent_depr.same_origin(&depr_entry));
@ -709,7 +704,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
///
/// Additionally, this function will also check if the item is deprecated. If so, and `id` is
/// not `None`, a deprecated lint attached to `id` will be emitted.
pub fn check_stability(self, def_id: DefId, id: Option<NodeId>, span: Span) {
pub fn check_stability(self, def_id: DefId, id: Option<HirId>, span: Span) {
match self.eval_stability(def_id, id, span) {
EvalResult::Allow => {}
EvalResult::Deny { feature, reason, issue } => {
@ -769,7 +764,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
None => return,
};
let def_id = DefId { krate: cnum, index: CRATE_DEF_INDEX };
self.tcx.check_stability(def_id, Some(item.id), item.span);
self.tcx.check_stability(def_id, Some(item.hir_id), item.span);
}
// For implementations of traits, check the stability of each item
@ -817,7 +812,6 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
}
fn visit_path(&mut self, path: &'tcx hir::Path, id: hir::HirId) {
let id = self.tcx.hir().hir_to_node_id(id);
if let Some(def_id) = path.def.opt_def_id() {
self.tcx.check_stability(def_id, Some(id), path.span)
}
@ -843,7 +837,7 @@ pub fn check_unused_or_stable_features<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
tcx,
access_levels,
};
missing.check_missing_stability(ast::CRATE_NODE_ID, krate.span, "crate");
missing.check_missing_stability(hir::CRATE_HIR_ID, krate.span, "crate");
intravisit::walk_crate(&mut missing, krate);
krate.visit_all_item_likes(&mut missing.as_deep_visitor());
}

View File

@ -1,5 +1,6 @@
use std::{fmt, env};
use crate::hir;
use crate::hir::map::definitions::DefPathData;
use crate::mir;
use crate::ty::{self, Ty, layout};
@ -14,7 +15,6 @@ use crate::ty::query::TyCtxtAt;
use errors::DiagnosticBuilder;
use syntax_pos::{Pos, Span};
use syntax::ast;
use syntax::symbol::Symbol;
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
@ -50,7 +50,7 @@ pub struct ConstEvalErr<'tcx> {
pub struct FrameInfo<'tcx> {
pub call_site: Span, // this span is in the caller!
pub instance: ty::Instance<'tcx>,
pub lint_root: Option<ast::NodeId>,
pub lint_root: Option<hir::HirId>,
}
impl<'tcx> fmt::Display for FrameInfo<'tcx> {
@ -98,7 +98,7 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> {
pub fn report_as_lint(&self,
tcx: TyCtxtAt<'a, 'gcx, 'tcx>,
message: &str,
lint_root: ast::NodeId,
lint_root: hir::HirId,
) -> ErrorHandled {
let lint = self.struct_generic(
tcx,
@ -118,7 +118,7 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> {
&self,
tcx: TyCtxtAt<'a, 'gcx, 'tcx>,
message: &str,
lint_root: Option<ast::NodeId>,
lint_root: Option<hir::HirId>,
) -> Result<DiagnosticBuilder<'tcx>, ErrorHandled> {
match self.error {
EvalErrorKind::Layout(LayoutError::Unknown(_)) |
@ -129,15 +129,15 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> {
}
trace!("reporting const eval failure at {:?}", self.span);
let mut err = if let Some(lint_root) = lint_root {
let node_id = self.stacktrace
let hir_id = self.stacktrace
.iter()
.rev()
.filter_map(|frame| frame.lint_root)
.next()
.unwrap_or(lint_root);
tcx.struct_span_lint_node(
tcx.struct_span_lint_hir(
crate::rustc::lint::builtin::CONST_ERR,
node_id,
hir_id,
tcx.span,
message,
)

View File

@ -413,7 +413,7 @@ pub enum Safety {
/// Unsafe because of an unsafe fn
FnUnsafe,
/// Unsafe because of an `unsafe` block
ExplicitUnsafe(ast::NodeId),
ExplicitUnsafe(hir::HirId),
}
impl_stable_hash_for!(struct Mir<'tcx> {
@ -2103,8 +2103,8 @@ pub struct SourceScopeData {
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
pub struct SourceScopeLocalData {
/// A NodeId with lint levels equivalent to this scope's lint levels.
pub lint_root: ast::NodeId,
/// A HirId with lint levels equivalent to this scope's lint levels.
pub lint_root: hir::HirId,
/// The unsafe block that contains this node.
pub safety: Safety,
}
@ -2854,8 +2854,8 @@ pub enum UnsafetyViolationKind {
General,
/// Permitted in const fn and regular fns.
GeneralAndConstFn,
ExternStatic(ast::NodeId),
BorrowPacked(ast::NodeId),
ExternStatic(hir::HirId),
BorrowPacked(hir::HirId),
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
@ -2872,7 +2872,7 @@ pub struct UnsafetyCheckResult {
pub violations: Lrc<[UnsafetyViolation]>,
/// unsafe blocks in this function, along with whether they are used. This is
/// used for the "unused_unsafe" lint.
pub unsafe_blocks: Lrc<[(ast::NodeId, bool)]>,
pub unsafe_blocks: Lrc<[(hir::HirId, bool)]>,
}
/// The layout of generator state

View File

@ -257,10 +257,10 @@ pub enum ObligationCauseCode<'tcx> {
ReturnNoExpression,
/// `return` with an expression
ReturnType(ast::NodeId),
ReturnType(hir::HirId),
/// Block implicit return
BlockTailExpression(ast::NodeId),
BlockTailExpression(hir::HirId),
/// #[feature(trivial_bounds)] is not enabled
TrivialBound,

View File

@ -10,6 +10,7 @@
use super::elaborate_predicates;
use crate::hir;
use crate::hir::def_id::DefId;
use crate::lint;
use crate::traits::{self, Obligation, ObligationCause};
@ -129,7 +130,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
// It's also hard to get a use site span, so we use the method definition span.
self.lint_node_note(
lint::builtin::WHERE_CLAUSES_OBJECT_SAFETY,
ast::CRATE_NODE_ID,
hir::CRATE_HIR_ID,
*span,
&format!("the trait `{}` cannot be made into an object",
self.item_path_str(trait_def_id)),

View File

@ -2859,11 +2859,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
pub fn lint_node_note<S: Into<MultiSpan>>(self,
lint: &'static Lint,
id: NodeId,
id: hir::HirId,
span: S,
msg: &str,
note: &str) {
let mut err = self.struct_span_lint_node(lint, id, span.into(), msg);
let mut err = self.struct_span_lint_hir(lint, id, span.into(), msg);
err.note(note);
err.emit()
}

View File

@ -2775,8 +2775,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
}
}
pub fn field_index(self, node_id: NodeId, tables: &TypeckTables<'_>) -> usize {
let hir_id = self.hir().node_to_hir_id(node_id);
pub fn field_index(self, hir_id: hir::HirId, tables: &TypeckTables<'_>) -> usize {
tables.field_indices().get(hir_id).cloned().expect("no index for a field")
}

View File

@ -89,15 +89,14 @@ struct CheckLoanCtxt<'a, 'tcx: 'a> {
impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> {
fn consume(&mut self,
consume_id: ast::NodeId,
consume_id: hir::HirId,
consume_span: Span,
cmt: &mc::cmt_<'tcx>,
mode: euv::ConsumeMode) {
debug!("consume(consume_id={}, cmt={:?}, mode={:?})",
consume_id, cmt, mode);
let hir_id = self.tcx().hir().node_to_hir_id(consume_id);
self.consume_common(hir_id.local_id, consume_span, cmt, mode);
self.consume_common(consume_id.local_id, consume_span, cmt, mode);
}
fn matched_pat(&mut self,
@ -118,7 +117,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> {
}
fn borrow(&mut self,
borrow_id: ast::NodeId,
borrow_id: hir::HirId,
borrow_span: Span,
cmt: &mc::cmt_<'tcx>,
loan_region: ty::Region<'tcx>,
@ -130,22 +129,21 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> {
borrow_id, cmt, loan_region,
bk, loan_cause);
let hir_id = self.tcx().hir().node_to_hir_id(borrow_id);
if let Some(lp) = opt_loan_path(cmt) {
let moved_value_use_kind = match loan_cause {
euv::ClosureCapture(_) => MovedInCapture,
_ => MovedInUse,
};
self.check_if_path_is_moved(hir_id.local_id, borrow_span, moved_value_use_kind, &lp);
self.check_if_path_is_moved(borrow_id.local_id, borrow_span, moved_value_use_kind, &lp);
}
self.check_for_conflicting_loans(hir_id.local_id);
self.check_for_conflicting_loans(borrow_id.local_id);
self.check_for_loans_across_yields(cmt, loan_region, borrow_span);
}
fn mutate(&mut self,
assignment_id: ast::NodeId,
assignment_id: hir::HirId,
assignment_span: Span,
assignee_cmt: &mc::cmt_<'tcx>,
mode: euv::MutateMode)
@ -176,8 +174,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> {
}
}
}
self.check_assignment(self.tcx().hir().node_to_hir_id(assignment_id).local_id,
assignment_span, assignee_cmt);
self.check_assignment(assignment_id.local_id, assignment_span, assignee_cmt);
}
fn decl_without_init(&mut self, _id: ast::NodeId, _span: Span) { }
@ -188,7 +185,7 @@ pub fn check_loans<'a, 'b, 'c, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
move_data: &move_data::FlowedMoveData<'c, 'tcx>,
all_loans: &[Loan<'tcx>],
body: &hir::Body) {
debug!("check_loans(body id={})", body.value.id);
debug!("check_loans(body id={})", body.value.hir_id);
let def_id = bccx.tcx.hir().body_owner_def_id(body.id());

View File

@ -68,7 +68,7 @@ struct GatherLoanCtxt<'a, 'tcx: 'a> {
impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> {
fn consume(&mut self,
consume_id: ast::NodeId,
consume_id: hir::HirId,
_consume_span: Span,
cmt: &mc::cmt_<'tcx>,
mode: euv::ConsumeMode) {
@ -79,7 +79,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> {
euv::Move(move_reason) => {
gather_moves::gather_move_from_expr(
self.bccx, &self.move_data, &mut self.move_error_collector,
self.bccx.tcx.hir().node_to_hir_id(consume_id).local_id, cmt, move_reason);
consume_id.local_id, cmt, move_reason);
}
euv::Copy => { }
}
@ -115,7 +115,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> {
}
fn borrow(&mut self,
borrow_id: ast::NodeId,
borrow_id: hir::HirId,
borrow_span: Span,
cmt: &mc::cmt_<'tcx>,
loan_region: ty::Region<'tcx>,
@ -126,8 +126,8 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> {
bk={:?}, loan_cause={:?})",
borrow_id, cmt, loan_region,
bk, loan_cause);
let hir_id = self.bccx.tcx.hir().node_to_hir_id(borrow_id);
self.guarantee_valid(hir_id.local_id,
self.guarantee_valid(borrow_id.local_id,
borrow_span,
cmt,
bk,
@ -136,12 +136,13 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> {
}
fn mutate(&mut self,
assignment_id: ast::NodeId,
assignment_id: hir::HirId,
assignment_span: Span,
assignee_cmt: &mc::cmt_<'tcx>,
_: euv::MutateMode)
{
self.guarantee_assignment_valid(assignment_id,
let node_id = self.bccx.tcx.hir().hir_to_node_id(assignment_id);
self.guarantee_assignment_valid(node_id,
assignment_span,
assignee_cmt);
}

View File

@ -420,13 +420,13 @@ impl<'hir> pprust_hir::PpAnn for IdentifiedAnnotation<'hir> {
}
pprust_hir::AnnNode::Block(blk) => {
s.s.space()?;
s.synth_comment(format!("block node_id: {} hir local_id: {}",
blk.id, blk.hir_id.local_id.as_u32()))
s.synth_comment(format!("block hir_id: {} hir local_id: {}",
blk.hir_id, blk.hir_id.local_id.as_u32()))
}
pprust_hir::AnnNode::Expr(expr) => {
s.s.space()?;
s.synth_comment(format!("node_id: {} hir local_id: {}",
expr.id, expr.hir_id.local_id.as_u32()))?;
s.synth_comment(format!("expr hir_id: {} hir local_id: {}",
expr.hir_id, expr.hir_id.local_id.as_u32()))?;
s.pclose()
}
pprust_hir::AnnNode::Pat(pat) => {
@ -834,15 +834,15 @@ fn print_flowgraph<'a, 'tcx, W: Write>(variants: Vec<borrowck_dot::Variant>,
let body_id = match code {
blocks::Code::Expr(expr) => {
// Find the function this expression is from.
let mut node_id = expr.id;
let mut hir_id = expr.hir_id;
loop {
let node = tcx.hir().get(node_id);
let node = tcx.hir().get_by_hir_id(hir_id);
if let Some(n) = hir::map::blocks::FnLikeNode::from_node(node) {
break n.body();
}
let parent = tcx.hir().get_parent_node(node_id);
assert_ne!(node_id, parent);
node_id = parent;
let parent = tcx.hir().get_parent_node_by_hir_id(hir_id);
assert_ne!(hir_id, parent);
hir_id = parent;
}
}
blocks::Code::FnLike(fn_like) => fn_like.body(),

View File

@ -200,7 +200,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonShorthandFieldPatterns {
}
if let PatKind::Binding(_, _, _, ident, None) = fieldpat.node.pat.node {
if cx.tcx.find_field_index(ident, &variant) ==
Some(cx.tcx.field_index(fieldpat.node.id, cx.tables)) {
Some(cx.tcx.field_index(fieldpat.node.hir_id, cx.tables)) {
let mut err = cx.struct_span_lint(NON_SHORTHAND_FIELD_PATTERNS,
fieldpat.span,
&format!("the `{}:` in this pattern is redundant", ident));

View File

@ -46,12 +46,12 @@ declare_lint! {
#[derive(Copy, Clone)]
pub struct TypeLimits {
/// Id of the last visited negated expression
negated_expr_id: ast::NodeId,
negated_expr_id: hir::HirId,
}
impl TypeLimits {
pub fn new() -> TypeLimits {
TypeLimits { negated_expr_id: ast::DUMMY_NODE_ID }
TypeLimits { negated_expr_id: hir::DUMMY_HIR_ID }
}
}
@ -71,8 +71,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
match e.node {
hir::ExprKind::Unary(hir::UnNeg, ref expr) => {
// propagate negation, if the negation itself isn't negated
if self.negated_expr_id != e.id {
self.negated_expr_id = expr.id;
if self.negated_expr_id != e.hir_id {
self.negated_expr_id = expr.hir_id;
}
}
hir::ExprKind::Binary(binop, ref l, ref r) => {
@ -95,7 +95,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
};
let (_, max) = int_ty_range(int_type);
let max = max as u128;
let negative = self.negated_expr_id == e.id;
let negative = self.negated_expr_id == e.hir_id;
// Detect literal value out of range [min, max] inclusive
// avoiding use of -min to prevent overflow/panic
@ -136,8 +136,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
_ => bug!(),
};
if lit_val < min || lit_val > max {
let parent_id = cx.tcx.hir().get_parent_node(e.id);
if let Node::Expr(parent_expr) = cx.tcx.hir().get(parent_id) {
let parent_id = cx.tcx.hir().get_parent_node_by_hir_id(e.hir_id);
if let Node::Expr(parent_expr) = cx.tcx.hir().get_by_hir_id(parent_id) {
if let hir::ExprKind::Cast(..) = parent_expr.node {
if let ty::Char = cx.tables.expr_ty(parent_expr).sty {
let mut err = cx.struct_span_lint(

View File

@ -58,7 +58,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
let t = cx.tables.expr_ty(&expr);
let type_permits_lack_of_use = if t.is_unit()
|| cx.tcx.is_ty_uninhabited_from(cx.tcx.hir().get_module_parent(expr.id), t) {
|| cx.tcx.is_ty_uninhabited_from(
cx.tcx.hir().get_module_parent_by_hir_id(expr.hir_id), t)
{
true
} else {
match t.sty {

View File

@ -1279,7 +1279,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
/// Serialize the text of exported macros
fn encode_info_for_macro_def(&mut self, macro_def: &hir::MacroDef) -> Entry<'tcx> {
use syntax::print::pprust;
let def_id = self.tcx.hir().local_def_id(macro_def.id);
let def_id = self.tcx.hir().local_def_id_from_hir_id(macro_def.hir_id);
Entry {
kind: EntryKind::MacroDef(self.lazy(&MacroDef {
body: pprust::tts_to_string(&macro_def.body.trees().collect::<Vec<_>>()),
@ -1680,7 +1680,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'tcx> {
self.index.encode_info_for_ty(ty);
}
fn visit_macro_def(&mut self, macro_def: &'tcx hir::MacroDef) {
let def_id = self.index.tcx.hir().local_def_id(macro_def.id);
let def_id = self.index.tcx.hir().local_def_id_from_hir_id(macro_def.hir_id);
self.index.record(def_id, IsolatedEncoder::encode_info_for_macro_def, macro_def);
}
}
@ -1702,13 +1702,13 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> {
match param.kind {
hir::GenericParamKind::Lifetime { .. } => {}
hir::GenericParamKind::Type { ref default, .. } => {
let def_id = self.tcx.hir().local_def_id(param.id);
let def_id = self.tcx.hir().local_def_id_from_hir_id(param.hir_id);
let has_default = Untracked(default.is_some());
let encode_info = IsolatedEncoder::encode_info_for_ty_param;
self.record(def_id, encode_info, (def_id, has_default));
}
hir::GenericParamKind::Const { .. } => {
let def_id = self.tcx.hir().local_def_id(param.id);
let def_id = self.tcx.hir().local_def_id_from_hir_id(param.hir_id);
let encode_info = IsolatedEncoder::encode_info_for_const_param;
self.record(def_id, encode_info, def_id);
}
@ -1729,7 +1729,7 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> {
fn encode_info_for_expr(&mut self, expr: &hir::Expr) {
match expr.node {
hir::ExprKind::Closure(..) => {
let def_id = self.tcx.hir().local_def_id(expr.id);
let def_id = self.tcx.hir().local_def_id_from_hir_id(expr.hir_id);
self.record(def_id, IsolatedEncoder::encode_info_for_closure, def_id);
}
_ => {}

View File

@ -185,7 +185,7 @@ macro_rules! read_hir {
($t:ty) => {
impl<'tcx> DepGraphRead for &'tcx $t {
fn read(&self, tcx: TyCtxt<'_, '_, '_>) {
tcx.hir().read(self.id);
tcx.hir().read_by_hir_id(self.hir_id);
}
}
}

View File

@ -301,7 +301,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
}
let mut_span = tcx.sess.source_map().span_until_non_whitespace(span);
tcx.struct_span_lint_node(
tcx.struct_span_lint_hir(
UNUSED_MUT,
vsi[local_decl.source_info.scope].lint_root,
span,

View File

@ -204,14 +204,14 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
debug!("update_source_scope_for({:?}, {:?})", span, safety_mode);
let new_unsafety = match safety_mode {
BlockSafety::Safe => None,
BlockSafety::ExplicitUnsafe(node_id) => {
BlockSafety::ExplicitUnsafe(hir_id) => {
assert_eq!(self.push_unsafe_count, 0);
match self.unpushed_unsafe {
Safety::Safe => {}
_ => return
}
self.unpushed_unsafe = Safety::ExplicitUnsafe(node_id);
Some(Safety::ExplicitUnsafe(node_id))
self.unpushed_unsafe = Safety::ExplicitUnsafe(hir_id);
Some(Safety::ExplicitUnsafe(hir_id))
}
BlockSafety::PushUnsafe => {
self.push_unsafe_count += 1;

View File

@ -72,13 +72,13 @@ pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'t
};
tcx.infer_ctxt().enter(|infcx| {
let cx = Cx::new(&infcx, id);
let fn_hir_id = tcx.hir().node_to_hir_id(id);
let cx = Cx::new(&infcx, fn_hir_id);
let mut mir = if cx.tables().tainted_by_errors {
build::construct_error(cx, body_id)
} else if cx.body_owner_kind.is_fn_or_closure() {
// fetch the fully liberated fn signature (that is, all bound
// types/lifetimes replaced)
let fn_hir_id = tcx.hir().node_to_hir_id(id);
let fn_sig = cx.tables().liberated_fn_sigs()[fn_hir_id].clone();
let fn_def_id = tcx.hir().local_def_id(id);

View File

@ -308,17 +308,11 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
debug!("in_scope(region_scope={:?}, block={:?})", region_scope, block);
let source_scope = self.source_scope;
let tcx = self.hir.tcx();
if let LintLevel::Explicit(node_id) = lint_level {
if let LintLevel::Explicit(current_hir_id) = lint_level {
let same_lint_scopes = tcx.dep_graph.with_ignore(|| {
let sets = tcx.lint_levels(LOCAL_CRATE);
let parent_hir_id =
tcx.hir().definitions().node_to_hir_id(
self.source_scope_local_data[source_scope].lint_root
);
let current_hir_id =
tcx.hir().definitions().node_to_hir_id(node_id);
sets.lint_level_set(parent_hir_id) ==
sets.lint_level_set(current_hir_id)
let parent_hir_id = self.source_scope_local_data[source_scope].lint_root;
sets.lint_level_set(parent_hir_id) == sets.lint_level_set(current_hir_id)
});
if !same_lint_scopes {

View File

@ -665,11 +665,11 @@ pub fn const_eval_raw_provider<'a, 'tcx>(
// because any code that existed before validation could not have failed validation
// thus preventing such a hard error from being a backwards compatibility hazard
Some(Def::Const(_)) | Some(Def::AssociatedConst(_)) => {
let node_id = tcx.hir().as_local_node_id(def_id).unwrap();
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
err.report_as_lint(
tcx.at(tcx.def_span(def_id)),
"any use of this value will cause an error",
node_id,
hir_id,
)
},
// promoting runtime code is only allowed to error if it references broken constants
@ -685,7 +685,7 @@ pub fn const_eval_raw_provider<'a, 'tcx>(
err.report_as_lint(
tcx.at(span),
"reaching this expression at runtime will panic or abort",
tcx.hir().as_local_node_id(def_id).unwrap(),
tcx.hir().as_local_hir_id(def_id).unwrap(),
)
}
// anything else (array lengths, enum initializers, constant patterns) are reported

View File

@ -30,7 +30,7 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Block {
hir::BlockCheckMode::DefaultBlock =>
BlockSafety::Safe,
hir::BlockCheckMode::UnsafeBlock(..) =>
BlockSafety::ExplicitUnsafe(self.id),
BlockSafety::ExplicitUnsafe(self.hir_id),
hir::BlockCheckMode::PushUnsafeBlock(..) =>
BlockSafety::PushUnsafe,
hir::BlockCheckMode::PopUnsafeBlock(..) =>
@ -103,7 +103,7 @@ fn mirror_stmts<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
},
pattern,
initializer: local.init.to_ref(),
lint_level: cx.lint_level_of(local.id),
lint_level: cx.lint_level_of(local.hir_id),
},
opt_destruction_scope: opt_dxn_ext,
span: stmt_span,

View File

@ -24,7 +24,7 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr {
data: region::ScopeData::Node
};
debug!("Expr::make_mirror(): id={}, span={:?}", self.id, self.span);
debug!("Expr::make_mirror(): id={}, span={:?}", self.hir_id, self.span);
let mut expr = make_mirror_unadjusted(cx, self);
@ -44,7 +44,7 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr {
kind: ExprKind::Scope {
region_scope: expr_scope,
value: expr.to_ref(),
lint_level: cx.lint_level_of(self.id),
lint_level: cx.lint_level_of(self.hir_id),
},
};
@ -529,7 +529,8 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
span_bug!(expr.span, "closure expr w/o closure type: {:?}", closure_ty);
}
};
let upvars = cx.tcx.with_freevars(expr.id, |freevars| {
let expr_node_id = cx.tcx.hir().hir_to_node_id(expr.hir_id);
let upvars = cx.tcx.with_freevars(expr_node_id, |freevars| {
freevars.iter()
.zip(substs.upvar_tys(def_id, cx.tcx))
.map(|(fv, ty)| capture_freevar(cx, expr, fv, ty))
@ -637,7 +638,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
hir::ExprKind::Field(ref source, ..) => {
ExprKind::Field {
lhs: source.to_ref(),
name: Field::new(cx.tcx.field_index(expr.id, cx.tables)),
name: Field::new(cx.tcx.field_index(expr.hir_id, cx.tables)),
}
}
hir::ExprKind::Cast(ref source, ref cast_ty) => {
@ -1184,7 +1185,7 @@ fn capture_freevar<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
let var_hir_id = cx.tcx.hir().node_to_hir_id(freevar.var_id());
let upvar_id = ty::UpvarId {
var_path: ty::UpvarPath { hir_id: var_hir_id },
closure_expr_id: cx.tcx.hir().local_def_id(closure_expr.id).to_local(),
closure_expr_id: cx.tcx.hir().local_def_id_from_hir_id(closure_expr.hir_id).to_local(),
};
let upvar_capture = cx.tables().upvar_capture(upvar_id);
let temp_lifetime = cx.region_scope_tree.temporary_scope(closure_expr.hir_id.local_id);
@ -1223,7 +1224,7 @@ fn field_refs<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
fields.iter()
.map(|field| {
FieldExprRef {
name: Field::new(cx.tcx.field_index(field.id, cx.tables)),
name: Field::new(cx.tcx.field_index(field.hir_id, cx.tables)),
expr: field.expr.to_ref(),
}
})

View File

@ -26,7 +26,7 @@ pub struct Cx<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
tcx: TyCtxt<'a, 'gcx, 'tcx>,
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
pub root_lint_level: ast::NodeId,
pub root_lint_level: hir::HirId,
pub param_env: ty::ParamEnv<'gcx>,
/// Identity `Substs` for use with const-evaluation.
@ -51,10 +51,10 @@ pub struct Cx<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
src_id: ast::NodeId) -> Cx<'a, 'gcx, 'tcx> {
src_id: hir::HirId) -> Cx<'a, 'gcx, 'tcx> {
let tcx = infcx.tcx;
let src_def_id = tcx.hir().local_def_id(src_id);
let body_owner_kind = tcx.hir().body_owner_kind(src_id);
let src_def_id = tcx.hir().local_def_id_from_hir_id(src_id);
let body_owner_kind = tcx.hir().body_owner_kind_by_hir_id(src_id);
let constness = match body_owner_kind {
hir::BodyOwnerKind::Const |
@ -63,7 +63,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
hir::BodyOwnerKind::Fn => hir::Constness::NotConst,
};
let attrs = tcx.hir().attrs(src_id);
let attrs = tcx.hir().attrs_by_hir_id(src_id);
// Some functions always have overflow checks enabled,
// however, they may not get codegen'd, depending on
@ -197,14 +197,13 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
ty.needs_drop(self.tcx.global_tcx(), param_env)
}
fn lint_level_of(&self, node_id: ast::NodeId) -> LintLevel {
let hir_id = self.tcx.hir().definitions().node_to_hir_id(node_id);
fn lint_level_of(&self, hir_id: hir::HirId) -> LintLevel {
let has_lint_level = self.tcx.dep_graph.with_ignore(|| {
self.tcx.lint_levels(LOCAL_CRATE).lint_level_set(hir_id).is_some()
});
if has_lint_level {
LintLevel::Explicit(node_id)
LintLevel::Explicit(hir_id)
} else {
LintLevel::Inherited
}
@ -237,7 +236,7 @@ impl UserAnnotatedTyHelpers<'gcx, 'tcx> for Cx<'_, 'gcx, 'tcx> {
}
}
fn lint_level_for_hir_id(tcx: TyCtxt<'_, '_, '_>, mut id: ast::NodeId) -> ast::NodeId {
fn lint_level_for_hir_id(tcx: TyCtxt<'_, '_, '_>, mut id: hir::HirId) -> hir::HirId {
// Right now we insert a `with_ignore` node in the dep graph here to
// ignore the fact that `lint_levels` below depends on the entire crate.
// For now this'll prevent false positives of recompiling too much when
@ -249,11 +248,10 @@ fn lint_level_for_hir_id(tcx: TyCtxt<'_, '_, '_>, mut id: ast::NodeId) -> ast::N
tcx.dep_graph.with_ignore(|| {
let sets = tcx.lint_levels(LOCAL_CRATE);
loop {
let hir_id = tcx.hir().definitions().node_to_hir_id(id);
if sets.lint_level_set(hir_id).is_some() {
if sets.lint_level_set(id).is_some() {
return id
}
let next = tcx.hir().get_parent_node(id);
let next = tcx.hir().get_parent_node_by_hir_id(id);
if next == id {
bug!("lint traversal reached the root of the crate");
}

View File

@ -28,7 +28,7 @@ mod util;
#[derive(Copy, Clone, Debug)]
pub enum LintLevel {
Inherited,
Explicit(ast::NodeId)
Explicit(hir::HirId)
}
impl LintLevel {
@ -54,7 +54,7 @@ pub struct Block<'tcx> {
#[derive(Copy, Clone, Debug)]
pub enum BlockSafety {
Safe,
ExplicitUnsafe(ast::NodeId),
ExplicitUnsafe(hir::HirId),
PushUnsafe,
PopUnsafe
}

View File

@ -171,7 +171,7 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> {
}
}
let module = self.tcx.hir().get_module_parent(scrut.id);
let module = self.tcx.hir().get_module_parent_by_hir_id(scrut.hir_id);
MatchCheckCtxt::create_and_enter(self.tcx, self.param_env, module, |ref mut cx| {
let mut have_errors = false;
@ -203,7 +203,7 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> {
// Then, if the match has no arms, check whether the scrutinee
// is uninhabited.
let pat_ty = self.tables.node_type(scrut.hir_id);
let module = self.tcx.hir().get_module_parent(scrut.id);
let module = self.tcx.hir().get_module_parent_by_hir_id(scrut.hir_id);
if inlined_arms.is_empty() {
let scrutinee_is_uninhabited = if self.tcx.features().exhaustive_patterns {
self.tcx.is_ty_uninhabited_from(module, pat_ty)
@ -561,10 +561,10 @@ struct MutationChecker<'a, 'tcx: 'a> {
impl<'a, 'tcx> Delegate<'tcx> for MutationChecker<'a, 'tcx> {
fn matched_pat(&mut self, _: &Pat, _: &cmt_<'_>, _: euv::MatchMode) {}
fn consume(&mut self, _: ast::NodeId, _: Span, _: &cmt_<'_>, _: ConsumeMode) {}
fn consume(&mut self, _: hir::HirId, _: Span, _: &cmt_<'_>, _: ConsumeMode) {}
fn consume_pat(&mut self, _: &Pat, _: &cmt_<'_>, _: ConsumeMode) {}
fn borrow(&mut self,
_: ast::NodeId,
_: hir::HirId,
span: Span,
_: &cmt_<'_>,
_: ty::Region<'tcx>,
@ -587,7 +587,7 @@ impl<'a, 'tcx> Delegate<'tcx> for MutationChecker<'a, 'tcx> {
}
}
fn decl_without_init(&mut self, _: ast::NodeId, _: Span) {}
fn mutate(&mut self, _: ast::NodeId, span: Span, _: &cmt_<'_>, mode: MutateMode) {
fn mutate(&mut self, _: hir::HirId, span: Span, _: &cmt_<'_>, mode: MutateMode) {
match mode {
MutateMode::JustWrite | MutateMode::WriteAndRead => {
struct_span_err!(self.cx.tcx.sess, span, E0302, "cannot assign in a pattern guard")

View File

@ -631,7 +631,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
fields.iter()
.map(|field| {
FieldPattern {
field: Field::new(self.tcx.field_index(field.node.id,
field: Field::new(self.tcx.field_index(field.node.hir_id,
self.tables)),
pattern: self.lower_pattern(&field.node.pat),
}

View File

@ -12,7 +12,6 @@ use rustc::lint::builtin::{SAFE_EXTERN_STATICS, SAFE_PACKED_BORROWS, UNUSED_UNSA
use rustc::mir::*;
use rustc::mir::visit::{PlaceContext, Visitor, MutatingUseContext};
use syntax::ast;
use syntax::symbol::Symbol;
use std::ops::Bound;
@ -29,8 +28,8 @@ pub struct UnsafetyChecker<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
/// Mark an `unsafe` block as used, so we don't lint it.
used_unsafe: FxHashSet<ast::NodeId>,
inherited_blocks: Vec<(ast::NodeId, bool)>,
used_unsafe: FxHashSet<hir::HirId>,
inherited_blocks: Vec<(hir::HirId, bool)>,
}
impl<'a, 'gcx, 'tcx> UnsafetyChecker<'a, 'tcx> {
@ -349,7 +348,7 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> {
fn register_violations(&mut self,
violations: &[UnsafetyViolation],
unsafe_blocks: &[(ast::NodeId, bool)]) {
unsafe_blocks: &[(hir::HirId, bool)]) {
let safety = self.source_scope_local_data[self.source_info.scope].safety;
let within_unsafe = match safety {
// `unsafe` blocks are required in safe code
@ -375,10 +374,10 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> {
}
// `unsafe` function bodies allow unsafe without additional unsafe blocks
Safety::BuiltinUnsafe | Safety::FnUnsafe => true,
Safety::ExplicitUnsafe(node_id) => {
Safety::ExplicitUnsafe(hir_id) => {
// mark unsafe block as used if there are any unsafe operations inside
if !violations.is_empty() {
self.used_unsafe.insert(node_id);
self.used_unsafe.insert(hir_id);
}
// only some unsafety is allowed in const fn
if self.min_const_fn {
@ -405,8 +404,8 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> {
true
}
};
self.inherited_blocks.extend(unsafe_blocks.iter().map(|&(node_id, is_used)| {
(node_id, is_used && !within_unsafe)
self.inherited_blocks.extend(unsafe_blocks.iter().map(|&(hir_id, is_used)| {
(hir_id, is_used && !within_unsafe)
}));
}
fn check_mut_borrowing_layout_constrained_field(
@ -467,8 +466,8 @@ pub(crate) fn provide(providers: &mut Providers<'_>) {
}
struct UnusedUnsafeVisitor<'a> {
used_unsafe: &'a FxHashSet<ast::NodeId>,
unsafe_blocks: &'a mut Vec<(ast::NodeId, bool)>,
used_unsafe: &'a FxHashSet<hir::HirId>,
unsafe_blocks: &'a mut Vec<(hir::HirId, bool)>,
}
impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for UnusedUnsafeVisitor<'a> {
@ -482,19 +481,19 @@ impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for UnusedUnsafeVisitor<'a> {
hir::intravisit::walk_block(self, block);
if let hir::UnsafeBlock(hir::UserProvided) = block.rules {
self.unsafe_blocks.push((block.id, self.used_unsafe.contains(&block.id)));
self.unsafe_blocks.push((block.hir_id, self.used_unsafe.contains(&block.hir_id)));
}
}
}
fn check_unused_unsafe<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
def_id: DefId,
used_unsafe: &FxHashSet<ast::NodeId>,
unsafe_blocks: &'a mut Vec<(ast::NodeId, bool)>)
used_unsafe: &FxHashSet<hir::HirId>,
unsafe_blocks: &'a mut Vec<(hir::HirId, bool)>)
{
let body_id =
tcx.hir().as_local_node_id(def_id).and_then(|node_id| {
tcx.hir().maybe_body_owned_by(node_id)
tcx.hir().as_local_hir_id(def_id).and_then(|hir_id| {
tcx.hir().maybe_body_owned_by_by_hir_id(hir_id)
});
let body_id = match body_id {
@ -574,18 +573,18 @@ fn unsafe_derive_on_repr_packed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: D
&message);
}
/// Returns the `NodeId` for an enclosing scope that is also `unsafe`.
/// Returns the `HirId` for an enclosing scope that is also `unsafe`.
fn is_enclosed(tcx: TyCtxt<'_, '_, '_>,
used_unsafe: &FxHashSet<ast::NodeId>,
id: ast::NodeId) -> Option<(String, ast::NodeId)> {
let parent_id = tcx.hir().get_parent_node(id);
used_unsafe: &FxHashSet<hir::HirId>,
id: hir::HirId) -> Option<(String, hir::HirId)> {
let parent_id = tcx.hir().get_parent_node_by_hir_id(id);
if parent_id != id {
if used_unsafe.contains(&parent_id) {
Some(("block".to_string(), parent_id))
} else if let Some(Node::Item(&hir::Item {
node: hir::ItemKind::Fn(_, header, _, _),
..
})) = tcx.hir().find(parent_id) {
})) = tcx.hir().find_by_hir_id(parent_id) {
match header.unsafety {
hir::Unsafety::Unsafe => Some(("fn".to_string(), parent_id)),
hir::Unsafety::Normal => None,
@ -599,14 +598,14 @@ fn is_enclosed(tcx: TyCtxt<'_, '_, '_>,
}
fn report_unused_unsafe(tcx: TyCtxt<'_, '_, '_>,
used_unsafe: &FxHashSet<ast::NodeId>,
id: ast::NodeId) {
let span = tcx.sess.source_map().def_span(tcx.hir().span(id));
used_unsafe: &FxHashSet<hir::HirId>,
id: hir::HirId) {
let span = tcx.sess.source_map().def_span(tcx.hir().span_by_hir_id(id));
let msg = "unnecessary `unsafe` block";
let mut db = tcx.struct_span_lint_node(UNUSED_UNSAFE, id, span, msg);
let mut db = tcx.struct_span_lint_hir(UNUSED_UNSAFE, id, span, msg);
db.span_label(span, msg);
if let Some((kind, id)) = is_enclosed(tcx, used_unsafe, id) {
db.span_label(tcx.sess.source_map().def_span(tcx.hir().span(id)),
db.span_label(tcx.sess.source_map().def_span(tcx.hir().span_by_hir_id(id)),
format!("because it's nested under this `unsafe` {}", kind));
}
db.emit();
@ -655,20 +654,20 @@ pub fn check_unsafety<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) {
.note(&details.as_str()[..])
.emit();
}
UnsafetyViolationKind::ExternStatic(lint_node_id) => {
UnsafetyViolationKind::ExternStatic(lint_hir_id) => {
tcx.lint_node_note(SAFE_EXTERN_STATICS,
lint_node_id,
lint_hir_id,
source_info.span,
&format!("{} is unsafe and requires unsafe function or block \
(error E0133)", &description.as_str()[..]),
&details.as_str()[..]);
}
UnsafetyViolationKind::BorrowPacked(lint_node_id) => {
UnsafetyViolationKind::BorrowPacked(lint_hir_id) => {
if let Some(impl_def_id) = builtin_derive_def_id(tcx, def_id) {
tcx.unsafe_derive_on_repr_packed(impl_def_id);
} else {
tcx.lint_node_note(SAFE_PACKED_BORROWS,
lint_node_id,
lint_hir_id,
source_info.span,
&format!("{} is unsafe and requires unsafe function or block \
(error E0133)", &description.as_str()[..]),
@ -679,7 +678,7 @@ pub fn check_unsafety<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) {
}
let mut unsafe_blocks: Vec<_> = unsafe_blocks.into_iter().collect();
unsafe_blocks.sort();
unsafe_blocks.sort_by_cached_key(|(hir_id, _)| tcx.hir().hir_to_node_id(*hir_id));
let used_unsafe: FxHashSet<_> = unsafe_blocks.iter()
.flat_map(|&&(id, used)| if used { Some(id) } else { None })
.collect();

View File

@ -430,10 +430,10 @@ impl<'a, 'mir, 'tcx> ConstPropagator<'a, 'mir, 'tcx> {
} else {
"left"
};
let node_id = source_scope_local_data[source_info.scope].lint_root;
self.tcx.lint_node(
let hir_id = source_scope_local_data[source_info.scope].lint_root;
self.tcx.lint_hir(
::rustc::lint::builtin::EXCEEDING_BITSHIFTS,
node_id,
hir_id,
span,
&format!("attempt to shift {} with overflow", dir));
return None;

View File

@ -2,7 +2,7 @@
// pieces of AST and HIR. The resulting numbers are good approximations but not
// completely accurate (some things might be counted twice, others missed).
use rustc::hir;
use rustc::hir::{self, HirId};
use rustc::hir::intravisit as hir_visit;
use rustc::util::common::to_readable_str;
use rustc::util::nodemap::{FxHashMap, FxHashSet};
@ -12,7 +12,7 @@ use syntax_pos::Span;
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
enum Id {
Node(NodeId),
Node(HirId),
Attr(AttrId),
None,
}
@ -119,7 +119,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
}
fn visit_item(&mut self, i: &'v hir::Item) {
self.record("Item", Id::Node(i.id), i);
self.record("Item", Id::Node(i.hir_id), i);
hir_visit::walk_item(self, i)
}
@ -129,22 +129,22 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
}
fn visit_foreign_item(&mut self, i: &'v hir::ForeignItem) {
self.record("ForeignItem", Id::Node(i.id), i);
self.record("ForeignItem", Id::Node(i.hir_id), i);
hir_visit::walk_foreign_item(self, i)
}
fn visit_local(&mut self, l: &'v hir::Local) {
self.record("Local", Id::Node(l.id), l);
self.record("Local", Id::Node(l.hir_id), l);
hir_visit::walk_local(self, l)
}
fn visit_block(&mut self, b: &'v hir::Block) {
self.record("Block", Id::Node(b.id), b);
self.record("Block", Id::Node(b.hir_id), b);
hir_visit::walk_block(self, b)
}
fn visit_stmt(&mut self, s: &'v hir::Stmt) {
self.record("Stmt", Id::Node(s.id), s);
self.record("Stmt", Id::Node(s.hir_id), s);
hir_visit::walk_stmt(self, s)
}
@ -154,17 +154,17 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
}
fn visit_pat(&mut self, p: &'v hir::Pat) {
self.record("Pat", Id::Node(p.id), p);
self.record("Pat", Id::Node(p.hir_id), p);
hir_visit::walk_pat(self, p)
}
fn visit_expr(&mut self, ex: &'v hir::Expr) {
self.record("Expr", Id::Node(ex.id), ex);
self.record("Expr", Id::Node(ex.hir_id), ex);
hir_visit::walk_expr(self, ex)
}
fn visit_ty(&mut self, t: &'v hir::Ty) {
self.record("Ty", Id::Node(t.id), t);
self.record("Ty", Id::Node(t.hir_id), t);
hir_visit::walk_ty(self, t)
}
@ -184,12 +184,12 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
}
fn visit_trait_item(&mut self, ti: &'v hir::TraitItem) {
self.record("TraitItem", Id::Node(ti.id), ti);
self.record("TraitItem", Id::Node(ti.hir_id), ti);
hir_visit::walk_trait_item(self, ti)
}
fn visit_impl_item(&mut self, ii: &'v hir::ImplItem) {
self.record("ImplItem", Id::Node(ii.id), ii);
self.record("ImplItem", Id::Node(ii.hir_id), ii);
hir_visit::walk_impl_item(self, ii)
}
@ -199,7 +199,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
}
fn visit_struct_field(&mut self, s: &'v hir::StructField) {
self.record("StructField", Id::Node(s.id), s);
self.record("StructField", Id::Node(s.hir_id), s);
hir_visit::walk_struct_field(self, s)
}
@ -212,7 +212,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
}
fn visit_lifetime(&mut self, lifetime: &'v hir::Lifetime) {
self.record("Lifetime", Id::Node(lifetime.id), lifetime);
self.record("Lifetime", Id::Node(lifetime.hir_id), lifetime);
hir_visit::walk_lifetime(self, lifetime)
}
@ -234,7 +234,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
}
fn visit_assoc_type_binding(&mut self, type_binding: &'v hir::TypeBinding) {
self.record("TypeBinding", Id::Node(type_binding.id), type_binding);
self.record("TypeBinding", Id::Node(type_binding.hir_id), type_binding);
hir_visit::walk_assoc_type_binding(self, type_binding)
}
@ -243,7 +243,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
}
fn visit_macro_def(&mut self, macro_def: &'v hir::MacroDef) {
self.record("MacroDef", Id::Node(macro_def.id), macro_def);
self.record("MacroDef", Id::Node(macro_def.hir_id), macro_def);
hir_visit::walk_macro_def(self, macro_def)
}
}

View File

@ -23,7 +23,7 @@ use rustc::middle::mem_categorization::Categorization;
use rustc::ty::{self, Ty, TyCtxt};
use rustc::ty::query::Providers;
use rustc::ty::subst::Substs;
use rustc::util::nodemap::{ItemLocalSet, NodeSet};
use rustc::util::nodemap::{ItemLocalSet, HirIdSet};
use rustc::hir;
use rustc_data_structures::sync::Lrc;
use syntax::ast;
@ -92,7 +92,7 @@ struct CheckCrateVisitor<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
in_fn: bool,
in_static: bool,
mut_rvalue_borrows: NodeSet,
mut_rvalue_borrows: HirIdSet,
param_env: ty::ParamEnv<'tcx>,
identity_substs: &'tcx Substs<'tcx>,
tables: &'a ty::TypeckTables<'tcx>,
@ -169,7 +169,7 @@ impl<'a, 'gcx> CheckCrateVisitor<'a, 'gcx> {
fn remove_mut_rvalue_borrow(&mut self, pat: &hir::Pat) -> bool {
let mut any_removed = false;
pat.walk(|p| {
any_removed |= self.mut_rvalue_borrows.remove(&p.id);
any_removed |= self.mut_rvalue_borrows.remove(&p.hir_id);
true
});
any_removed
@ -223,7 +223,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
hir::StmtKind::Local(ref local) => {
if self.remove_mut_rvalue_borrow(&local.pat) {
if let Some(init) = &local.init {
self.mut_rvalue_borrows.insert(init.id);
self.mut_rvalue_borrows.insert(init.hir_id);
}
}
@ -248,7 +248,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
outer &= check_adjustments(self, ex);
// Handle borrows on (or inside the autorefs of) this expression.
if self.mut_rvalue_borrows.remove(&ex.id) {
if self.mut_rvalue_borrows.remove(&ex.hir_id) {
outer = NotPromotable
}
@ -318,7 +318,7 @@ fn check_expr_kind<'a, 'tcx>(
}
hir::ExprKind::Cast(ref from, _) => {
let expr_promotability = v.check_expr(from);
debug!("Checking const cast(id={})", from.id);
debug!("Checking const cast(id={})", from.hir_id);
match v.tables.cast_kinds().get(from.hir_id) {
None => {
v.tcx.sess.delay_span_bug(e.span, "no kind for cast");
@ -456,9 +456,10 @@ fn check_expr_kind<'a, 'tcx>(
hir::ExprKind::Closure(_capture_clause, ref _box_fn_decl,
body_id, _span, _option_generator_movability) => {
let nested_body_promotable = v.check_nested_body(body_id);
let node_id = v.tcx.hir().hir_to_node_id(e.hir_id);
// Paths in constant contexts cannot refer to local variables,
// as there are none, and thus closures can't have upvars there.
if v.tcx.with_freevars(e.id, |fv| !fv.is_empty()) {
if v.tcx.with_freevars(node_id, |fv| !fv.is_empty()) {
NotPromotable
} else {
nested_body_promotable
@ -518,7 +519,7 @@ fn check_expr_kind<'a, 'tcx>(
mut_borrow = v.remove_mut_rvalue_borrow(pat);
}
if mut_borrow {
v.mut_rvalue_borrows.insert(expr.id);
v.mut_rvalue_borrows.insert(expr.hir_id);
}
let _ = v.check_expr(expr);
@ -619,13 +620,13 @@ fn check_adjustments<'a, 'tcx>(
impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for CheckCrateVisitor<'a, 'gcx> {
fn consume(&mut self,
_consume_id: ast::NodeId,
_consume_id: hir::HirId,
_consume_span: Span,
_cmt: &mc::cmt_<'_>,
_mode: euv::ConsumeMode) {}
fn borrow(&mut self,
borrow_id: ast::NodeId,
borrow_id: hir::HirId,
_borrow_span: Span,
cmt: &mc::cmt_<'tcx>,
_loan_region: ty::Region<'tcx>,
@ -678,7 +679,7 @@ impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for CheckCrateVisitor<'a, 'gcx> {
fn decl_without_init(&mut self, _id: ast::NodeId, _span: Span) {}
fn mutate(&mut self,
_assignment_id: ast::NodeId,
_assignment_id: hir::HirId,
_assignment_span: Span,
_assignee_cmt: &mc::cmt_<'_>,
_mode: euv::MutateMode) {

View File

@ -21,7 +21,7 @@ use rustc::ty::{self, TyCtxt, Ty, TraitRef, TypeFoldable, GenericParamDefKind};
use rustc::ty::fold::TypeVisitor;
use rustc::ty::query::Providers;
use rustc::ty::subst::Substs;
use rustc::util::nodemap::NodeSet;
use rustc::util::nodemap::HirIdSet;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::sync::Lrc;
use syntax::ast::{self, DUMMY_NODE_ID, Ident};
@ -271,7 +271,8 @@ fn def_id_visibility<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
return (ctor_vis, span, descr);
}
Node::Expr(expr) => {
return (ty::Visibility::Restricted(tcx.hir().get_module_parent(expr.id)),
return (ty::Visibility::Restricted(
tcx.hir().get_module_parent_by_hir_id(expr.hir_id)),
expr.span, "private")
}
node => bug!("unexpected node kind: {:?}", node)
@ -695,18 +696,20 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
}
fn visit_macro_def(&mut self, md: &'tcx hir::MacroDef) {
let node_id = self.tcx.hir().hir_to_node_id(md.hir_id);
if md.legacy {
self.update(md.id, Some(AccessLevel::Public));
self.update(node_id, Some(AccessLevel::Public));
return
}
let module_did = ty::DefIdTree::parent(
self.tcx,
self.tcx.hir().local_def_id(md.id)
self.tcx.hir().local_def_id_from_hir_id(md.hir_id)
).unwrap();
let mut module_id = self.tcx.hir().as_local_node_id(module_did).unwrap();
let level = if md.vis.node.is_pub() { self.get(module_id) } else { None };
let level = self.update(md.id, level);
let level = self.update(node_id, level);
if level.is_none() {
return
}
@ -870,7 +873,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> {
// unmentioned fields, just check them all.
for (vf_index, variant_field) in variant.fields.iter().enumerate() {
let field = fields.iter().find(|f| {
self.tcx.field_index(f.id, self.tables) == vf_index
self.tcx.field_index(f.hir_id, self.tables) == vf_index
});
let (use_ctxt, span) = match field {
Some(field) => (field.ident.span, field.span),
@ -881,7 +884,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> {
} else {
for field in fields {
let use_ctxt = field.ident.span;
let index = self.tcx.field_index(field.id, self.tables);
let index = self.tcx.field_index(field.hir_id, self.tables);
self.check_field(use_ctxt, field.span, adt, &variant.fields[index]);
}
}
@ -900,7 +903,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> {
let variant = adt.variant_of_def(def);
for field in fields {
let use_ctxt = field.node.ident.span;
let index = self.tcx.field_index(field.node.id, self.tables);
let index = self.tcx.field_index(field.node.hir_id, self.tables);
self.check_field(use_ctxt, field.span, adt, &variant.fields[index]);
}
}
@ -1152,7 +1155,7 @@ struct ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx: 'a> {
access_levels: &'a AccessLevels,
in_variant: bool,
// Set of errors produced by this obsolete visitor.
old_error_set: NodeSet,
old_error_set: HirIdSet,
}
struct ObsoleteCheckTypeForPrivatenessVisitor<'a, 'b: 'a, 'tcx: 'b> {
@ -1196,7 +1199,7 @@ impl<'a, 'tcx> ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
fn check_generic_bound(&mut self, bound: &hir::GenericBound) {
if let hir::GenericBound::Trait(ref trait_ref, _) = *bound {
if self.path_is_private_type(&trait_ref.trait_ref.path) {
self.old_error_set.insert(trait_ref.trait_ref.ref_id);
self.old_error_set.insert(trait_ref.trait_ref.hir_ref_id);
}
}
}
@ -1452,7 +1455,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
fn visit_ty(&mut self, t: &'tcx hir::Ty) {
if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = t.node {
if self.path_is_private_type(path) {
self.old_error_set.insert(t.id);
self.old_error_set.insert(t.hir_id);
}
}
intravisit::walk_ty(self, t)
@ -1596,7 +1599,7 @@ impl<'a, 'tcx> DefIdVisitor<'a, 'tcx> for SearchInterfaceForPrivateItemsVisitor<
struct PrivateItemsInPublicInterfacesVisitor<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
has_pub_restricted: bool,
old_error_set: &'a NodeSet,
old_error_set: &'a HirIdSet,
private_crates: FxHashSet<CrateNum>
}
@ -1608,7 +1611,7 @@ impl<'a, 'tcx> PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> {
// Slow path taken only if there any errors in the crate.
for &id in self.old_error_set {
// Walk up the nodes until we find `item_id` (or we hit a root).
let mut id = id;
let mut id = self.tcx.hir().hir_to_node_id(id);
loop {
if id == item_id {
has_old_errors = true;

View File

@ -1517,7 +1517,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
return;
}
};
let def = self.save_ctxt.get_path_def(hir_expr.id);
let node_id = self.save_ctxt.tcx.hir().hir_to_node_id(hir_expr.hir_id);
let def = self.save_ctxt.get_path_def(node_id);
self.process_struct_lit(ex, path, fields, adt.variant_of_def(def), base)
}
ast::ExprKind::MethodCall(ref seg, ref args) => self.process_method_call(ex, seg, args),

View File

@ -397,7 +397,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
Some(Node::Item(item)) => match item.node {
hir::ItemKind::Impl(.., ref ty, _) => {
let mut qualname = String::from("<");
qualname.push_str(&self.tcx.hir().node_to_pretty_string(ty.id));
qualname.push_str(&self.tcx.hir().hir_to_pretty_string(ty.hir_id));
let trait_id = self.tcx.trait_id_of_impl(impl_id);
let mut decl_id = None;

View File

@ -304,8 +304,8 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
} else {
let mut multispan = MultiSpan::from_span(span);
multispan.push_span_label(span_late, note.to_string());
tcx.lint_node(lint::builtin::LATE_BOUND_LIFETIME_ARGUMENTS,
args.args[0].id(), multispan, msg);
tcx.lint_hir(lint::builtin::LATE_BOUND_LIFETIME_ARGUMENTS,
args.args[0].id(), multispan, msg);
return (false, None);
}
}
@ -885,7 +885,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
let msg = format!("associated type `{}` is private", binding.item_name);
tcx.sess.span_err(binding.span, &msg);
}
tcx.check_stability(assoc_ty.def_id, Some(ref_id), binding.span);
tcx.check_stability(assoc_ty.def_id, Some(hir_ref_id), binding.span);
if !speculative {
dup_bindings.entry(assoc_ty.def_id)
@ -1267,7 +1267,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
// parameter or `Self`.
pub fn associated_path_to_ty(
&self,
ref_id: ast::NodeId,
hir_ref_id: hir::HirId,
span: Span,
qself_ty: Ty<'tcx>,
qself_def: Def,
@ -1292,7 +1292,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
let def = Def::Variant(variant_def.did);
if permit_variants {
check_type_alias_enum_variants_enabled(tcx, span);
tcx.check_stability(variant_def.did, Some(ref_id), span);
tcx.check_stability(variant_def.did, Some(hir_ref_id), span);
return (qself_ty, def);
} else {
variant_resolution = Some(def);
@ -1370,7 +1370,6 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
};
let trait_did = bound.def_id();
let hir_ref_id = self.tcx().hir().node_to_hir_id(ref_id);
let (assoc_ident, def_scope) = tcx.adjust_ident(assoc_ident, trait_did, hir_ref_id);
let item = tcx.associated_items(trait_did).find(|i| {
Namespace::from(i.kind) == Namespace::Type &&
@ -1385,12 +1384,12 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
let msg = format!("{} `{}` is private", def.kind_name(), assoc_ident);
tcx.sess.span_err(span, &msg);
}
tcx.check_stability(item.def_id, Some(ref_id), span);
tcx.check_stability(item.def_id, Some(hir_ref_id), span);
if let Some(variant_def) = variant_resolution {
let mut err = tcx.struct_span_lint_node(
let mut err = tcx.struct_span_lint_hir(
AMBIGUOUS_ASSOCIATED_ITEMS,
ref_id,
hir_ref_id,
span,
"ambiguous associated item",
);
@ -1742,7 +1741,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
/// internal notion of a type.
pub fn ast_ty_to_ty(&self, ast_ty: &hir::Ty) -> Ty<'tcx> {
debug!("ast_ty_to_ty(id={:?}, ast_ty={:?} ty_ty={:?})",
ast_ty.id, ast_ty, ast_ty.node);
ast_ty.hir_id, ast_ty, ast_ty.node);
let tcx = self.tcx();
@ -1795,7 +1794,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
} else {
Def::Err
};
self.associated_path_to_ty(ast_ty.id, ast_ty.span, ty, def, segment, false).0
self.associated_path_to_ty(ast_ty.hir_id, ast_ty.span, ty, def, segment, false).0
}
hir::TyKind::Array(ref ty, ref length) => {
let length_def_id = tcx.hir().local_def_id(length.id);

View File

@ -64,7 +64,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}
}
PatKind::Path(ref qpath) => {
let (def, _, _) = self.resolve_ty_and_def_ufcs(qpath, pat.id, pat.span);
let (def, _, _) = self.resolve_ty_and_def_ufcs(qpath, pat.hir_id, pat.span);
match def {
Def::Const(..) | Def::AssociatedConst(..) => false,
_ => true,
@ -630,7 +630,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
if self.diverges.get().always() {
for arm in arms {
self.warn_if_unreachable(arm.body.id, arm.body.span, "arm");
self.warn_if_unreachable(arm.body.hir_id, arm.body.span, "arm");
}
}
@ -725,7 +725,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
let cause = if i == 0 {
// The reason for the first arm to fail is not that the match arms diverge,
// but rather that there's a prior obligation that doesn't hold.
self.cause(arm_span, ObligationCauseCode::BlockTailExpression(arm.body.id))
self.cause(arm_span, ObligationCauseCode::BlockTailExpression(arm.body.hir_id))
} else {
self.cause(expr.span, ObligationCauseCode::MatchExpressionArm {
arm_span,
@ -761,7 +761,8 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
) -> Ty<'tcx>
{
// Resolve the path and check the definition for errors.
let (variant, pat_ty) = if let Some(variant_ty) = self.check_struct_path(qpath, pat.id) {
let (variant, pat_ty) = if let Some(variant_ty) = self.check_struct_path(qpath, pat.hir_id)
{
variant_ty
} else {
for field in fields {
@ -779,7 +780,8 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
self.demand_eqtype_pat(pat.span, expected, pat_ty, match_discrim_span);
// Type-check subpatterns.
if self.check_struct_pat_fields(pat_ty, pat.id, pat.span, variant, fields, etc, def_bm) {
if self.check_struct_pat_fields(pat_ty, pat.hir_id, pat.span, variant, fields, etc, def_bm)
{
pat_ty
} else {
self.tcx.types.err
@ -795,7 +797,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
let tcx = self.tcx;
// Resolve the path and check the definition for errors.
let (def, opt_ty, segments) = self.resolve_ty_and_def_ufcs(qpath, pat.id, pat.span);
let (def, opt_ty, segments) = self.resolve_ty_and_def_ufcs(qpath, pat.hir_id, pat.span);
match def {
Def::Err => {
self.set_tainted_by_errors();
@ -818,7 +820,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
}
// Type-check the path.
let pat_ty = self.instantiate_value_path(segments, opt_ty, def, pat.span, pat.id).0;
let pat_ty = self.instantiate_value_path(segments, opt_ty, def, pat.span, pat.hir_id).0;
self.demand_suptype(pat.span, expected, pat_ty);
pat_ty
}
@ -849,7 +851,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
};
// Resolve the path and check the definition for errors.
let (def, opt_ty, segments) = self.resolve_ty_and_def_ufcs(qpath, pat.id, pat.span);
let (def, opt_ty, segments) = self.resolve_ty_and_def_ufcs(qpath, pat.hir_id, pat.span);
if def == Def::Err {
self.set_tainted_by_errors();
on_error();
@ -857,7 +859,8 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
}
// Type-check the path.
let (pat_ty, def) = self.instantiate_value_path(segments, opt_ty, def, pat.span, pat.id);
let (pat_ty, def) = self.instantiate_value_path(segments, opt_ty, def, pat.span,
pat.hir_id);
if !pat_ty.is_fn() {
report_unexpected_def(def);
return self.tcx.types.err;
@ -897,7 +900,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
let field_ty = self.field_ty(subpat.span, &variant.fields[i], substs);
self.check_pat_walk(&subpat, field_ty, def_bm, match_arm_pat_span);
self.tcx.check_stability(variant.fields[i].did, Some(pat.id), subpat.span);
self.tcx.check_stability(variant.fields[i].did, Some(pat.hir_id), subpat.span);
}
} else {
let subpats_ending = if subpats.len() == 1 { "" } else { "s" };
@ -917,7 +920,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
fn check_struct_pat_fields(&self,
adt_ty: Ty<'tcx>,
pat_id: ast::NodeId,
pat_id: hir::HirId,
span: Span,
variant: &'tcx ty::VariantDef,
fields: &'gcx [Spanned<hir::FieldPat>],
@ -963,7 +966,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
vacant.insert(span);
field_map.get(&ident)
.map(|(i, f)| {
self.write_field_index(field.id, *i);
self.write_field_index(field.hir_id, *i);
self.tcx.check_stability(f.did, Some(pat_id), span);
self.field_ty(span, f, substs)
})

View File

@ -250,7 +250,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
if let &ty::Adt(adt_def, ..) = t {
if adt_def.is_enum() {
if let hir::ExprKind::Call(ref expr, _) = call_expr.node {
unit_variant = Some(self.tcx.hir().node_to_pretty_string(expr.id))
unit_variant = Some(self.tcx.hir().hir_to_pretty_string(expr.hir_id))
}
}
}

View File

@ -399,9 +399,9 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> {
} else {
("", lint::builtin::TRIVIAL_CASTS)
};
let mut err = fcx.tcx.struct_span_lint_node(
let mut err = fcx.tcx.struct_span_lint_hir(
lint,
self.expr.id,
self.expr.hir_id,
self.span,
&format!("trivial {}cast: `{}` as `{}`",
adjective,
@ -417,7 +417,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> {
self.cast_ty = fcx.structurally_resolved_type(self.span, self.cast_ty);
debug!("check_cast({}, {:?} as {:?})",
self.expr.id,
self.expr.hir_id,
self.expr_ty,
self.cast_ty);

View File

@ -72,7 +72,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
opt_kind, expected_sig
);
let expr_def_id = self.tcx.hir().local_def_id(expr.id);
let expr_def_id = self.tcx.hir().local_def_id_from_hir_id(expr.hir_id);
let ClosureSignatures {
bound_sig,
@ -86,7 +86,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
self.param_env,
liberated_sig,
decl,
expr.id,
expr.hir_id,
body,
gen,
).1;
@ -131,8 +131,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
let closure_type = self.tcx.mk_closure(expr_def_id, substs);
debug!(
"check_closure: expr.id={:?} closure_type={:?}",
expr.id, closure_type
"check_closure: expr.hir_id={:?} closure_type={:?}",
expr.hir_id, closure_type
);
// Tuple up the arguments and insert the resulting function type into

View File

@ -1177,7 +1177,8 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E>
Expressions::UpFront(coercion_sites) => {
// if the user gave us an array to validate, check that we got
// the next expression in the list, as expected
assert_eq!(coercion_sites[self.pushed].as_coercion_site().id, e.id);
assert_eq!(coercion_sites[self.pushed].as_coercion_site().hir_id,
e.hir_id);
}
}
self.pushed += 1;
@ -1208,7 +1209,7 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E>
db.span_label(cause.span, "return type is not `()`");
}
ObligationCauseCode::BlockTailExpression(blk_id) => {
let parent_id = fcx.tcx.hir().get_parent_node(blk_id);
let parent_id = fcx.tcx.hir().get_parent_node_by_hir_id(blk_id);
db = self.report_return_mismatched_types(
cause,
expected,
@ -1246,8 +1247,8 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E>
found: Ty<'tcx>,
err: TypeError<'tcx>,
fcx: &FnCtxt<'a, 'gcx, 'tcx>,
id: syntax::ast::NodeId,
expression: Option<(&'gcx hir::Expr, syntax::ast::NodeId)>,
id: hir::HirId,
expression: Option<(&'gcx hir::Expr, hir::HirId)>,
) -> DiagnosticBuilder<'a> {
let mut db = fcx.report_mismatched_types(cause, expected, found, err);
@ -1257,7 +1258,7 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E>
// Verify that this is a tail expression of a function, otherwise the
// label pointing out the cause for the type coercion will be wrong
// as prior return coercions would not be relevant (#57664).
let parent_id = fcx.tcx.hir().get_parent_node(id);
let parent_id = fcx.tcx.hir().get_parent_node_by_hir_id(id);
let fn_decl = if let Some((expr, blk_id)) = expression {
pointing_at_return_type = fcx.suggest_mismatched_types_on_tail(
&mut db,
@ -1267,7 +1268,7 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E>
cause.span,
blk_id,
);
let parent = fcx.tcx.hir().get(parent_id);
let parent = fcx.tcx.hir().get_by_hir_id(parent_id);
fcx.get_node_fn_decl(parent).map(|(fn_decl, _, is_main)| (fn_decl, is_main))
} else {
fcx.get_fn_decl(parent_id)

View File

@ -2,7 +2,6 @@ use crate::check::FnCtxt;
use rustc::infer::InferOk;
use rustc::traits::{ObligationCause, ObligationCauseCode};
use syntax::ast;
use syntax::util::parser::PREC_POSTFIX;
use syntax_pos::Span;
use rustc::hir;
@ -164,7 +163,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
probe::Mode::MethodCall,
expected,
checked_ty,
ast::DUMMY_NODE_ID);
hir::DUMMY_HIR_ID);
methods.retain(|m| {
self.has_no_input_arg(m) &&
self.tcx.get_attrs(m.def_id).iter()
@ -218,15 +217,15 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
if let hir::def::Def::Local(id) = path.def {
let parent = self.tcx.hir().get_parent_node(id);
if let Some(Node::Expr(hir::Expr {
id,
hir_id,
node: hir::ExprKind::Closure(_, decl, ..),
..
})) = self.tcx.hir().find(parent) {
let parent = self.tcx.hir().get_parent_node(*id);
let parent = self.tcx.hir().get_parent_node_by_hir_id(*hir_id);
if let (Some(Node::Expr(hir::Expr {
node: hir::ExprKind::MethodCall(path, span, expr),
..
})), 1) = (self.tcx.hir().find(parent), decl.inputs.len()) {
})), 1) = (self.tcx.hir().find_by_hir_id(parent), decl.inputs.len()) {
let self_ty = self.tables.borrow().node_type(expr[0].hir_id);
let self_ty = format!("{:?}", self_ty);
let name = path.ident.as_str();
@ -470,8 +469,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
checked_ty: Ty<'tcx>,
expected_ty: Ty<'tcx>,
) -> bool {
let parent_id = self.tcx.hir().get_parent_node(expr.id);
if let Some(parent) = self.tcx.hir().find(parent_id) {
let parent_id = self.tcx.hir().get_parent_node_by_hir_id(expr.hir_id);
if let Some(parent) = self.tcx.hir().find_by_hir_id(parent_id) {
// Shouldn't suggest `.into()` on `const`s.
if let Node::Item(Item { node: ItemKind::Const(_, _), .. }) = parent {
// FIXME(estebank): modify once we decide to suggest `as` casts
@ -501,10 +500,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
if let Some(hir::Node::Expr(hir::Expr {
node: hir::ExprKind::Struct(_, fields, _),
..
})) = self.tcx.hir().find(self.tcx.hir().get_parent_node(expr.id)) {
})) = self.tcx.hir().find_by_hir_id(self.tcx.hir().get_parent_node_by_hir_id(expr.hir_id)) {
// `expr` is a literal field for a struct, only suggest if appropriate
for field in fields {
if field.expr.id == expr.id && field.is_shorthand {
if field.expr.hir_id == expr.hir_id && field.is_shorthand {
// This is a field literal
prefix = format!("{}: ", field.ident);
break;

View File

@ -105,7 +105,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
pub fn method_exists(&self,
method_name: ast::Ident,
self_ty: Ty<'tcx>,
call_expr_id: ast::NodeId,
call_expr_id: hir::HirId,
allow_private: bool)
-> bool {
let mode = probe::Mode::MethodCall;
@ -131,7 +131,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
msg: &str,
method_name: ast::Ident,
self_ty: Ty<'tcx>,
call_expr_id: ast::NodeId,
call_expr_id: hir::HirId,
) {
let has_params = self
.probe_for_name(
@ -202,7 +202,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
.unwrap().insert(import_def_id);
}
self.tcx.check_stability(pick.item.def_id, Some(call_expr.id), span);
self.tcx.check_stability(pick.item.def_id, Some(call_expr.hir_id), span);
let result = self.confirm_method(
span,
@ -255,7 +255,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
let mode = probe::Mode::MethodCall;
let self_ty = self.resolve_type_vars_if_possible(&self_ty);
self.probe_for_name(span, mode, method_name, IsSuggestion(false),
self_ty, call_expr.id, scope)
self_ty, call_expr.hir_id, scope)
}
/// `lookup_method_in_trait` is used for overloaded operators.
@ -399,7 +399,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
span: Span,
method_name: ast::Ident,
self_ty: Ty<'tcx>,
expr_id: ast::NodeId
expr_id: hir::HirId
) -> Result<Def, MethodError<'tcx>> {
debug!(
"resolve_ufcs: method_name={:?} self_ty={:?} expr_id={:?}",

View File

@ -209,7 +209,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
mode: Mode,
return_type: Ty<'tcx>,
self_ty: Ty<'tcx>,
scope_expr_id: ast::NodeId)
scope_expr_id: hir::HirId)
-> Vec<ty::AssociatedItem> {
debug!("probe(self_ty={:?}, return_type={}, scope_expr_id={})",
self_ty,
@ -238,7 +238,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
item_name: ast::Ident,
is_suggestion: IsSuggestion,
self_ty: Ty<'tcx>,
scope_expr_id: ast::NodeId,
scope_expr_id: hir::HirId,
scope: ProbeScope)
-> PickResult<'tcx> {
debug!("probe(self_ty={:?}, item_name={}, scope_expr_id={})",
@ -263,7 +263,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
return_type: Option<Ty<'tcx>>,
is_suggestion: IsSuggestion,
self_ty: Ty<'tcx>,
scope_expr_id: ast::NodeId,
scope_expr_id: hir::HirId,
scope: ProbeScope,
op: OP)
-> Result<R, MethodError<'tcx>>
@ -340,7 +340,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
"the type of this value must be known \
to call a method on a raw pointer on it");
} else {
self.tcx.lint_node(
self.tcx.lint_hir(
lint::builtin::TYVAR_BEHIND_RAW_POINTER,
scope_expr_id,
span,
@ -825,13 +825,12 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
}
fn assemble_extension_candidates_for_traits_in_scope(&mut self,
expr_id: ast::NodeId)
expr_hir_id: hir::HirId)
-> Result<(), MethodError<'tcx>> {
if expr_id == ast::DUMMY_NODE_ID {
if expr_hir_id == hir::DUMMY_HIR_ID {
return Ok(())
}
let mut duplicates = FxHashSet::default();
let expr_hir_id = self.tcx.hir().node_to_hir_id(expr_id);
let opt_applicable_traits = self.tcx.in_scope_traits(expr_hir_id);
if let Some(applicable_traits) = opt_applicable_traits {
for trait_candidate in applicable_traits.iter() {
@ -1415,7 +1414,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
steps, IsSuggestion(true));
pcx.allow_similar_names = true;
pcx.assemble_inherent_candidates();
pcx.assemble_extension_candidates_for_traits_in_scope(ast::DUMMY_NODE_ID)?;
pcx.assemble_extension_candidates_for_traits_in_scope(hir::DUMMY_HIR_ID)?;
let method_names = pcx.candidate_method_names();
pcx.allow_similar_names = false;
@ -1425,7 +1424,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
pcx.reset();
pcx.method_name = Some(method_name);
pcx.assemble_inherent_candidates();
pcx.assemble_extension_candidates_for_traits_in_scope(ast::DUMMY_NODE_ID)
pcx.assemble_extension_candidates_for_traits_in_scope(hir::DUMMY_HIR_ID)
.ok().map_or(None, |_| {
pcx.pick_core()
.and_then(|pick| pick.ok())

View File

@ -137,7 +137,7 @@ use crate::TypeAndSubsts;
use crate::lint;
use crate::util::captures::Captures;
use crate::util::common::{ErrorReported, indenter};
use crate::util::nodemap::{DefIdMap, DefIdSet, FxHashMap, FxHashSet, NodeMap};
use crate::util::nodemap::{DefIdMap, DefIdSet, FxHashMap, FxHashSet, HirIdMap, NodeMap};
pub use self::Expectation::*;
use self::autoderef::Autoderef;
@ -388,14 +388,14 @@ impl Needs {
#[derive(Copy, Clone)]
pub struct UnsafetyState {
pub def: ast::NodeId,
pub def: hir::HirId,
pub unsafety: hir::Unsafety,
pub unsafe_push_count: u32,
from_fn: bool
}
impl UnsafetyState {
pub fn function(unsafety: hir::Unsafety, def: ast::NodeId) -> UnsafetyState {
pub fn function(unsafety: hir::Unsafety, def: hir::HirId) -> UnsafetyState {
UnsafetyState { def: def, unsafety: unsafety, unsafe_push_count: 0, from_fn: true }
}
@ -410,11 +410,11 @@ impl UnsafetyState {
unsafety => {
let (unsafety, def, count) = match blk.rules {
hir::PushUnsafeBlock(..) =>
(unsafety, blk.id, self.unsafe_push_count.checked_add(1).unwrap()),
(unsafety, blk.hir_id, self.unsafe_push_count.checked_add(1).unwrap()),
hir::PopUnsafeBlock(..) =>
(unsafety, blk.id, self.unsafe_push_count.checked_sub(1).unwrap()),
(unsafety, blk.hir_id, self.unsafe_push_count.checked_sub(1).unwrap()),
hir::UnsafeBlock(..) =>
(hir::Unsafety::Unsafe, blk.id, self.unsafe_push_count),
(hir::Unsafety::Unsafe, blk.hir_id, self.unsafe_push_count),
hir::DefaultBlock =>
(unsafety, self.def, self.unsafe_push_count),
};
@ -497,11 +497,11 @@ pub struct BreakableCtxt<'gcx: 'tcx, 'tcx> {
pub struct EnclosingBreakables<'gcx: 'tcx, 'tcx> {
stack: Vec<BreakableCtxt<'gcx, 'tcx>>,
by_id: NodeMap<usize>,
by_id: HirIdMap<usize>,
}
impl<'gcx, 'tcx> EnclosingBreakables<'gcx, 'tcx> {
fn find_breakable(&mut self, target_id: ast::NodeId) -> &mut BreakableCtxt<'gcx, 'tcx> {
fn find_breakable(&mut self, target_id: hir::HirId) -> &mut BreakableCtxt<'gcx, 'tcx> {
let ix = *self.by_id.get(&target_id).unwrap_or_else(|| {
bug!("could not find enclosing breakable with id {}", target_id);
});
@ -770,10 +770,10 @@ fn adt_destructor<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
/// (notably closures), `typeck_tables(def_id)` would wind up
/// redirecting to the owning function.
fn primary_body_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
id: ast::NodeId)
id: hir::HirId)
-> Option<(hir::BodyId, Option<&'tcx hir::FnDecl>)>
{
match tcx.hir().get(id) {
match tcx.hir().get_by_hir_id(id) {
Node::Item(item) => {
match item.node {
hir::ItemKind::Const(_, body) |
@ -820,7 +820,7 @@ fn has_typeck_tables<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
return tcx.has_typeck_tables(outer_def_id);
}
let id = tcx.hir().as_local_node_id(def_id).unwrap();
let id = tcx.hir().as_local_hir_id(def_id).unwrap();
primary_body_of(tcx, id).is_some()
}
@ -840,8 +840,8 @@ fn typeck_tables_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
return tcx.typeck_tables_of(outer_def_id);
}
let id = tcx.hir().as_local_node_id(def_id).unwrap();
let span = tcx.hir().span(id);
let id = tcx.hir().as_local_hir_id(def_id).unwrap();
let span = tcx.hir().span_by_hir_id(id);
// Figure out what primary body this item has.
let (body_id, fn_decl) = primary_body_of(tcx, id).unwrap_or_else(|| {
@ -925,8 +925,8 @@ fn typeck_tables_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// Consistency check our TypeckTables instance can hold all ItemLocalIds
// it will need to hold.
assert_eq!(tables.local_id_root,
Some(DefId::local(tcx.hir().definitions().node_to_hir_id(id).owner)));
assert_eq!(tables.local_id_root, Some(DefId::local(id.owner)));
tables
}
@ -939,7 +939,7 @@ fn check_abi<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, span: Span, abi: Abi) {
struct GatherLocalsVisitor<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
fcx: &'a FnCtxt<'a, 'gcx, 'tcx>,
parent_id: ast::NodeId,
parent_id: hir::HirId,
}
impl<'a, 'gcx, 'tcx> GatherLocalsVisitor<'a, 'gcx, 'tcx> {
@ -1051,7 +1051,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
fn_sig: ty::FnSig<'tcx>,
decl: &'gcx hir::FnDecl,
fn_id: ast::NodeId,
fn_id: hir::HirId,
body: &'gcx hir::Body,
can_be_generator: Option<hir::GeneratorMovability>)
-> (FnCtxt<'a, 'gcx, 'tcx>, Option<GeneratorTypes<'tcx>>)
@ -1085,9 +1085,9 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
fcx.yield_ty = Some(yield_ty);
}
let outer_def_id = fcx.tcx.closure_base_def_id(fcx.tcx.hir().local_def_id(fn_id));
let outer_node_id = fcx.tcx.hir().as_local_node_id(outer_def_id).unwrap();
GatherLocalsVisitor { fcx: &fcx, parent_id: outer_node_id, }.visit_body(body);
let outer_def_id = fcx.tcx.closure_base_def_id(fcx.tcx.hir().local_def_id_from_hir_id(fn_id));
let outer_hir_id = fcx.tcx.hir().as_local_hir_id(outer_def_id).unwrap();
GatherLocalsVisitor { fcx: &fcx, parent_id: outer_hir_id, }.visit_body(body);
// Add formal parameters.
for (arg_ty, arg) in fn_sig.inputs().iter().zip(&body.arguments) {
@ -1110,8 +1110,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
fcx.write_ty(arg.hir_id, arg_ty);
}
let fn_hir_id = fcx.tcx.hir().node_to_hir_id(fn_id);
inherited.tables.borrow_mut().liberated_fn_sigs_mut().insert(fn_hir_id, fn_sig);
inherited.tables.borrow_mut().liberated_fn_sigs_mut().insert(fn_id, fn_sig);
fcx.check_return_expr(&body.value);
@ -1164,14 +1163,13 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
// Check that the main return type implements the termination trait.
if let Some(term_id) = fcx.tcx.lang_items().termination() {
if let Some((def_id, EntryFnType::Main)) = fcx.tcx.entry_fn(LOCAL_CRATE) {
let main_id = fcx.tcx.hir().as_local_node_id(def_id).unwrap();
let main_id = fcx.tcx.hir().as_local_hir_id(def_id).unwrap();
if main_id == fn_id {
let substs = fcx.tcx.mk_substs_trait(declared_ret_ty, &[]);
let trait_ref = ty::TraitRef::new(term_id, substs);
let return_ty_span = decl.output.span();
let fn_hir_id = fcx.tcx.hir().node_to_hir_id(fn_id);
let cause = traits::ObligationCause::new(
return_ty_span, fn_hir_id, ObligationCauseCode::MainFunctionType);
return_ty_span, fn_id, ObligationCauseCode::MainFunctionType);
inherited.register_predicate(
traits::Obligation::new(
@ -1182,7 +1180,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
// Check that a function marked as `#[panic_handler]` has signature `fn(&PanicInfo) -> !`
if let Some(panic_impl_did) = fcx.tcx.lang_items().panic_impl() {
if panic_impl_did == fcx.tcx.hir().local_def_id(fn_id) {
if panic_impl_did == fcx.tcx.hir().local_def_id_from_hir_id(fn_id) {
if let Some(panic_info_did) = fcx.tcx.lang_items().panic_info() {
// at this point we don't care if there are duplicate handlers or if the handler has
// the wrong signature as this value we'll be used when writing metadata and that
@ -1197,7 +1195,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
}
let inputs = fn_sig.inputs();
let span = fcx.tcx.hir().span(fn_id);
let span = fcx.tcx.hir().span_by_hir_id(fn_id);
if inputs.len() == 1 {
let arg_is_panic_info = match inputs[0].sty {
ty::Ref(region, ty, mutbl) => match ty.sty {
@ -1218,7 +1216,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
);
}
if let Node::Item(item) = fcx.tcx.hir().get(fn_id) {
if let Node::Item(item) = fcx.tcx.hir().get_by_hir_id(fn_id) {
if let ItemKind::Fn(_, _, ref generics, _) = item.node {
if !generics.params.is_empty() {
fcx.tcx.sess.span_err(
@ -1240,7 +1238,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
// Check that a function marked as `#[alloc_error_handler]` has signature `fn(Layout) -> !`
if let Some(alloc_error_handler_did) = fcx.tcx.lang_items().oom() {
if alloc_error_handler_did == fcx.tcx.hir().local_def_id(fn_id) {
if alloc_error_handler_did == fcx.tcx.hir().local_def_id_from_hir_id(fn_id) {
if let Some(alloc_layout_did) = fcx.tcx.lang_items().alloc_layout() {
if declared_ret_ty.sty != ty::Never {
fcx.tcx.sess.span_err(
@ -1250,7 +1248,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
}
let inputs = fn_sig.inputs();
let span = fcx.tcx.hir().span(fn_id);
let span = fcx.tcx.hir().span_by_hir_id(fn_id);
if inputs.len() == 1 {
let arg_is_alloc_layout = match inputs[0].sty {
ty::Adt(ref adt, _) => {
@ -1266,7 +1264,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
);
}
if let Node::Item(item) = fcx.tcx.hir().get(fn_id) {
if let Node::Item(item) = fcx.tcx.hir().get_by_hir_id(fn_id) {
if let ItemKind::Fn(_, _, ref generics, _) = item.node {
if !generics.params.is_empty() {
fcx.tcx.sess.span_err(
@ -2030,7 +2028,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
ret_coercion_span: RefCell::new(None),
yield_ty: None,
ps: RefCell::new(UnsafetyState::function(hir::Unsafety::Normal,
ast::CRATE_NODE_ID)),
hir::CRATE_HIR_ID)),
diverges: Cell::new(Diverges::Maybe),
has_errors: Cell::new(false),
enclosing_breakables: RefCell::new(EnclosingBreakables {
@ -2051,13 +2049,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
/// Produces warning on the given node, if the current point in the
/// function is unreachable, and there hasn't been another warning.
fn warn_if_unreachable(&self, id: ast::NodeId, span: Span, kind: &str) {
fn warn_if_unreachable(&self, id: hir::HirId, span: Span, kind: &str) {
if self.diverges.get() == Diverges::Always {
self.diverges.set(Diverges::WarnedAlways);
debug!("warn_if_unreachable: id={:?} span={:?} kind={}", id, span, kind);
self.tcx().lint_node(
self.tcx().lint_hir(
lint::builtin::UNREACHABLE_CODE,
id, span,
&format!("unreachable {}", kind));
@ -2145,8 +2143,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}
}
pub fn write_field_index(&self, node_id: ast::NodeId, index: usize) {
let hir_id = self.tcx.hir().node_to_hir_id(node_id);
pub fn write_field_index(&self, hir_id: hir::HirId, index: usize) {
self.tables.borrow_mut().field_indices_mut().insert(hir_id, index);
}
@ -2339,10 +2336,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
/// `InferCtxt::instantiate_opaque_types` for more details.
fn instantiate_opaque_types_from_value<T: TypeFoldable<'tcx>>(
&self,
parent_id: ast::NodeId,
parent_id: hir::HirId,
value: &T,
) -> T {
let parent_def_id = self.tcx.hir().local_def_id(parent_id);
let parent_def_id = self.tcx.hir().local_def_id_from_hir_id(parent_id);
debug!("instantiate_opaque_types_from_value(parent_def_id={:?}, value={:?})",
parent_def_id,
value);
@ -3009,7 +3006,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
// Closure arguments themselves can't be diverging, but
// a previous argument can, e.g., `foo(panic!(), || {})`.
if !check_closures {
self.warn_if_unreachable(arg.id, arg.span, "expression");
self.warn_if_unreachable(arg.hir_id, arg.span, "expression");
}
let is_closure = match arg.node {
@ -3340,7 +3337,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
ret_coercion.borrow_mut()
.coerce(self,
&self.cause(return_expr.span,
ObligationCauseCode::ReturnType(return_expr.id)),
ObligationCauseCode::ReturnType(return_expr.hir_id)),
return_expr,
return_expr_ty);
}
@ -3511,13 +3508,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
let field_ty = self.field_ty(expr.span, field, substs);
// Save the index of all fields regardless of their visibility in case
// of error recovery.
self.write_field_index(expr.id, index);
self.write_field_index(expr.hir_id, index);
if field.vis.is_accessible_from(def_scope, self.tcx) {
let adjustments = autoderef.adjust_steps(self, needs);
self.apply_adjustments(base, adjustments);
autoderef.finalize(self);
self.tcx.check_stability(field.did, Some(expr.id), expr.span);
self.tcx.check_stability(field.did, Some(expr.hir_id), expr.span);
return field_ty;
}
private_candidate = Some((base_def.did, field_ty));
@ -3532,7 +3529,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
self.apply_adjustments(base, adjustments);
autoderef.finalize(self);
self.write_field_index(expr.id, index);
self.write_field_index(expr.hir_id, index);
return field_ty;
}
}
@ -3549,31 +3546,33 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
"field `{}` of struct `{}` is private",
field, struct_path);
// Also check if an accessible method exists, which is often what is meant.
if self.method_exists(field, expr_t, expr.id, false) && !self.expr_in_place(expr.id) {
if self.method_exists(field, expr_t, expr.hir_id, false)
&& !self.expr_in_place(expr.hir_id)
{
self.suggest_method_call(
&mut err,
&format!("a method `{}` also exists, call it with parentheses", field),
field,
expr_t,
expr.id,
expr.hir_id,
);
}
err.emit();
field_ty
} else if field.name == keywords::Invalid.name() {
self.tcx().types.err
} else if self.method_exists(field, expr_t, expr.id, true) {
} else if self.method_exists(field, expr_t, expr.hir_id, true) {
let mut err = type_error_struct!(self.tcx().sess, field.span, expr_t, E0615,
"attempted to take value of method `{}` on type `{}`",
field, expr_t);
if !self.expr_in_place(expr.id) {
if !self.expr_in_place(expr.hir_id) {
self.suggest_method_call(
&mut err,
"use parentheses to call the method",
field,
expr_t,
expr.id
expr.hir_id
);
} else {
err.help("methods are immutable and cannot be assigned to");
@ -3613,7 +3612,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
) {
let base = self.tcx.sess.source_map()
.span_to_snippet(base.span)
.unwrap_or_else(|_| self.tcx.hir().node_to_pretty_string(base.id));
.unwrap_or_else(|_|
self.tcx.hir().hir_to_pretty_string(base.hir_id));
let help = "instead of using tuple indexing, use array indexing";
let suggestion = format!("{}[{}]", base, field);
let applicability = if len < user_index {
@ -3629,7 +3629,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
ty::RawPtr(..) => {
let base = self.tcx.sess.source_map()
.span_to_snippet(base.span)
.unwrap_or_else(|_| self.tcx.hir().node_to_pretty_string(base.id));
.unwrap_or_else(|_| self.tcx.hir().hir_to_pretty_string(base.hir_id));
let msg = format!("`{}` is a raw pointer; try dereferencing it", base);
let suggestion = format!("(*{}).{}", base, field);
err.span_suggestion(
@ -3754,7 +3754,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
fn check_expr_struct_fields(&self,
adt_ty: Ty<'tcx>,
expected: Expectation<'tcx>,
expr_id: ast::NodeId,
expr_id: hir::HirId,
span: Span,
variant: &'tcx ty::VariantDef,
ast_fields: &'gcx [hir::Field],
@ -3787,7 +3787,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
let ident = tcx.adjust_ident(field.ident, variant.did, self.body_id).0;
let field_type = if let Some((i, v_field)) = remaining_fields.remove(&ident) {
seen_fields.insert(ident, field.span);
self.write_field_index(field.id, i);
self.write_field_index(field.hir_id, i);
// We don't look at stability attributes on
// struct-like enums (yet...), but it's definitely not
@ -3875,13 +3875,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
pub fn check_struct_path(&self,
qpath: &QPath,
node_id: ast::NodeId)
hir_id: hir::HirId)
-> Option<(&'tcx ty::VariantDef, Ty<'tcx>)> {
let path_span = match *qpath {
QPath::Resolved(_, ref path) => path.span,
QPath::TypeRelative(ref qself, _) => qself.span
};
let (def, ty) = self.finish_resolving_struct_path(qpath, path_span, node_id);
let (def, ty) = self.finish_resolving_struct_path(qpath, path_span, hir_id);
let variant = match def {
Def::Err => {
self.set_tainted_by_errors();
@ -3909,7 +3909,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
if let Some((variant, did, substs)) = variant {
debug!("check_struct_path: did={:?} substs={:?}", did, substs);
let hir_id = self.tcx.hir().node_to_hir_id(node_id);
self.write_user_type_annotation_from_substs(hir_id, did, substs, None);
// Check bounds on type arguments used in the path.
@ -3938,7 +3937,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
{
// Find the relevant variant
let (variant, adt_ty) =
if let Some(variant_ty) = self.check_struct_path(qpath, expr.id) {
if let Some(variant_ty) = self.check_struct_path(qpath, expr.hir_id) {
variant_ty
} else {
self.check_struct_fields_on_error(fields, base_expr);
@ -3958,7 +3957,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
adt.variant_descr());
}
let error_happened = self.check_expr_struct_fields(adt_ty, expected, expr.id, path_span,
let error_happened = self.check_expr_struct_fields(adt_ty, expected, expr.hir_id, path_span,
variant, fields, base_expr.is_none());
if let &Some(ref base_expr) = base_expr {
// If check_expr_struct_fields hit an error, do not attempt to populate
@ -4007,7 +4006,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
expr, expected);
// Warn for expressions after diverging siblings.
self.warn_if_unreachable(expr.id, expr.span, "expression");
self.warn_if_unreachable(expr.hir_id, expr.span, "expression");
// Hide the outer diverging and has_errors flags.
let old_diverges = self.diverges.get();
@ -4023,7 +4022,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
ExprKind::Loop(..) | ExprKind::While(..) |
ExprKind::If(..) | ExprKind::Match(..) => {}
_ => self.warn_if_unreachable(expr.id, expr.span, "expression")
_ => self.warn_if_unreachable(expr.hir_id, expr.span, "expression")
}
// Any expression that produces a value of type `!` must have diverged
@ -4040,7 +4039,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
self.diverges.set(self.diverges.get() | old_diverges);
self.has_errors.set(self.has_errors.get() | old_has_errors);
debug!("type of {} is...", self.tcx.hir().node_to_string(expr.id));
debug!("type of {} is...", self.tcx.hir().hir_to_string(expr.hir_id));
debug!("... {:?}, expected is {:?}", ty, expected);
ty
@ -4060,7 +4059,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
);
let tcx = self.tcx;
let id = expr.id;
let id = expr.hir_id;
match expr.node {
ExprKind::Box(ref subexpr) => {
let expected_inner = expected.to_option(self).map_or(NoExpectation, |ty| {
@ -4192,7 +4191,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}
}
ExprKind::Path(ref qpath) => {
let (def, opt_ty, segs) = self.resolve_ty_and_def_ufcs(qpath, expr.id, expr.span);
let (def, opt_ty, segs) = self.resolve_ty_and_def_ufcs(qpath, expr.hir_id,
expr.span);
let ty = match def {
Def::Err => {
self.set_tainted_by_errors();
@ -4257,6 +4257,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}
ExprKind::Break(destination, ref expr_opt) => {
if let Ok(target_id) = destination.target_id {
let target_id = tcx.hir().node_to_hir_id(target_id);
let (e_ty, cause);
if let Some(ref e) = *expr_opt {
// If this is a break with a value, we need to type-check
@ -4362,7 +4363,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
*self.ret_coercion_span.borrow_mut() = Some(expr.span);
}
let cause = self.cause(expr.span, ObligationCauseCode::ReturnNoExpression);
if let Some((fn_decl, _)) = self.get_fn_decl(expr.id) {
if let Some((fn_decl, _)) = self.get_fn_decl(expr.hir_id) {
coercion.coerce_forced_unit(
self,
&cause,
@ -4424,7 +4425,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
may_break: false, // Will get updated if/when we find a `break`.
};
let (ctxt, ()) = self.with_breakable_ctxt(expr.id, ctxt, || {
let (ctxt, ()) = self.with_breakable_ctxt(expr.hir_id, ctxt, || {
self.check_expr_has_type_or_error(&cond, tcx.types.bool);
let cond_diverging = self.diverges.get();
self.check_block_no_value(&body);
@ -4460,7 +4461,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
may_break: false, // Will get updated if/when we find a `break`.
};
let (ctxt, ()) = self.with_breakable_ctxt(expr.id, ctxt, || {
let (ctxt, ()) = self.with_breakable_ctxt(expr.hir_id, ctxt, || {
self.check_block_no_value(&body);
});
@ -4717,7 +4718,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
fn finish_resolving_struct_path(&self,
qpath: &QPath,
path_span: Span,
node_id: ast::NodeId)
hir_id: hir::HirId)
-> (Def, Ty<'tcx>)
{
match *qpath {
@ -4734,11 +4735,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
} else {
Def::Err
};
let (ty, def) = AstConv::associated_path_to_ty(self, node_id, path_span,
let (ty, def) = AstConv::associated_path_to_ty(self, hir_id, path_span,
ty, def, segment, true);
// Write back the new resolution.
let hir_id = self.tcx.hir().node_to_hir_id(node_id);
self.tables.borrow_mut().type_dependent_defs_mut().insert(hir_id, def);
(def, ty)
@ -4750,11 +4750,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
/// definition. The newly resolved definition is written into `type_dependent_defs`.
pub fn resolve_ty_and_def_ufcs<'b>(&self,
qpath: &'b QPath,
node_id: ast::NodeId,
hir_id: hir::HirId,
span: Span)
-> (Def, Option<Ty<'tcx>>, &'b [hir::PathSegment])
{
debug!("resolve_ty_and_def_ufcs: qpath={:?} node_id={:?} span={:?}", qpath, node_id, span);
debug!("resolve_ty_and_def_ufcs: qpath={:?} hir_id={:?} span={:?}", qpath, hir_id, span);
let (ty, qself, item_segment) = match *qpath {
QPath::Resolved(ref opt_qself, ref path) => {
return (path.def,
@ -4765,14 +4765,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
(self.to_ty(qself), qself, segment)
}
};
let hir_id = self.tcx.hir().node_to_hir_id(node_id);
if let Some(cached_def) = self.tables.borrow().type_dependent_defs().get(hir_id) {
// Return directly on cache hit. This is useful to avoid doubly reporting
// errors with default match binding modes. See #44614.
return (*cached_def, Some(ty), slice::from_ref(&**item_segment))
}
let item_name = item_segment.ident;
let def = match self.resolve_ufcs(span, item_name, ty, node_id) {
let def = match self.resolve_ufcs(span, item_name, ty, hir_id) {
Ok(def) => def,
Err(error) => {
let def = match error {
@ -4854,7 +4853,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
hir::StmtKind::Local(..) | hir::StmtKind::Expr(..) | hir::StmtKind::Semi(..) => {}
}
self.warn_if_unreachable(stmt.id, stmt.span, "statement");
self.warn_if_unreachable(stmt.hir_id, stmt.span, "statement");
// Hide the outer diverging and `has_errors` flags.
let old_diverges = self.diverges.get();
@ -4936,7 +4935,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
may_break: false,
};
let (ctxt, ()) = self.with_breakable_ctxt(blk.id, ctxt, || {
let (ctxt, ()) = self.with_breakable_ctxt(blk.hir_id, ctxt, || {
for s in &blk.stmts {
self.check_stmt(s);
}
@ -4946,12 +4945,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
let tail_expr_ty = tail_expr.map(|t| self.check_expr_with_expectation(t, expected));
let mut enclosing_breakables = self.enclosing_breakables.borrow_mut();
let ctxt = enclosing_breakables.find_breakable(blk.id);
let ctxt = enclosing_breakables.find_breakable(blk.hir_id);
let coerce = ctxt.coerce.as_mut().unwrap();
if let Some(tail_expr_ty) = tail_expr_ty {
let tail_expr = tail_expr.unwrap();
let cause = self.cause(tail_expr.span,
ObligationCauseCode::BlockTailExpression(blk.id));
ObligationCauseCode::BlockTailExpression(blk.hir_id));
coerce.coerce(self,
&cause,
tail_expr,
@ -4975,9 +4974,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
// that highlight errors inline.
let mut sp = blk.span;
let mut fn_span = None;
if let Some((decl, ident)) = self.get_parent_fn_decl(blk.id) {
let blk_node_id = self.tcx.hir().hir_to_node_id(blk.hir_id);
if let Some((decl, ident)) = self.get_parent_fn_decl(blk_node_id) {
let ret_sp = decl.output.span();
if let Some(block_sp) = self.parent_item_span(blk.id) {
if let Some(block_sp) = self.parent_item_span(blk_node_id) {
// HACK: on some cases (`ui/liveness/liveness-issue-2163.rs`) the
// output would otherwise be incorrect and even misleading. Make sure
// the span we're aiming at correspond to a `fn` body.
@ -5067,13 +5067,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}
}
/// Given a `NodeId`, return the `FnDecl` of the method it is enclosed by and whether a
/// Given a `HirId`, return the `FnDecl` of the method it is enclosed by and whether a
/// suggestion can be made, `None` otherwise.
pub fn get_fn_decl(&self, blk_id: ast::NodeId) -> Option<(hir::FnDecl, bool)> {
pub fn get_fn_decl(&self, blk_id: hir::HirId) -> Option<(hir::FnDecl, bool)> {
// 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.
self.tcx.hir().get_return_block(blk_id).and_then(|blk_id| {
let parent = self.tcx.hir().get(blk_id);
let parent = self.tcx.hir().get_by_hir_id(blk_id);
self.get_node_fn_decl(parent).map(|(fn_decl, _, is_main)| (fn_decl, is_main))
})
}
@ -5090,7 +5090,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
expected: Ty<'tcx>,
found: Ty<'tcx>,
cause_span: Span,
blk_id: ast::NodeId,
blk_id: hir::HirId,
) -> bool {
self.suggest_missing_semicolon(err, expression, expected, cause_span);
let mut pointing_at_return_type = false;
@ -5303,14 +5303,14 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
self_ty: Option<Ty<'tcx>>,
def: Def,
span: Span,
node_id: ast::NodeId)
hir_id: hir::HirId)
-> (Ty<'tcx>, Def) {
debug!(
"instantiate_value_path(segments={:?}, self_ty={:?}, def={:?}, node_id={})",
"instantiate_value_path(segments={:?}, self_ty={:?}, def={:?}, hir_id={})",
segments,
self_ty,
def,
node_id,
hir_id,
);
let tcx = self.tcx;
@ -5380,7 +5380,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
Def::Local(nid) | Def::Upvar(nid, ..) => {
let ty = self.local_ty(span, nid).decl_ty;
let ty = self.normalize_associated_types_in(span, &ty);
self.write_ty(tcx.hir().node_to_hir_id(node_id), ty);
self.write_ty(hir_id, ty);
return (ty, def);
}
_ => {}
@ -5532,7 +5532,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
assert!(!ty.has_escaping_bound_vars());
// First, store the "user substs" for later.
let hir_id = tcx.hir().node_to_hir_id(node_id);
self.write_user_type_annotation_from_substs(hir_id, def_id, substs, user_self_ty);
// Add all the obligations that are required, substituting and
@ -5566,10 +5565,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}
}
self.check_rustc_args_require_const(def_id, node_id, span);
self.check_rustc_args_require_const(def_id, hir_id, span);
debug!("instantiate_value_path: type of {:?} is {:?}",
node_id,
hir_id,
ty_substituted);
self.write_substs(hir_id, substs);
@ -5578,7 +5577,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
fn check_rustc_args_require_const(&self,
def_id: DefId,
node_id: ast::NodeId,
hir_id: hir::HirId,
span: Span) {
// We're only interested in functions tagged with
// #[rustc_args_required_const], so ignore anything that's not.
@ -5588,9 +5587,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
// 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 let Node::Expr(expr) = self.tcx.hir().get(self.tcx.hir().get_parent_node(node_id)) {
if let Node::Expr(expr) = self.tcx.hir().get_by_hir_id(
self.tcx.hir().get_parent_node_by_hir_id(hir_id))
{
if let ExprKind::Call(ref callee, ..) = expr.node {
if callee.id == node_id {
if callee.hir_id == hir_id {
return
}
}
@ -5618,7 +5619,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}
}
fn with_breakable_ctxt<F: FnOnce() -> R, R>(&self, id: ast::NodeId,
fn with_breakable_ctxt<F: FnOnce() -> R, R>(&self, id: hir::HirId,
ctxt: BreakableCtxt<'gcx, 'tcx>, f: F)
-> (BreakableCtxt<'gcx, 'tcx>, R) {
let index;
@ -5655,22 +5656,22 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}
/// Returns `true` if an expression is contained inside the LHS of an assignment expression.
fn expr_in_place(&self, mut expr_id: ast::NodeId) -> bool {
fn expr_in_place(&self, mut expr_id: hir::HirId) -> bool {
let mut contained_in_place = false;
while let hir::Node::Expr(parent_expr) =
self.tcx.hir().get(self.tcx.hir().get_parent_node(expr_id))
self.tcx.hir().get_by_hir_id(self.tcx.hir().get_parent_node_by_hir_id(expr_id))
{
match &parent_expr.node {
hir::ExprKind::Assign(lhs, ..) | hir::ExprKind::AssignOp(_, lhs, ..) => {
if lhs.id == expr_id {
if lhs.hir_id == expr_id {
contained_in_place = true;
break;
}
}
_ => (),
}
expr_id = parent_expr.id;
expr_id = parent_expr.hir_id;
}
contained_in_place

View File

@ -51,8 +51,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
{
let tcx = self.tcx;
debug!("check_binop(expr.id={}, expr={:?}, op={:?}, lhs_expr={:?}, rhs_expr={:?})",
expr.id,
debug!("check_binop(expr.hir_id={}, expr={:?}, op={:?}, lhs_expr={:?}, rhs_expr={:?})",
expr.hir_id,
expr,
op,
lhs_expr,
@ -150,8 +150,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
is_assign: IsAssign)
-> (Ty<'tcx>, Ty<'tcx>, Ty<'tcx>)
{
debug!("check_overloaded_binop(expr.id={}, op={:?}, is_assign={:?})",
expr.id,
debug!("check_overloaded_binop(expr.hir_id={}, op={:?}, is_assign={:?})",
expr.hir_id,
op,
is_assign);

View File

@ -90,7 +90,6 @@ use rustc_data_structures::sync::Lrc;
use std::mem;
use std::ops::Deref;
use std::rc::Rc;
use syntax::ast;
use syntax_pos::Span;
// a variation on try that just returns unit
@ -163,7 +162,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
/// rest of type check and because sometimes we need type
/// inference to have completed before we can determine which
/// constraints to add.
pub fn regionck_fn(&self, fn_id: ast::NodeId, body: &'gcx hir::Body) {
pub fn regionck_fn(&self, fn_id: hir::HirId, body: &'gcx hir::Body) {
debug!("regionck_fn(id={})", fn_id);
let subject = self.tcx.hir().body_owner_def_id(body.id());
let hir_id = body.value.hir_id;
@ -176,9 +175,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
);
if self.err_count_since_creation() == 0 {
let fn_hir_id = self.tcx.hir().node_to_hir_id(fn_id);
// regionck assumes typeck succeeded
rcx.visit_fn_body(fn_hir_id, body, self.tcx.hir().span_by_hir_id(fn_hir_id));
rcx.visit_fn_body(fn_id, body, self.tcx.hir().span_by_hir_id(fn_id));
}
rcx.resolve_regions_and_report_errors(SuppressRegionErrors::when_nll_is_enabled(self.tcx));
@ -696,8 +694,8 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx> {
hir::ExprKind::Ret(Some(ref ret_expr)) => {
let call_site_scope = self.call_site_scope;
debug!(
"visit_expr ExprKind::Ret ret_expr.id {} call_site_scope: {:?}",
ret_expr.id, call_site_scope
"visit_expr ExprKind::Ret ret_expr.hir_id {} call_site_scope: {:?}",
ret_expr.hir_id, call_site_scope
);
let call_site_region = self.tcx.mk_region(ty::ReScope(call_site_scope.unwrap()));
self.type_of_node_must_outlive(

View File

@ -67,7 +67,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for InferBorrowKindVisitor<'a, 'gcx, 'tcx> {
let body = self.fcx.tcx.hir().body(body_id);
self.visit_body(body);
self.fcx
.analyze_closure(expr.id, expr.hir_id, expr.span, body, cc);
.analyze_closure(expr.hir_id, expr.span, body, cc);
}
intravisit::walk_expr(self, expr);
@ -77,7 +77,6 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for InferBorrowKindVisitor<'a, 'gcx, 'tcx> {
impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
fn analyze_closure(
&self,
closure_node_id: ast::NodeId,
closure_hir_id: hir::HirId,
span: Span,
body: &hir::Body,
@ -89,7 +88,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
debug!(
"analyze_closure(id={:?}, body.id={:?})",
closure_node_id,
closure_hir_id,
body.id()
);
@ -105,7 +104,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
span_bug!(
span,
"type of closure expr {:?} is not a closure {:?}",
closure_node_id,
closure_hir_id,
t
);
}
@ -121,6 +120,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
None
};
let closure_node_id = self.tcx.hir().hir_to_node_id(closure_hir_id);
self.tcx.with_freevars(closure_node_id, |freevars| {
let mut freevar_list: Vec<ty::UpvarId> = Vec::with_capacity(freevars.len());
for freevar in freevars {
@ -582,7 +583,7 @@ impl<'a, 'gcx, 'tcx> InferBorrowKind<'a, 'gcx, 'tcx> {
impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'gcx, 'tcx> {
fn consume(
&mut self,
_consume_id: ast::NodeId,
_consume_id: hir::HirId,
_consume_span: Span,
cmt: &mc::cmt_<'tcx>,
mode: euv::ConsumeMode,
@ -611,7 +612,7 @@ impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'gcx, 'tcx> {
fn borrow(
&mut self,
borrow_id: ast::NodeId,
borrow_id: hir::HirId,
_borrow_span: Span,
cmt: &mc::cmt_<'tcx>,
_loan_region: ty::Region<'tcx>,
@ -638,7 +639,7 @@ impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'gcx, 'tcx> {
fn mutate(
&mut self,
_assignment_id: ast::NodeId,
_assignment_id: hir::HirId,
_assignment_span: Span,
assignee_cmt: &mc::cmt_<'tcx>,
_mode: euv::MutateMode,

View File

@ -243,11 +243,11 @@ impl<'cx, 'gcx, 'tcx> Visitor<'gcx> for WritebackCx<'cx, 'gcx, 'tcx> {
}
hir::ExprKind::Struct(_, ref fields, _) => {
for field in fields {
self.visit_field_id(field.id);
self.visit_field_id(field.hir_id);
}
}
hir::ExprKind::Field(..) => {
self.visit_field_id(e.id);
self.visit_field_id(e.hir_id);
}
_ => {}
}
@ -273,7 +273,7 @@ impl<'cx, 'gcx, 'tcx> Visitor<'gcx> for WritebackCx<'cx, 'gcx, 'tcx> {
}
hir::PatKind::Struct(_, ref fields, _) => {
for field in fields {
self.visit_field_id(field.node.id);
self.visit_field_id(field.node.hir_id);
}
}
_ => {}
@ -590,8 +590,7 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
}
}
fn visit_field_id(&mut self, node_id: ast::NodeId) {
let hir_id = self.tcx().hir().node_to_hir_id(node_id);
fn visit_field_id(&mut self, hir_id: hir::HirId) {
if let Some(index) = self.fcx
.tables
.borrow_mut()

View File

@ -129,12 +129,12 @@ impl<'a, 'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'a, 'tcx> {
hir::GenericParamKind::Type {
default: Some(_), ..
} => {
let def_id = self.tcx.hir().local_def_id(param.id);
let def_id = self.tcx.hir().local_def_id_from_hir_id(param.hir_id);
self.tcx.type_of(def_id);
}
hir::GenericParamKind::Type { .. } => {}
hir::GenericParamKind::Const { .. } => {
let def_id = self.tcx.hir().local_def_id(param.id);
let def_id = self.tcx.hir().local_def_id_from_hir_id(param.hir_id);
self.tcx.type_of(def_id);
}
}
@ -144,7 +144,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'a, 'tcx> {
fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
if let hir::ExprKind::Closure(..) = expr.node {
let def_id = self.tcx.hir().local_def_id(expr.id);
let def_id = self.tcx.hir().local_def_id_from_hir_id(expr.hir_id);
self.tcx.generics_of(def_id);
self.tcx.type_of(def_id);
}
@ -322,9 +322,10 @@ fn type_param_predicates<'a, 'tcx>(
};
let icx = ItemCtxt::new(tcx, item_def_id);
let param_hir_id = tcx.hir().node_to_hir_id(param_id);
Lrc::make_mut(&mut result)
.predicates
.extend(icx.type_parameter_bounds_in_generics(ast_generics, param_id, ty,
.extend(icx.type_parameter_bounds_in_generics(ast_generics, param_hir_id, ty,
OnlySelfBounds(true)));
result
}
@ -337,7 +338,7 @@ impl<'a, 'tcx> ItemCtxt<'a, 'tcx> {
fn type_parameter_bounds_in_generics(
&self,
ast_generics: &hir::Generics,
param_id: ast::NodeId,
param_id: hir::HirId,
ty: Ty<'tcx>,
only_self_bounds: OnlySelfBounds,
) -> Vec<(ty::Predicate<'tcx>, Span)> {
@ -345,7 +346,7 @@ impl<'a, 'tcx> ItemCtxt<'a, 'tcx> {
.params
.iter()
.filter_map(|param| match param.kind {
GenericParamKind::Type { .. } if param.id == param_id => Some(&param.bounds),
GenericParamKind::Type { .. } if param.hir_id == param_id => Some(&param.bounds),
_ => None,
})
.flat_map(|bounds| bounds.iter())
@ -382,12 +383,12 @@ impl<'a, 'tcx> ItemCtxt<'a, 'tcx> {
fn is_param<'a, 'tcx>(
tcx: TyCtxt<'a, 'tcx, 'tcx>,
ast_ty: &hir::Ty,
param_id: ast::NodeId,
param_id: hir::HirId,
) -> bool {
if let hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) = ast_ty.node {
match path.def {
Def::SelfTy(Some(def_id), None) | Def::TyParam(def_id) => {
def_id == tcx.hir().local_def_id(param_id)
def_id == tcx.hir().local_def_id_from_hir_id(param_id)
}
_ => false,
}
@ -721,7 +722,7 @@ fn super_predicates_of<'a, 'tcx>(
// as one of its "superpredicates".
let is_trait_alias = tcx.is_trait_alias(trait_def_id);
let superbounds2 = icx.type_parameter_bounds_in_generics(
generics, item.id, self_param_ty, OnlySelfBounds(!is_trait_alias));
generics, item.hir_id, self_param_ty, OnlySelfBounds(!is_trait_alias));
// Combine the two lists to form the complete set of superbounds:
let superbounds: Vec<_> = superbounds1.into_iter().chain(superbounds2).collect();
@ -987,7 +988,7 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty
.map(|(i, param)| ty::GenericParamDef {
name: param.name.ident().as_interned_str(),
index: own_start + i as u32,
def_id: tcx.hir().local_def_id(param.id),
def_id: tcx.hir().local_def_id_from_hir_id(param.hir_id),
pure_wrt_drop: param.pure_wrt_drop,
kind: ty::GenericParamDefKind::Lifetime,
}),
@ -1018,9 +1019,9 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty
if !allow_defaults && default.is_some() {
if !tcx.features().default_type_parameter_fallback {
tcx.lint_node(
tcx.lint_hir(
lint::builtin::INVALID_TYPE_PARAM_DEFAULT,
param.id,
param.hir_id,
param.span,
&format!(
"defaults for type parameters are only allowed in \
@ -1033,7 +1034,7 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty
let ty_param = ty::GenericParamDef {
index: type_start + i as u32,
name: param.name.ident().as_interned_str(),
def_id: tcx.hir().local_def_id(param.id),
def_id: tcx.hir().local_def_id_from_hir_id(param.hir_id),
pure_wrt_drop: param.pure_wrt_drop,
kind: ty::GenericParamDefKind::Type {
has_default: default.is_some(),
@ -1704,8 +1705,7 @@ fn early_bound_lifetimes_from_generics<'a, 'tcx>(
.iter()
.filter(move |param| match param.kind {
GenericParamKind::Lifetime { .. } => {
let hir_id = tcx.hir().node_to_hir_id(param.id);
!tcx.is_late_bound(hir_id)
!tcx.is_late_bound(param.hir_id)
}
_ => false,
})
@ -1942,7 +1942,7 @@ fn explicit_predicates_of<'a, 'tcx>(
let mut index = parent_count + has_own_self as u32;
for param in early_bound_lifetimes_from_generics(tcx, ast_generics) {
let region = tcx.mk_region(ty::ReEarlyBound(ty::EarlyBoundRegion {
def_id: tcx.hir().local_def_id(param.id),
def_id: tcx.hir().local_def_id_from_hir_id(param.hir_id),
index,
name: param.name.ident().as_interned_str(),
}));
@ -2224,7 +2224,7 @@ fn compute_sig_of_foreign_fn_decl<'a, 'tcx>(
&format!(
"use of SIMD type `{}` in FFI is highly experimental and \
may result in invalid code",
tcx.hir().node_to_pretty_string(ast_ty.id)
tcx.hir().hir_to_pretty_string(ast_ty.hir_id)
),
)
.help("add #![feature(simd_ffi)] to the crate attributes to enable")

View File

@ -371,8 +371,8 @@ pub fn hir_ty_to_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, hir_ty: &hir::Ty) ->
// In case there are any projections etc, find the "environment"
// def-id that will be used to determine the traits/predicates in
// scope. This is derived from the enclosing item-like thing.
let env_node_id = tcx.hir().get_parent(hir_ty.id);
let env_def_id = tcx.hir().local_def_id(env_node_id);
let env_node_id = tcx.hir().get_parent_item(hir_ty.hir_id);
let env_def_id = tcx.hir().local_def_id_from_hir_id(env_node_id);
let item_cx = self::collect::ItemCtxt::new(tcx, env_def_id);
astconv::AstConv::ast_ty_to_ty(&item_cx, hir_ty)

View File

@ -1221,7 +1221,7 @@ impl Lifetime {
impl Clean<Lifetime> for hir::Lifetime {
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Lifetime {
if self.id != ast::DUMMY_NODE_ID {
if self.hir_id != hir::DUMMY_HIR_ID {
let def = cx.tcx.named_region(self.hir_id);
match def {
Some(rl::Region::EarlyBound(_, node_id, _)) |
@ -1513,7 +1513,7 @@ impl Clean<GenericParamDef> for hir::GenericParam {
}
hir::GenericParamKind::Type { ref default, synthetic } => {
(self.name.ident().name.clean(cx), GenericParamDefKind::Type {
did: cx.tcx.hir().local_def_id(self.id),
did: cx.tcx.hir().local_def_id_from_hir_id(self.hir_id),
bounds: self.bounds.clean(cx),
default: default.clean(cx),
synthetic: synthetic,
@ -1521,7 +1521,7 @@ impl Clean<GenericParamDef> for hir::GenericParam {
}
hir::GenericParamKind::Const { ref ty } => {
(self.name.ident().name.clean(cx), GenericParamDefKind::Const {
did: cx.tcx.hir().local_def_id(self.id),
did: cx.tcx.hir().local_def_id_from_hir_id(self.hir_id),
ty: ty.clean(cx),
})
}
@ -1988,7 +1988,7 @@ impl Clean<bool> for hir::IsAuto {
impl Clean<Type> for hir::TraitRef {
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Type {
resolve_type(cx, self.path.clean(cx), self.ref_id)
resolve_type(cx, self.path.clean(cx), self.hir_ref_id)
}
}
@ -2599,7 +2599,7 @@ impl Clean<Type> for hir::Ty {
if let Some(lt) = lifetime.cloned() {
if !lt.is_elided() {
let lt_def_id =
cx.tcx.hir().local_def_id(param.id);
cx.tcx.hir().local_def_id_from_hir_id(param.hir_id);
lt_substs.insert(lt_def_id, lt.clean(cx));
}
}
@ -2607,7 +2607,8 @@ impl Clean<Type> for hir::Ty {
}
hir::GenericParamKind::Type { ref default, .. } => {
let ty_param_def =
Def::TyParam(cx.tcx.hir().local_def_id(param.id));
Def::TyParam(
cx.tcx.hir().local_def_id_from_hir_id(param.hir_id));
let mut j = 0;
let type_ = generic_args.args.iter().find_map(|arg| {
match arg {
@ -2631,7 +2632,8 @@ impl Clean<Type> for hir::Ty {
}
hir::GenericParamKind::Const { .. } => {
let const_param_def =
Def::ConstParam(cx.tcx.hir().local_def_id(param.id));
Def::ConstParam(
cx.tcx.hir().local_def_id_from_hir_id(param.hir_id));
let mut j = 0;
let const_ = generic_args.args.iter().find_map(|arg| {
match arg {
@ -2656,7 +2658,7 @@ impl Clean<Type> for hir::Ty {
});
return cx.enter_alias(ty_substs, lt_substs, const_substs, || ty.clean(cx));
}
resolve_type(cx, path.clean(cx), self.id)
resolve_type(cx, path.clean(cx), self.hir_id)
}
TyKind::Path(hir::QPath::Resolved(Some(ref qself), ref p)) => {
let mut segments: Vec<_> = p.segments.clone().into();
@ -2669,7 +2671,7 @@ impl Clean<Type> for hir::Ty {
Type::QPath {
name: p.segments.last().expect("segments were empty").ident.name.clean(cx),
self_type: box qself.clean(cx),
trait_: box resolve_type(cx, trait_path.clean(cx), self.id)
trait_: box resolve_type(cx, trait_path.clean(cx), self.hir_id)
}
}
TyKind::Path(hir::QPath::TypeRelative(ref qself, ref segment)) => {
@ -2686,7 +2688,7 @@ impl Clean<Type> for hir::Ty {
Type::QPath {
name: segment.ident.name.clean(cx),
self_type: box qself.clean(cx),
trait_: box resolve_type(cx, trait_path.clean(cx), self.id)
trait_: box resolve_type(cx, trait_path.clean(cx), self.hir_id)
}
}
TyKind::TraitObject(ref bounds, ref lifetime) => {
@ -3909,8 +3911,8 @@ fn print_const_expr(cx: &DocContext<'_, '_, '_>, body: hir::BodyId) -> String {
/// Given a type Path, resolve it to a Type using the TyCtxt
fn resolve_type(cx: &DocContext<'_, '_, '_>,
path: Path,
id: ast::NodeId) -> Type {
if id == ast::DUMMY_NODE_ID {
id: hir::HirId) -> Type {
if id == hir::DUMMY_HIR_ID {
debug!("resolve_type({:?})", path);
} else {
debug!("resolve_type({:?},{:?})", path, id);

View File

@ -193,7 +193,6 @@ impl<'a, 'tcx, 'rcx> DocContext<'a, 'tcx, 'rcx> {
};
hir::Ty {
id: ast::DUMMY_NODE_ID,
node: hir::TyKind::Path(hir::QPath::Resolved(None, P(new_path))),
span: DUMMY_SP,
hir_id: hir::DUMMY_HIR_ID,
@ -213,7 +212,6 @@ impl<'a, 'tcx, 'rcx> DocContext<'a, 'tcx, 'rcx> {
};
args.push(hir::GenericArg::Lifetime(hir::Lifetime {
id: ast::DUMMY_NODE_ID,
hir_id: hir::DUMMY_HIR_ID,
span: DUMMY_SP,
name: hir::LifetimeName::Param(name),
@ -235,7 +233,6 @@ impl<'a, 'tcx, 'rcx> DocContext<'a, 'tcx, 'rcx> {
pub fn ty_param_to_ty(&self, param: ty::GenericParamDef) -> hir::Ty {
debug!("ty_param_to_ty({:?}) {:?}", param, param.def_id);
hir::Ty {
id: ast::DUMMY_NODE_ID,
node: hir::TyKind::Path(hir::QPath::Resolved(
None,
P(hir::Path {

View File

@ -868,7 +868,7 @@ impl<'a, 'hir> intravisit::Visitor<'hir> for HirCollector<'a, 'hir> {
fn visit_item(&mut self, item: &'hir hir::Item) {
let name = if let hir::ItemKind::Impl(.., ref ty, _) = item.node {
self.map.node_to_pretty_string(ty.id)
self.map.hir_to_pretty_string(ty.hir_id)
} else {
item.ident.to_string()
};

View File

@ -66,13 +66,13 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
}
}
fn stability(&self, id: ast::NodeId) -> Option<attr::Stability> {
self.cx.tcx.hir().opt_local_def_id(id)
fn stability(&self, id: hir::HirId) -> Option<attr::Stability> {
self.cx.tcx.hir().opt_local_def_id_from_hir_id(id)
.and_then(|def_id| self.cx.tcx.lookup_stability(def_id)).cloned()
}
fn deprecation(&self, id: ast::NodeId) -> Option<attr::Deprecation> {
self.cx.tcx.hir().opt_local_def_id(id)
fn deprecation(&self, id: hir::HirId) -> Option<attr::Deprecation> {
self.cx.tcx.hir().opt_local_def_id_from_hir_id(id)
.and_then(|def_id| self.cx.tcx.lookup_deprecation(def_id))
}
@ -83,7 +83,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
krate.attrs.clone(),
Spanned { span: syntax_pos::DUMMY_SP,
node: hir::VisibilityKind::Public },
ast::CRATE_NODE_ID,
hir::CRATE_HIR_ID,
&krate.module,
None);
// Attach the crate's exported macros to the top-level module:
@ -105,8 +105,8 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
struct_type,
name,
vis: item.vis.clone(),
stab: self.stability(item.id),
depr: self.deprecation(item.id),
stab: self.stability(item.hir_id),
depr: self.deprecation(item.hir_id),
attrs: item.attrs.clone(),
generics: generics.clone(),
fields: sd.fields().iter().cloned().collect(),
@ -124,8 +124,8 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
struct_type,
name,
vis: item.vis.clone(),
stab: self.stability(item.id),
depr: self.deprecation(item.id),
stab: self.stability(item.hir_id),
depr: self.deprecation(item.hir_id),
attrs: item.attrs.clone(),
generics: generics.clone(),
fields: sd.fields().iter().cloned().collect(),
@ -142,14 +142,14 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
variants: def.variants.iter().map(|v| Variant {
name: v.node.ident.name,
attrs: v.node.attrs.clone(),
stab: self.stability(v.node.data.id()),
depr: self.deprecation(v.node.data.id()),
stab: self.stability(v.node.data.hir_id()),
depr: self.deprecation(v.node.data.hir_id()),
def: v.node.data.clone(),
whence: v.span,
}).collect(),
vis: it.vis.clone(),
stab: self.stability(it.id),
depr: self.deprecation(it.id),
stab: self.stability(it.hir_id),
depr: self.deprecation(it.hir_id),
generics: params.clone(),
attrs: it.attrs.clone(),
id: it.id,
@ -207,16 +207,16 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
helpers,
attrs: item.attrs.clone(),
whence: item.span,
stab: self.stability(item.id),
depr: self.deprecation(item.id),
stab: self.stability(item.hir_id),
depr: self.deprecation(item.hir_id),
});
}
None => {
om.fns.push(Function {
id: item.id,
vis: item.vis.clone(),
stab: self.stability(item.id),
depr: self.deprecation(item.id),
stab: self.stability(item.hir_id),
depr: self.deprecation(item.hir_id),
attrs: item.attrs.clone(),
decl: fd.clone(),
name,
@ -230,7 +230,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
}
pub fn visit_mod_contents(&mut self, span: Span, attrs: hir::HirVec<ast::Attribute>,
vis: hir::Visibility, id: ast::NodeId,
vis: hir::Visibility, id: hir::HirId,
m: &hir::Mod,
name: Option<ast::Name>) -> Module {
let mut om = Module::new(name);
@ -240,7 +240,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
om.vis = vis.clone();
om.stab = self.stability(id);
om.depr = self.deprecation(id);
om.id = id;
om.id = self.cx.tcx.hir().hir_to_node_id(id);
// Keep track of if there were any private modules in the path.
let orig_inside_public_path = self.inside_public_path;
self.inside_public_path &= vis.node.is_pub();
@ -460,7 +460,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
om.mods.push(self.visit_mod_contents(item.span,
item.attrs.clone(),
item.vis.clone(),
item.id,
item.hir_id,
m,
Some(ident.name)));
},
@ -481,8 +481,8 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
attrs: item.attrs.clone(),
whence: item.span,
vis: item.vis.clone(),
stab: self.stability(item.id),
depr: self.deprecation(item.id),
stab: self.stability(item.hir_id),
depr: self.deprecation(item.hir_id),
};
om.typedefs.push(t);
},
@ -494,8 +494,8 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
attrs: item.attrs.clone(),
whence: item.span,
vis: item.vis.clone(),
stab: self.stability(item.id),
depr: self.deprecation(item.id),
stab: self.stability(item.hir_id),
depr: self.deprecation(item.hir_id),
};
om.existentials.push(t);
},
@ -509,8 +509,8 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
attrs: item.attrs.clone(),
whence: item.span,
vis: item.vis.clone(),
stab: self.stability(item.id),
depr: self.deprecation(item.id),
stab: self.stability(item.hir_id),
depr: self.deprecation(item.hir_id),
};
om.statics.push(s);
},
@ -523,8 +523,8 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
attrs: item.attrs.clone(),
whence: item.span,
vis: item.vis.clone(),
stab: self.stability(item.id),
depr: self.deprecation(item.id),
stab: self.stability(item.hir_id),
depr: self.deprecation(item.hir_id),
};
om.constants.push(s);
},
@ -543,8 +543,8 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
attrs: item.attrs.clone(),
whence: item.span,
vis: item.vis.clone(),
stab: self.stability(item.id),
depr: self.deprecation(item.id),
stab: self.stability(item.hir_id),
depr: self.deprecation(item.hir_id),
};
om.traits.push(t);
},
@ -557,8 +557,8 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
attrs: item.attrs.clone(),
whence: item.span,
vis: item.vis.clone(),
stab: self.stability(item.id),
depr: self.deprecation(item.id),
stab: self.stability(item.hir_id),
depr: self.deprecation(item.hir_id),
};
om.trait_aliases.push(t);
},
@ -588,8 +588,8 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
id: item.id,
whence: item.span,
vis: item.vis.clone(),
stab: self.stability(item.id),
depr: self.deprecation(item.id),
stab: self.stability(item.hir_id),
depr: self.deprecation(item.hir_id),
};
om.impls.push(i);
}
@ -609,13 +609,14 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
let matchers = tts.chunks(4).map(|arm| arm[0].span()).collect();
Macro {
def_id: self.cx.tcx.hir().local_def_id(def.id),
def_id: self.cx.tcx.hir().local_def_id_from_hir_id(def.hir_id),
attrs: def.attrs.clone(),
name: renamed.unwrap_or(def.name),
whence: def.span,
matchers,
stab: self.stability(def.id),
depr: self.deprecation(def.id),
stab: self.stability(def.hir_id),
depr: self.deprecation(def.hir_id),
imported_from: None,
}
}

@ -1 +1 @@
Subproject commit 1fac38088609747627b07807945224cf1ea642ca
Subproject commit 7bc2e1d60d23a2f6a31d7a04d40171372d80b5b3