mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-22 10:05:06 +03:00
Auto merge of #58836 - ljedrz:begone_NodeId, r=Zoxc
Remove NodeId from even more HIR nodes The next iteration of HirIdification (#57578). Removes `NodeId` from: - [x] `StructField` - [x] `ForeignItem` - [x] `Item` - [x] `Pat` - [x] `FieldPat` - [x] `VariantData` - [x] `ImplItemId` (replaces it with `HirId`) - [x] `TraitItemId` (replaces it with `HirId`)
This commit is contained in:
@@ -94,7 +94,7 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
|
||||
/// Checks any attribute.
|
||||
fn check_attributes(&self, item: &hir::Item, target: Target) {
|
||||
if target == Target::Fn || target == Target::Const {
|
||||
self.tcx.codegen_fn_attrs(self.tcx.hir().local_def_id(item.id));
|
||||
self.tcx.codegen_fn_attrs(self.tcx.hir().local_def_id_from_hir_id(item.hir_id));
|
||||
} else if let Some(a) = item.attrs.iter().find(|a| a.check_name("target_feature")) {
|
||||
self.tcx.sess.struct_span_err(a.span, "attribute should be applied to a function")
|
||||
.span_label(item.span, "not a function")
|
||||
|
||||
@@ -469,8 +469,8 @@ fn visit_item(&mut self, item: &'lcx Item) {
|
||||
|
||||
fn visit_trait_item(&mut self, item: &'lcx TraitItem) {
|
||||
self.lctx.with_hir_id_owner(item.id, |lctx| {
|
||||
let id = hir::TraitItemId { node_id: item.id };
|
||||
let hir_item = lctx.lower_trait_item(item);
|
||||
let id = hir::TraitItemId { hir_id: hir_item.hir_id };
|
||||
lctx.trait_items.insert(id, hir_item);
|
||||
lctx.modules.get_mut(&lctx.current_module).unwrap().trait_items.insert(id);
|
||||
});
|
||||
@@ -480,8 +480,8 @@ fn visit_trait_item(&mut self, item: &'lcx TraitItem) {
|
||||
|
||||
fn visit_impl_item(&mut self, item: &'lcx ImplItem) {
|
||||
self.lctx.with_hir_id_owner(item.id, |lctx| {
|
||||
let id = hir::ImplItemId { node_id: item.id };
|
||||
let hir_item = lctx.lower_impl_item(item);
|
||||
let id = hir::ImplItemId { hir_id: hir_item.hir_id };
|
||||
lctx.impl_items.insert(id, hir_item);
|
||||
lctx.modules.get_mut(&lctx.current_module).unwrap().impl_items.insert(id);
|
||||
});
|
||||
@@ -1414,7 +1414,6 @@ fn lower_existential_impl_trait(
|
||||
|
||||
trace!("exist ty def index: {:#?}", exist_ty_def_index);
|
||||
let exist_ty_item = hir::Item {
|
||||
id: exist_ty_id.node_id,
|
||||
hir_id: exist_ty_id.hir_id,
|
||||
ident: keywords::Invalid.ident(),
|
||||
attrs: Default::default(),
|
||||
@@ -2675,7 +2674,7 @@ fn lower_where_predicate(&mut self, pred: &WherePredicate) -> hir::WherePredicat
|
||||
fn lower_variant_data(&mut self, vdata: &VariantData) -> hir::VariantData {
|
||||
match *vdata {
|
||||
VariantData::Struct(ref fields, id) => {
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(id);
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(id);
|
||||
|
||||
hir::VariantData::Struct(
|
||||
fields
|
||||
@@ -2683,12 +2682,11 @@ fn lower_variant_data(&mut self, vdata: &VariantData) -> hir::VariantData {
|
||||
.enumerate()
|
||||
.map(|f| self.lower_struct_field(f))
|
||||
.collect(),
|
||||
node_id,
|
||||
hir_id,
|
||||
)
|
||||
},
|
||||
VariantData::Tuple(ref fields, id) => {
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(id);
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(id);
|
||||
|
||||
hir::VariantData::Tuple(
|
||||
fields
|
||||
@@ -2696,14 +2694,13 @@ fn lower_variant_data(&mut self, vdata: &VariantData) -> hir::VariantData {
|
||||
.enumerate()
|
||||
.map(|f| self.lower_struct_field(f))
|
||||
.collect(),
|
||||
node_id,
|
||||
hir_id,
|
||||
)
|
||||
},
|
||||
VariantData::Unit(id) => {
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(id);
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(id);
|
||||
|
||||
hir::VariantData::Unit(node_id, hir_id)
|
||||
hir::VariantData::Unit(hir_id)
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -2743,11 +2740,10 @@ fn lower_poly_trait_ref(
|
||||
}
|
||||
|
||||
fn lower_struct_field(&mut self, (index, f): (usize, &StructField)) -> hir::StructField {
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(f.id);
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(f.id);
|
||||
|
||||
hir::StructField {
|
||||
span: f.span,
|
||||
id: node_id,
|
||||
hir_id,
|
||||
ident: match f.ident {
|
||||
Some(ident) => ident,
|
||||
@@ -3129,7 +3125,6 @@ fn lower_use_tree(
|
||||
this.insert_item(
|
||||
new_id.node_id,
|
||||
hir::Item {
|
||||
id: new_id.node_id,
|
||||
hir_id: new_id.hir_id,
|
||||
ident,
|
||||
attrs: attrs.clone(),
|
||||
@@ -3235,7 +3230,6 @@ fn lower_use_tree(
|
||||
this.insert_item(
|
||||
new_id,
|
||||
hir::Item {
|
||||
id: new_id,
|
||||
hir_id: new_hir_id,
|
||||
ident,
|
||||
attrs: attrs.clone(),
|
||||
@@ -3369,7 +3363,7 @@ fn lower_trait_item_ref(&mut self, i: &TraitItem) -> hir::TraitItemRef {
|
||||
TraitItemKind::Macro(..) => unimplemented!(),
|
||||
};
|
||||
hir::TraitItemRef {
|
||||
id: hir::TraitItemId { node_id: i.id },
|
||||
id: hir::TraitItemId { hir_id: self.lower_node_id(i.id).hir_id },
|
||||
ident: i.ident,
|
||||
span: i.span,
|
||||
defaultness: self.lower_defaultness(Defaultness::Default, has_default),
|
||||
@@ -3433,7 +3427,7 @@ fn lower_impl_item(&mut self, i: &ImplItem) -> hir::ImplItem {
|
||||
|
||||
fn lower_impl_item_ref(&mut self, i: &ImplItem) -> hir::ImplItemRef {
|
||||
hir::ImplItemRef {
|
||||
id: hir::ImplItemId { node_id: i.id },
|
||||
id: hir::ImplItemId { hir_id: self.lower_node_id(i.id).hir_id },
|
||||
ident: i.ident,
|
||||
span: i.span,
|
||||
vis: self.lower_visibility(&i.vis, Some(i.id)),
|
||||
@@ -3535,10 +3529,9 @@ pub fn lower_item(&mut self, i: &Item) -> Option<hir::Item> {
|
||||
|
||||
let node = self.lower_item_kind(i.id, &mut ident, &attrs, &mut vis, &i.node);
|
||||
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(i.id);
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(i.id);
|
||||
|
||||
Some(hir::Item {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
ident,
|
||||
attrs,
|
||||
@@ -3552,7 +3545,6 @@ fn lower_foreign_item(&mut self, i: &ForeignItem) -> hir::ForeignItem {
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(i.id);
|
||||
let def_id = self.resolver.definitions().local_def_id(node_id);
|
||||
hir::ForeignItem {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
ident: i.ident,
|
||||
attrs: self.lower_attrs(&i.attrs),
|
||||
@@ -3746,12 +3738,11 @@ fn lower_pat(&mut self, p: &Pat) -> P<hir::Pat> {
|
||||
let fs = fields
|
||||
.iter()
|
||||
.map(|f| {
|
||||
let LoweredNodeId { node_id, hir_id } = self.next_id();
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.next_id();
|
||||
|
||||
Spanned {
|
||||
span: f.span,
|
||||
node: hir::FieldPat {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
ident: f.node.ident,
|
||||
pat: self.lower_pat(&f.node.pat),
|
||||
@@ -3783,9 +3774,8 @@ fn lower_pat(&mut self, p: &Pat) -> P<hir::Pat> {
|
||||
PatKind::Mac(_) => panic!("Shouldn't exist here"),
|
||||
};
|
||||
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(p.id);
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(p.id);
|
||||
P(hir::Pat {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
node,
|
||||
span: p.span,
|
||||
@@ -4359,7 +4349,7 @@ fn lower_expr(&mut self, e: &Expr) -> hir::Expr {
|
||||
let iter = self.str_to_ident("iter");
|
||||
|
||||
let next_ident = self.str_to_ident("__next");
|
||||
let next_pat = self.pat_ident_binding_mode(
|
||||
let (next_pat, next_pat_nid) = self.pat_ident_binding_mode(
|
||||
desugared_span,
|
||||
next_ident,
|
||||
hir::BindingAnnotation::Mutable,
|
||||
@@ -4368,9 +4358,9 @@ fn lower_expr(&mut self, e: &Expr) -> hir::Expr {
|
||||
// `::std::option::Option::Some(val) => next = val`
|
||||
let pat_arm = {
|
||||
let val_ident = self.str_to_ident("val");
|
||||
let val_pat = self.pat_ident(pat.span, val_ident);
|
||||
let val_expr = P(self.expr_ident(pat.span, val_ident, val_pat.id));
|
||||
let next_expr = P(self.expr_ident(pat.span, next_ident, next_pat.id));
|
||||
let (val_pat, val_pat_nid) = self.pat_ident(pat.span, val_ident);
|
||||
let val_expr = P(self.expr_ident(pat.span, val_ident, val_pat_nid));
|
||||
let next_expr = P(self.expr_ident(pat.span, next_ident, next_pat_nid));
|
||||
let assign = P(self.expr(
|
||||
pat.span,
|
||||
hir::ExprKind::Assign(next_expr, val_expr),
|
||||
@@ -4389,7 +4379,7 @@ fn lower_expr(&mut self, e: &Expr) -> hir::Expr {
|
||||
};
|
||||
|
||||
// `mut iter`
|
||||
let iter_pat = self.pat_ident_binding_mode(
|
||||
let (iter_pat, iter_pat_nid) = self.pat_ident_binding_mode(
|
||||
desugared_span,
|
||||
iter,
|
||||
hir::BindingAnnotation::Mutable
|
||||
@@ -4397,7 +4387,7 @@ fn lower_expr(&mut self, e: &Expr) -> hir::Expr {
|
||||
|
||||
// `match ::std::iter::Iterator::next(&mut iter) { ... }`
|
||||
let match_expr = {
|
||||
let iter = P(self.expr_ident(head_sp, iter, iter_pat.id));
|
||||
let iter = P(self.expr_ident(head_sp, iter, iter_pat_nid));
|
||||
let ref_mut_iter = self.expr_mut_addr_of(head_sp, iter);
|
||||
let next_path = &["iter", "Iterator", "next"];
|
||||
let next_path = P(self.expr_std_path(head_sp, next_path, None, ThinVec::new()));
|
||||
@@ -4421,7 +4411,7 @@ fn lower_expr(&mut self, e: &Expr) -> hir::Expr {
|
||||
span: head_sp,
|
||||
};
|
||||
|
||||
let next_expr = P(self.expr_ident(head_sp, next_ident, next_pat.id));
|
||||
let next_expr = P(self.expr_ident(head_sp, next_ident, next_pat_nid));
|
||||
|
||||
// `let mut __next`
|
||||
let next_let = self.stmt_let_pat(
|
||||
@@ -4548,11 +4538,11 @@ fn lower_expr(&mut self, e: &Expr) -> hir::Expr {
|
||||
// `Ok(val) => #[allow(unreachable_code)] val,`
|
||||
let ok_arm = {
|
||||
let val_ident = self.str_to_ident("val");
|
||||
let val_pat = self.pat_ident(e.span, val_ident);
|
||||
let (val_pat, val_pat_nid) = self.pat_ident(e.span, val_ident);
|
||||
let val_expr = P(self.expr_ident_with_attrs(
|
||||
e.span,
|
||||
val_ident,
|
||||
val_pat.id,
|
||||
val_pat_nid,
|
||||
ThinVec::from(attrs.clone()),
|
||||
));
|
||||
let ok_pat = self.pat_ok(e.span, val_pat);
|
||||
@@ -4564,12 +4554,12 @@ fn lower_expr(&mut self, e: &Expr) -> hir::Expr {
|
||||
// return Try::from_error(From::from(err)),`
|
||||
let err_arm = {
|
||||
let err_ident = self.str_to_ident("err");
|
||||
let err_local = self.pat_ident(e.span, err_ident);
|
||||
let (err_local, err_local_nid) = self.pat_ident(e.span, err_ident);
|
||||
let from_expr = {
|
||||
let path = &["convert", "From", "from"];
|
||||
let from = P(self.expr_std_path(
|
||||
e.span, path, None, ThinVec::new()));
|
||||
let err_expr = self.expr_ident(e.span, err_ident, err_local.id);
|
||||
let err_expr = self.expr_ident(e.span, err_ident, err_local_nid);
|
||||
|
||||
self.expr_call(e.span, from, hir_vec![err_expr])
|
||||
};
|
||||
@@ -4917,15 +4907,15 @@ fn stmt_let(
|
||||
ident: Ident,
|
||||
ex: P<hir::Expr>,
|
||||
) -> (hir::Stmt, NodeId) {
|
||||
let pat = if mutbl {
|
||||
let (pat, pat_nid) = if mutbl {
|
||||
self.pat_ident_binding_mode(sp, ident, hir::BindingAnnotation::Mutable)
|
||||
} else {
|
||||
self.pat_ident(sp, ident)
|
||||
};
|
||||
let pat_id = pat.id;
|
||||
|
||||
(
|
||||
self.stmt_let_pat(sp, Some(ex), pat, hir::LocalSource::Normal),
|
||||
pat_id,
|
||||
pat_nid,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -4983,7 +4973,7 @@ fn pat_std_enum(
|
||||
self.pat(span, pt)
|
||||
}
|
||||
|
||||
fn pat_ident(&mut self, span: Span, ident: Ident) -> P<hir::Pat> {
|
||||
fn pat_ident(&mut self, span: Span, ident: Ident) -> (P<hir::Pat>, NodeId) {
|
||||
self.pat_ident_binding_mode(span, ident, hir::BindingAnnotation::Unannotated)
|
||||
}
|
||||
|
||||
@@ -4992,15 +4982,17 @@ fn pat_ident_binding_mode(
|
||||
span: Span,
|
||||
ident: Ident,
|
||||
bm: hir::BindingAnnotation,
|
||||
) -> P<hir::Pat> {
|
||||
) -> (P<hir::Pat>, NodeId) {
|
||||
let LoweredNodeId { node_id, hir_id } = self.next_id();
|
||||
|
||||
P(hir::Pat {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
node: hir::PatKind::Binding(bm, node_id, hir_id, ident.with_span_pos(span), None),
|
||||
span,
|
||||
})
|
||||
(
|
||||
P(hir::Pat {
|
||||
hir_id,
|
||||
node: hir::PatKind::Binding(bm, node_id, hir_id, ident.with_span_pos(span), None),
|
||||
span,
|
||||
}),
|
||||
node_id
|
||||
)
|
||||
}
|
||||
|
||||
fn pat_wild(&mut self, span: Span) -> P<hir::Pat> {
|
||||
@@ -5008,9 +5000,8 @@ fn pat_wild(&mut self, span: Span) -> P<hir::Pat> {
|
||||
}
|
||||
|
||||
fn pat(&mut self, span: Span, pat: hir::PatKind) -> P<hir::Pat> {
|
||||
let LoweredNodeId { node_id, hir_id } = self.next_id();
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.next_id();
|
||||
P(hir::Pat {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
node: pat,
|
||||
span,
|
||||
|
||||
@@ -356,7 +356,7 @@ fn visit_nested_body(&mut self, id: BodyId) {
|
||||
fn visit_item(&mut self, i: &'hir Item) {
|
||||
debug!("visit_item: {:?}", i);
|
||||
debug_assert_eq!(i.hir_id.owner,
|
||||
self.definitions.opt_def_index(i.id).unwrap());
|
||||
self.definitions.opt_def_index(self.hir_to_node_id[&i.hir_id]).unwrap());
|
||||
self.with_dep_node_owner(i.hir_id.owner, i, |this| {
|
||||
this.insert(i.span, i.hir_id, Node::Item(i));
|
||||
this.with_parent(i.hir_id, |this| {
|
||||
|
||||
@@ -319,7 +319,7 @@ pub fn describe_def(&self, node_id: NodeId) -> Option<Def> {
|
||||
|
||||
match node {
|
||||
Node::Item(item) => {
|
||||
let def_id = || self.local_def_id(item.id);
|
||||
let def_id = || self.local_def_id_from_hir_id(item.hir_id);
|
||||
|
||||
match item.node {
|
||||
ItemKind::Static(_, m, _) => Some(Def::Static(def_id(), m == MutMutable)),
|
||||
@@ -341,7 +341,7 @@ pub fn describe_def(&self, node_id: NodeId) -> Option<Def> {
|
||||
}
|
||||
}
|
||||
Node::ForeignItem(item) => {
|
||||
let def_id = self.local_def_id(item.id);
|
||||
let def_id = self.local_def_id_from_hir_id(item.hir_id);
|
||||
match item.node {
|
||||
ForeignItemKind::Fn(..) => Some(Def::Fn(def_id)),
|
||||
ForeignItemKind::Static(_, m) => Some(Def::Static(def_id, m)),
|
||||
@@ -366,11 +366,11 @@ pub fn describe_def(&self, node_id: NodeId) -> Option<Def> {
|
||||
}
|
||||
}
|
||||
Node::Variant(variant) => {
|
||||
let def_id = self.local_def_id(variant.node.data.id());
|
||||
let def_id = self.local_def_id_from_hir_id(variant.node.data.hir_id());
|
||||
Some(Def::Variant(def_id))
|
||||
}
|
||||
Node::StructCtor(variant) => {
|
||||
let def_id = self.local_def_id(variant.id());
|
||||
let def_id = self.local_def_id_from_hir_id(variant.hir_id());
|
||||
Some(Def::StructCtor(def_id, def::CtorKind::from_hir(variant)))
|
||||
}
|
||||
Node::AnonConst(_) |
|
||||
@@ -427,7 +427,7 @@ pub fn krate(&self) -> &'hir Crate {
|
||||
}
|
||||
|
||||
pub fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem {
|
||||
self.read(id.node_id);
|
||||
self.read_by_hir_id(id.hir_id);
|
||||
|
||||
// N.B., intentionally bypass `self.forest.krate()` so that we
|
||||
// do not trigger a read of the whole krate here
|
||||
@@ -435,7 +435,7 @@ pub fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem {
|
||||
}
|
||||
|
||||
pub fn impl_item(&self, id: ImplItemId) -> &'hir ImplItem {
|
||||
self.read(id.node_id);
|
||||
self.read_by_hir_id(id.hir_id);
|
||||
|
||||
// N.B., intentionally bypass `self.forest.krate()` so that we
|
||||
// do not trigger a read of the whole krate here
|
||||
@@ -618,11 +618,11 @@ pub fn visit_item_likes_in_module<V>(&self, module: DefId, visitor: &mut V)
|
||||
}
|
||||
|
||||
for id in &module.trait_items {
|
||||
visitor.visit_trait_item(self.expect_trait_item(id.node_id));
|
||||
visitor.visit_trait_item(self.expect_trait_item_by_hir_id(id.hir_id));
|
||||
}
|
||||
|
||||
for id in &module.impl_items {
|
||||
visitor.visit_impl_item(self.expect_impl_item(id.node_id));
|
||||
visitor.visit_impl_item(self.expect_impl_item_by_hir_id(id.hir_id));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-21
@@ -834,7 +834,6 @@ pub struct Block {
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
pub struct Pat {
|
||||
pub id: NodeId,
|
||||
pub hir_id: HirId,
|
||||
pub node: PatKind,
|
||||
pub span: Span,
|
||||
@@ -842,7 +841,7 @@ pub struct Pat {
|
||||
|
||||
impl fmt::Debug for Pat {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "pat({}: {})", self.id,
|
||||
write!(f, "pat({}: {})", self.hir_id,
|
||||
print::to_string(print::NO_ANN, |s| s.print_pat(self)))
|
||||
}
|
||||
}
|
||||
@@ -897,7 +896,6 @@ pub fn walk<F>(&self, mut it: F) -> bool
|
||||
/// except `is_shorthand` is true.
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||
pub struct FieldPat {
|
||||
pub id: NodeId,
|
||||
pub hir_id: HirId,
|
||||
/// The identifier for the field.
|
||||
pub ident: Ident,
|
||||
@@ -1659,7 +1657,7 @@ pub struct MethodSig {
|
||||
// so it can fetched later.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, RustcEncodable, RustcDecodable, Debug)]
|
||||
pub struct TraitItemId {
|
||||
pub node_id: NodeId,
|
||||
pub hir_id: HirId,
|
||||
}
|
||||
|
||||
/// Represents an item declaration within a trait declaration,
|
||||
@@ -1704,7 +1702,7 @@ pub enum TraitItemKind {
|
||||
// so it can fetched later.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, RustcEncodable, RustcDecodable, Debug)]
|
||||
pub struct ImplItemId {
|
||||
pub node_id: NodeId,
|
||||
pub hir_id: HirId,
|
||||
}
|
||||
|
||||
/// Represents anything within an `impl` block
|
||||
@@ -2132,7 +2130,6 @@ pub struct StructField {
|
||||
pub span: Span,
|
||||
pub ident: Ident,
|
||||
pub vis: Visibility,
|
||||
pub id: NodeId,
|
||||
pub hir_id: HirId,
|
||||
pub ty: P<Ty>,
|
||||
pub attrs: HirVec<Attribute>,
|
||||
@@ -2159,9 +2156,9 @@ pub fn is_positional(&self) -> bool {
|
||||
/// Id of the whole struct lives in `Item`.
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||
pub enum VariantData {
|
||||
Struct(HirVec<StructField>, NodeId, HirId),
|
||||
Tuple(HirVec<StructField>, NodeId, HirId),
|
||||
Unit(NodeId, HirId),
|
||||
Struct(HirVec<StructField>, HirId),
|
||||
Tuple(HirVec<StructField>, HirId),
|
||||
Unit(HirId),
|
||||
}
|
||||
|
||||
impl VariantData {
|
||||
@@ -2171,18 +2168,11 @@ pub fn fields(&self) -> &[StructField] {
|
||||
_ => &[],
|
||||
}
|
||||
}
|
||||
pub fn id(&self) -> NodeId {
|
||||
match *self {
|
||||
VariantData::Struct(_, id, ..)
|
||||
| VariantData::Tuple(_, id, ..)
|
||||
| VariantData::Unit(id, ..) => id,
|
||||
}
|
||||
}
|
||||
pub fn hir_id(&self) -> HirId {
|
||||
match *self {
|
||||
VariantData::Struct(_, _, hir_id)
|
||||
| VariantData::Tuple(_, _, hir_id)
|
||||
| VariantData::Unit(_, hir_id) => hir_id,
|
||||
VariantData::Struct(_, hir_id)
|
||||
| VariantData::Tuple(_, hir_id)
|
||||
| VariantData::Unit(hir_id) => hir_id,
|
||||
}
|
||||
}
|
||||
pub fn is_struct(&self) -> bool {
|
||||
@@ -2222,7 +2212,6 @@ pub struct ItemId {
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||
pub struct Item {
|
||||
pub ident: Ident,
|
||||
pub id: NodeId,
|
||||
pub hir_id: HirId,
|
||||
pub attrs: HirVec<Attribute>,
|
||||
pub node: ItemKind,
|
||||
@@ -2379,7 +2368,6 @@ pub struct ForeignItem {
|
||||
pub ident: Ident,
|
||||
pub attrs: HirVec<Attribute>,
|
||||
pub node: ForeignItemKind,
|
||||
pub id: NodeId,
|
||||
pub hir_id: HirId,
|
||||
pub span: Span,
|
||||
pub vis: Visibility,
|
||||
|
||||
@@ -116,11 +116,11 @@ fn hash_stable<W: StableHasherResult>(&self,
|
||||
hcx: &mut StableHashingContext<'a>,
|
||||
hasher: &mut StableHasher<W>) {
|
||||
let hir::TraitItemId {
|
||||
node_id
|
||||
hir_id
|
||||
} = * self;
|
||||
|
||||
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
|
||||
node_id.hash_stable(hcx, hasher);
|
||||
hir_id.hash_stable(hcx, hasher);
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -130,11 +130,11 @@ fn hash_stable<W: StableHasherResult>(&self,
|
||||
hcx: &mut StableHashingContext<'a>,
|
||||
hasher: &mut StableHasher<W>) {
|
||||
let hir::ImplItemId {
|
||||
node_id
|
||||
hir_id
|
||||
} = * self;
|
||||
|
||||
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
|
||||
node_id.hash_stable(hcx, hasher);
|
||||
hir_id.hash_stable(hcx, hasher);
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -421,7 +421,6 @@ fn hash_stable<W: StableHasherResult>(&self,
|
||||
});
|
||||
|
||||
impl_stable_hash_for!(struct hir::Pat {
|
||||
id -> _,
|
||||
hir_id -> _,
|
||||
node,
|
||||
span,
|
||||
@@ -430,7 +429,6 @@ fn hash_stable<W: StableHasherResult>(&self,
|
||||
impl_stable_hash_for_spanned!(hir::FieldPat);
|
||||
|
||||
impl_stable_hash_for!(struct hir::FieldPat {
|
||||
id -> _,
|
||||
hir_id -> _,
|
||||
ident -> (ident.name),
|
||||
pat,
|
||||
@@ -838,16 +836,15 @@ fn hash_stable<W: StableHasherResult>(&self,
|
||||
span,
|
||||
ident -> (ident.name),
|
||||
vis,
|
||||
id,
|
||||
hir_id,
|
||||
ty,
|
||||
attrs
|
||||
});
|
||||
|
||||
impl_stable_hash_for!(enum hir::VariantData {
|
||||
Struct(fields, id, hir_id),
|
||||
Tuple(fields, id, hir_id),
|
||||
Unit(id, hir_id)
|
||||
Struct(fields, hir_id),
|
||||
Tuple(fields, hir_id),
|
||||
Unit(hir_id)
|
||||
});
|
||||
|
||||
impl<'a> HashStable<StableHashingContext<'a>> for hir::Item {
|
||||
@@ -857,7 +854,6 @@ fn hash_stable<W: StableHasherResult>(&self,
|
||||
let hir::Item {
|
||||
ident,
|
||||
ref attrs,
|
||||
id: _,
|
||||
hir_id: _,
|
||||
ref node,
|
||||
ref vis,
|
||||
@@ -932,7 +928,6 @@ fn hash_stable<W: StableHasherResult>(&self,
|
||||
ident -> (ident.name),
|
||||
attrs,
|
||||
node,
|
||||
id,
|
||||
hir_id,
|
||||
span,
|
||||
vis
|
||||
|
||||
@@ -152,7 +152,7 @@ fn visit_node(&mut self, node: Node<'tcx>) {
|
||||
Node::Item(item) => {
|
||||
match item.node {
|
||||
hir::ItemKind::Struct(..) | hir::ItemKind::Union(..) => {
|
||||
let def_id = self.tcx.hir().local_def_id(item.id);
|
||||
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
let def = self.tcx.adt_def(def_id);
|
||||
self.repr_has_repr_c = def.repr.c();
|
||||
|
||||
@@ -376,7 +376,7 @@ fn visit_item(&mut self, item: &hir::Item) {
|
||||
has_allow_dead_code_or_lang_attr(self.tcx,
|
||||
impl_item.hir_id,
|
||||
&impl_item.attrs) {
|
||||
self.worklist.push(self.tcx.hir().node_to_hir_id(impl_item_ref.id.node_id));
|
||||
self.worklist.push(impl_item_ref.id.hir_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -465,7 +465,7 @@ fn should_warn_about_item(&mut self, item: &hir::Item) -> bool {
|
||||
}
|
||||
|
||||
fn should_warn_about_field(&mut self, field: &hir::StructField) -> bool {
|
||||
let field_type = self.tcx.type_of(self.tcx.hir().local_def_id(field.id));
|
||||
let field_type = self.tcx.type_of(self.tcx.hir().local_def_id_from_hir_id(field.hir_id));
|
||||
!field.is_positional()
|
||||
&& !self.symbol_is_live(field.hir_id)
|
||||
&& !field_type.is_phantom_data()
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
use crate::hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefId, LOCAL_CRATE};
|
||||
use crate::session::{config, Session};
|
||||
use crate::session::config::EntryFnType;
|
||||
use syntax::ast::NodeId;
|
||||
use syntax::attr;
|
||||
use syntax::entry::EntryPointType;
|
||||
use syntax_pos::Span;
|
||||
use crate::hir::{Item, ItemKind, ImplItem, TraitItem};
|
||||
use crate::hir::{HirId, Item, ItemKind, ImplItem, TraitItem};
|
||||
use crate::hir::itemlikevisit::ItemLikeVisitor;
|
||||
use crate::ty::TyCtxt;
|
||||
use crate::ty::query::Providers;
|
||||
@@ -17,22 +16,22 @@ struct EntryContext<'a, 'tcx: 'a> {
|
||||
map: &'a hir_map::Map<'tcx>,
|
||||
|
||||
// The top-level function called 'main'
|
||||
main_fn: Option<(NodeId, Span)>,
|
||||
main_fn: Option<(HirId, Span)>,
|
||||
|
||||
// The function that has attribute named 'main'
|
||||
attr_main_fn: Option<(NodeId, Span)>,
|
||||
attr_main_fn: Option<(HirId, Span)>,
|
||||
|
||||
// The function that has the attribute 'start' on it
|
||||
start_fn: Option<(NodeId, Span)>,
|
||||
start_fn: Option<(HirId, Span)>,
|
||||
|
||||
// The functions that one might think are 'main' but aren't, e.g.
|
||||
// main functions not defined at the top level. For diagnostics.
|
||||
non_main_fns: Vec<(NodeId, Span)> ,
|
||||
non_main_fns: Vec<(HirId, Span)> ,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> ItemLikeVisitor<'tcx> for EntryContext<'a, 'tcx> {
|
||||
fn visit_item(&mut self, item: &'tcx Item) {
|
||||
let def_id = self.map.local_def_id(item.id);
|
||||
let def_id = self.map.local_def_id_from_hir_id(item.hir_id);
|
||||
let def_key = self.map.def_key(def_id);
|
||||
let at_root = def_key.parent == Some(CRATE_DEF_INDEX);
|
||||
find_item(item, self, at_root);
|
||||
@@ -106,18 +105,18 @@ fn find_item(item: &Item, ctxt: &mut EntryContext<'_, '_>, at_root: bool) {
|
||||
match entry_point_type(item, at_root) {
|
||||
EntryPointType::MainNamed => {
|
||||
if ctxt.main_fn.is_none() {
|
||||
ctxt.main_fn = Some((item.id, item.span));
|
||||
ctxt.main_fn = Some((item.hir_id, item.span));
|
||||
} else {
|
||||
span_err!(ctxt.session, item.span, E0136,
|
||||
"multiple 'main' functions");
|
||||
}
|
||||
},
|
||||
EntryPointType::OtherMain => {
|
||||
ctxt.non_main_fns.push((item.id, item.span));
|
||||
ctxt.non_main_fns.push((item.hir_id, item.span));
|
||||
},
|
||||
EntryPointType::MainAttr => {
|
||||
if ctxt.attr_main_fn.is_none() {
|
||||
ctxt.attr_main_fn = Some((item.id, item.span));
|
||||
ctxt.attr_main_fn = Some((item.hir_id, item.span));
|
||||
} else {
|
||||
struct_span_err!(ctxt.session, item.span, E0137,
|
||||
"multiple functions with a #[main] attribute")
|
||||
@@ -128,7 +127,7 @@ fn find_item(item: &Item, ctxt: &mut EntryContext<'_, '_>, at_root: bool) {
|
||||
},
|
||||
EntryPointType::Start => {
|
||||
if ctxt.start_fn.is_none() {
|
||||
ctxt.start_fn = Some((item.id, item.span));
|
||||
ctxt.start_fn = Some((item.hir_id, item.span));
|
||||
} else {
|
||||
struct_span_err!(ctxt.session, item.span, E0138, "multiple 'start' functions")
|
||||
.span_label(ctxt.start_fn.unwrap().1, "previous `start` function here")
|
||||
@@ -144,12 +143,12 @@ fn configure_main(
|
||||
tcx: TyCtxt<'_, '_, '_>,
|
||||
visitor: &EntryContext<'_, '_>,
|
||||
) -> Option<(DefId, EntryFnType)> {
|
||||
if let Some((node_id, _)) = visitor.start_fn {
|
||||
Some((tcx.hir().local_def_id(node_id), EntryFnType::Start))
|
||||
} else if let Some((node_id, _)) = visitor.attr_main_fn {
|
||||
Some((tcx.hir().local_def_id(node_id), EntryFnType::Main))
|
||||
} else if let Some((node_id, _)) = visitor.main_fn {
|
||||
Some((tcx.hir().local_def_id(node_id), EntryFnType::Main))
|
||||
if let Some((hir_id, _)) = visitor.start_fn {
|
||||
Some((tcx.hir().local_def_id_from_hir_id(hir_id), EntryFnType::Start))
|
||||
} else if let Some((hir_id, _)) = visitor.attr_main_fn {
|
||||
Some((tcx.hir().local_def_id_from_hir_id(hir_id), EntryFnType::Main))
|
||||
} else if let Some((hir_id, _)) = visitor.main_fn {
|
||||
Some((tcx.hir().local_def_id_from_hir_id(hir_id), EntryFnType::Main))
|
||||
} else {
|
||||
// No main function
|
||||
let mut err = struct_err!(tcx.sess, E0601,
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
use crate::hir::{self, PatKind};
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use std::rc::Rc;
|
||||
use syntax::ast;
|
||||
use syntax::ptr::P;
|
||||
use syntax_pos::Span;
|
||||
use crate::util::nodemap::ItemLocalSet;
|
||||
@@ -74,7 +73,7 @@ fn borrow(&mut self,
|
||||
|
||||
// The local variable `id` is declared but not initialized.
|
||||
fn decl_without_init(&mut self,
|
||||
id: ast::NodeId,
|
||||
id: hir::HirId,
|
||||
span: Span);
|
||||
|
||||
// The path at `cmt` is being assigned to.
|
||||
@@ -609,8 +608,7 @@ fn walk_local(&mut self, local: &hir::Local) {
|
||||
match local.init {
|
||||
None => {
|
||||
local.pat.each_binding(|_, hir_id, span, _| {
|
||||
let node_id = self.mc.tcx.hir().hir_to_node_id(hir_id);
|
||||
self.delegate.decl_without_init(node_id, span);
|
||||
self.delegate.decl_without_init(hir_id, span);
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ fn visit_item(&mut self, item: &hir::Item) {
|
||||
match self.item_refs.get(&*value.as_str()).cloned() {
|
||||
// Known lang item with attribute on correct target.
|
||||
Some((item_index, expected_target)) if actual_target == expected_target => {
|
||||
let def_id = self.tcx.hir().local_def_id(item.id);
|
||||
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
self.collect_item(item_index, def_id);
|
||||
},
|
||||
// Known lang item with attribute on incorrect target.
|
||||
|
||||
@@ -88,7 +88,7 @@ pub enum Categorization<'tcx> {
|
||||
ThreadLocal(ty::Region<'tcx>), // value that cannot move, but still restricted in scope
|
||||
StaticItem,
|
||||
Upvar(Upvar), // upvar referenced by closure env
|
||||
Local(ast::NodeId), // local variable
|
||||
Local(hir::HirId), // local variable
|
||||
Deref(cmt<'tcx>, PointerKind<'tcx>), // deref of a ptr
|
||||
Interior(cmt<'tcx>, InteriorKind), // something interior: field, tuple, etc
|
||||
Downcast(cmt<'tcx>, DefId), // selects a particular enum variant (*1)
|
||||
@@ -198,9 +198,9 @@ pub struct cmt_<'tcx> {
|
||||
pub type cmt<'tcx> = Rc<cmt_<'tcx>>;
|
||||
|
||||
pub enum ImmutabilityBlame<'tcx> {
|
||||
ImmLocal(ast::NodeId),
|
||||
ImmLocal(hir::HirId),
|
||||
ClosureEnv(LocalDefId),
|
||||
LocalDeref(ast::NodeId),
|
||||
LocalDeref(hir::HirId),
|
||||
AdtFieldDeref(&'tcx ty::AdtDef, &'tcx ty::FieldDef)
|
||||
}
|
||||
|
||||
@@ -230,8 +230,8 @@ pub fn immutability_blame(&self) -> Option<ImmutabilityBlame<'tcx>> {
|
||||
Categorization::Deref(ref base_cmt, BorrowedPtr(ty::ImmBorrow, _)) => {
|
||||
// try to figure out where the immutable reference came from
|
||||
match base_cmt.cat {
|
||||
Categorization::Local(node_id) =>
|
||||
Some(ImmutabilityBlame::LocalDeref(node_id)),
|
||||
Categorization::Local(hir_id) =>
|
||||
Some(ImmutabilityBlame::LocalDeref(hir_id)),
|
||||
Categorization::Interior(ref base_cmt, InteriorField(field_index)) => {
|
||||
base_cmt.resolve_field(field_index.0).map(|(adt_def, field_def)| {
|
||||
ImmutabilityBlame::AdtFieldDeref(adt_def, field_def)
|
||||
@@ -247,8 +247,8 @@ pub fn immutability_blame(&self) -> Option<ImmutabilityBlame<'tcx>> {
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
Categorization::Local(node_id) => {
|
||||
Some(ImmutabilityBlame::ImmLocal(node_id))
|
||||
Categorization::Local(hir_id) => {
|
||||
Some(ImmutabilityBlame::ImmLocal(hir_id))
|
||||
}
|
||||
Categorization::Rvalue(..) |
|
||||
Categorization::Upvar(..) |
|
||||
@@ -741,7 +741,7 @@ pub fn cat_def(&self,
|
||||
Ok(cmt_ {
|
||||
hir_id,
|
||||
span,
|
||||
cat: Categorization::Local(vid),
|
||||
cat: Categorization::Local(self.tcx.hir().node_to_hir_id(vid)),
|
||||
mutbl: MutabilityCategory::from_local(self.tcx, self.tables, vid),
|
||||
ty: expr_ty,
|
||||
note: NoteNone
|
||||
@@ -1495,7 +1495,7 @@ pub fn descriptive_string(&self, tcx: TyCtxt<'_, '_, '_>) -> Cow<'static, str> {
|
||||
"non-place".into()
|
||||
}
|
||||
Categorization::Local(vid) => {
|
||||
if tcx.hir().is_argument(vid) {
|
||||
if tcx.hir().is_argument(tcx.hir().hir_to_node_id(vid)) {
|
||||
"argument"
|
||||
} else {
|
||||
"local variable"
|
||||
|
||||
@@ -14,10 +14,9 @@
|
||||
use crate::ty::query::Providers;
|
||||
use crate::middle::privacy;
|
||||
use crate::session::config;
|
||||
use crate::util::nodemap::{NodeSet, FxHashSet};
|
||||
use crate::util::nodemap::{HirIdSet, FxHashSet};
|
||||
|
||||
use rustc_target::spec::abi::Abi;
|
||||
use syntax::ast;
|
||||
use crate::hir;
|
||||
use crate::hir::def_id::LOCAL_CRATE;
|
||||
use crate::hir::intravisit::{Visitor, NestedVisitorMap};
|
||||
@@ -37,7 +36,7 @@ fn item_might_be_inlined(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
match item.node {
|
||||
hir::ItemKind::Impl(..) |
|
||||
hir::ItemKind::Fn(..) => {
|
||||
let generics = tcx.generics_of(tcx.hir().local_def_id(item.id));
|
||||
let generics = tcx.generics_of(tcx.hir().local_def_id_from_hir_id(item.hir_id));
|
||||
generics.requires_monomorphization(tcx)
|
||||
}
|
||||
_ => false,
|
||||
@@ -70,10 +69,10 @@ struct ReachableContext<'a, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
tables: &'a ty::TypeckTables<'tcx>,
|
||||
// The set of items which must be exported in the linkage sense.
|
||||
reachable_symbols: NodeSet,
|
||||
reachable_symbols: HirIdSet,
|
||||
// A worklist of item IDs. Each item ID in this worklist will be inlined
|
||||
// and will be scanned for further references.
|
||||
worklist: Vec<ast::NodeId>,
|
||||
worklist: Vec<hir::HirId>,
|
||||
// Whether any output of this compilation is a library
|
||||
any_library: bool,
|
||||
}
|
||||
@@ -104,27 +103,28 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
|
||||
|
||||
match def {
|
||||
Some(Def::Local(node_id)) | Some(Def::Upvar(node_id, ..)) => {
|
||||
self.reachable_symbols.insert(node_id);
|
||||
let hir_id = self.tcx.hir().node_to_hir_id(node_id);
|
||||
self.reachable_symbols.insert(hir_id);
|
||||
}
|
||||
Some(def) => {
|
||||
if let Some((node_id, def_id)) = def.opt_def_id().and_then(|def_id| {
|
||||
self.tcx.hir().as_local_node_id(def_id).map(|node_id| (node_id, def_id))
|
||||
if let Some((hir_id, def_id)) = def.opt_def_id().and_then(|def_id| {
|
||||
self.tcx.hir().as_local_hir_id(def_id).map(|hir_id| (hir_id, def_id))
|
||||
}) {
|
||||
if self.def_id_represents_local_inlined_item(def_id) {
|
||||
self.worklist.push(node_id);
|
||||
self.worklist.push(hir_id);
|
||||
} else {
|
||||
match def {
|
||||
// If this path leads to a constant, then we need to
|
||||
// recurse into the constant to continue finding
|
||||
// items that are reachable.
|
||||
Def::Const(..) | Def::AssociatedConst(..) => {
|
||||
self.worklist.push(node_id);
|
||||
self.worklist.push(hir_id);
|
||||
}
|
||||
|
||||
// If this wasn't a static, then the destination is
|
||||
// surely reachable.
|
||||
_ => {
|
||||
self.reachable_symbols.insert(node_id);
|
||||
self.reachable_symbols.insert(hir_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -204,14 +204,14 @@ fn propagate(&mut self) {
|
||||
continue
|
||||
}
|
||||
|
||||
if let Some(ref item) = self.tcx.hir().find(search_item) {
|
||||
if let Some(ref item) = self.tcx.hir().find_by_hir_id(search_item) {
|
||||
self.propagate_node(item, search_item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn propagate_node(&mut self, node: &Node<'tcx>,
|
||||
search_item: ast::NodeId) {
|
||||
search_item: hir::HirId) {
|
||||
if !self.any_library {
|
||||
// If we are building an executable, only explicitly extern
|
||||
// types need to be exported.
|
||||
@@ -221,7 +221,7 @@ fn propagate_node(&mut self, node: &Node<'tcx>,
|
||||
} else {
|
||||
false
|
||||
};
|
||||
let def_id = self.tcx.hir().local_def_id(item.id);
|
||||
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
let codegen_attrs = self.tcx.codegen_fn_attrs(def_id);
|
||||
let is_extern = codegen_attrs.contains_extern_indicator();
|
||||
let std_internal = codegen_attrs.flags.contains(
|
||||
@@ -242,7 +242,7 @@ fn propagate_node(&mut self, node: &Node<'tcx>,
|
||||
Node::Item(item) => {
|
||||
match item.node {
|
||||
hir::ItemKind::Fn(.., body) => {
|
||||
let def_id = self.tcx.hir().local_def_id(item.id);
|
||||
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
if item_might_be_inlined(self.tcx,
|
||||
&item,
|
||||
self.tcx.codegen_fn_attrs(def_id)) {
|
||||
@@ -295,7 +295,7 @@ fn propagate_node(&mut self, node: &Node<'tcx>,
|
||||
self.visit_nested_body(body);
|
||||
}
|
||||
hir::ImplItemKind::Method(_, body) => {
|
||||
let did = self.tcx.hir().get_parent_did(search_item);
|
||||
let did = self.tcx.hir().get_parent_did_by_hir_id(search_item);
|
||||
if method_might_be_inlined(self.tcx, impl_item, did) {
|
||||
self.visit_nested_body(body)
|
||||
}
|
||||
@@ -317,7 +317,7 @@ fn propagate_node(&mut self, node: &Node<'tcx>,
|
||||
_ => {
|
||||
bug!(
|
||||
"found unexpected node kind in worklist: {} ({:?})",
|
||||
self.tcx.hir().node_to_string(search_item),
|
||||
self.tcx.hir().hir_to_string(search_item),
|
||||
node,
|
||||
);
|
||||
}
|
||||
@@ -336,7 +336,7 @@ fn propagate_node(&mut self, node: &Node<'tcx>,
|
||||
struct CollectPrivateImplItemsVisitor<'a, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
access_levels: &'a privacy::AccessLevels,
|
||||
worklist: &'a mut Vec<ast::NodeId>,
|
||||
worklist: &'a mut Vec<hir::HirId>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx: 'a> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a, 'tcx> {
|
||||
@@ -344,17 +344,18 @@ fn visit_item(&mut self, item: &hir::Item) {
|
||||
// Anything which has custom linkage gets thrown on the worklist no
|
||||
// matter where it is in the crate, along with "special std symbols"
|
||||
// which are currently akin to allocator symbols.
|
||||
let def_id = self.tcx.hir().local_def_id(item.id);
|
||||
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
let codegen_attrs = self.tcx.codegen_fn_attrs(def_id);
|
||||
if codegen_attrs.contains_extern_indicator() ||
|
||||
codegen_attrs.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL) {
|
||||
self.worklist.push(item.id);
|
||||
self.worklist.push(item.hir_id);
|
||||
}
|
||||
|
||||
// We need only trait impls here, not inherent impls, and only non-exported ones
|
||||
if let hir::ItemKind::Impl(.., Some(ref trait_ref), _, ref impl_item_refs) = item.node {
|
||||
if !self.access_levels.is_reachable(item.id) {
|
||||
self.worklist.extend(impl_item_refs.iter().map(|r| r.id.node_id));
|
||||
let node_id = self.tcx.hir().hir_to_node_id(item.hir_id);
|
||||
if !self.access_levels.is_reachable(node_id) {
|
||||
self.worklist.extend(impl_item_refs.iter().map(|ii_ref| ii_ref.id.hir_id));
|
||||
|
||||
let trait_def_id = match trait_ref.path.def {
|
||||
Def::Trait(def_id) => def_id,
|
||||
@@ -368,11 +369,11 @@ fn visit_item(&mut self, item: &hir::Item) {
|
||||
let provided_trait_methods = self.tcx.provided_trait_methods(trait_def_id);
|
||||
self.worklist.reserve(provided_trait_methods.len());
|
||||
for default_method in provided_trait_methods {
|
||||
let node_id = self.tcx
|
||||
.hir()
|
||||
.as_local_node_id(default_method.def_id)
|
||||
.unwrap();
|
||||
self.worklist.push(node_id);
|
||||
let hir_id = self.tcx
|
||||
.hir()
|
||||
.as_local_hir_id(default_method.def_id)
|
||||
.unwrap();
|
||||
self.worklist.push(hir_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -388,7 +389,7 @@ fn visit_impl_item(&mut self, _impl_item: &hir::ImplItem) {
|
||||
// We introduce a new-type here, so we can have a specialized HashStable
|
||||
// implementation for it.
|
||||
#[derive(Clone)]
|
||||
pub struct ReachableSet(pub Lrc<NodeSet>);
|
||||
pub struct ReachableSet(pub Lrc<HirIdSet>);
|
||||
|
||||
fn reachable_set<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum) -> ReachableSet {
|
||||
debug_assert!(crate_num == LOCAL_CRATE);
|
||||
@@ -412,11 +413,12 @@ fn reachable_set<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum) ->
|
||||
// If other crates link to us, they're going to expect to be able to
|
||||
// use the lang items, so we need to be sure to mark them as
|
||||
// exported.
|
||||
reachable_context.worklist.extend(access_levels.map.iter().map(|(id, _)| *id));
|
||||
reachable_context.worklist.extend(
|
||||
access_levels.map.iter().map(|(id, _)| tcx.hir().node_to_hir_id(*id)));
|
||||
for item in tcx.lang_items().items().iter() {
|
||||
if let Some(did) = *item {
|
||||
if let Some(node_id) = tcx.hir().as_local_node_id(did) {
|
||||
reachable_context.worklist.push(node_id);
|
||||
if let Some(hir_id) = tcx.hir().as_local_hir_id(did) {
|
||||
reachable_context.worklist.push(hir_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
use crate::rustc::lint;
|
||||
use crate::session::Session;
|
||||
use crate::util::nodemap::{DefIdMap, FxHashMap, FxHashSet, HirIdMap, HirIdSet, NodeMap};
|
||||
use crate::util::nodemap::{DefIdMap, FxHashMap, FxHashSet, HirIdMap, HirIdSet};
|
||||
use errors::{Applicability, DiagnosticBuilder};
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use std::borrow::Cow;
|
||||
@@ -204,7 +204,7 @@ struct NamedRegionMap {
|
||||
|
||||
// For each type and trait definition, maps type parameters
|
||||
// to the trait object lifetime defaults computed from them.
|
||||
pub object_lifetime_defaults: NodeMap<Vec<ObjectLifetimeDefault>>,
|
||||
pub object_lifetime_defaults: HirIdMap<Vec<ObjectLifetimeDefault>>,
|
||||
}
|
||||
|
||||
/// See [`NamedRegionMap`].
|
||||
@@ -395,8 +395,7 @@ fn resolve_lifetimes<'tcx>(
|
||||
.or_default();
|
||||
Lrc::get_mut(map).unwrap().insert(hir_id.local_id);
|
||||
}
|
||||
for (k, v) in named_region_map.object_lifetime_defaults {
|
||||
let hir_id = tcx.hir().node_to_hir_id(k);
|
||||
for (hir_id, v) in named_region_map.object_lifetime_defaults {
|
||||
let map = rl.object_lifetime_defaults
|
||||
.entry(hir_id.owner_local_def_id())
|
||||
.or_default();
|
||||
@@ -672,13 +671,14 @@ fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
|
||||
// In the future, this should be fixed and this error should be removed.
|
||||
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) {
|
||||
if let Some(hir_id) = self.tcx.hir().as_local_hir_id(def_id) {
|
||||
// Ensure that the parent of the def is an item, not HRTB
|
||||
let parent_id = self.tcx.hir().get_parent_node(node_id);
|
||||
let parent_impl_id = hir::ImplItemId { node_id: parent_id };
|
||||
let parent_trait_id = hir::TraitItemId { node_id: parent_id };
|
||||
let parent_id = self.tcx.hir().get_parent_node_by_hir_id(hir_id);
|
||||
let parent_impl_id = hir::ImplItemId { hir_id: parent_id };
|
||||
let parent_trait_id = hir::TraitItemId { hir_id: parent_id };
|
||||
let krate = self.tcx.hir().forest.krate();
|
||||
if !(krate.items.contains_key(&parent_id)
|
||||
let parent_node_id = self.tcx.hir().hir_to_node_id(parent_id);
|
||||
if !(krate.items.contains_key(&parent_node_id)
|
||||
|| krate.impl_items.contains_key(&parent_impl_id)
|
||||
|| krate.trait_items.contains_key(&parent_trait_id))
|
||||
{
|
||||
@@ -1266,8 +1266,8 @@ fn check_if_label_shadows_lifetime(
|
||||
|
||||
fn compute_object_lifetime_defaults(
|
||||
tcx: TyCtxt<'_, '_, '_>,
|
||||
) -> NodeMap<Vec<ObjectLifetimeDefault>> {
|
||||
let mut map = NodeMap::default();
|
||||
) -> HirIdMap<Vec<ObjectLifetimeDefault>> {
|
||||
let mut map = HirIdMap::default();
|
||||
for item in tcx.hir().krate().items.values() {
|
||||
match item.node {
|
||||
hir::ItemKind::Struct(_, ref generics)
|
||||
@@ -1311,7 +1311,7 @@ fn compute_object_lifetime_defaults(
|
||||
tcx.sess.span_err(item.span, &object_lifetime_default_reprs);
|
||||
}
|
||||
|
||||
map.insert(item.id, result);
|
||||
map.insert(item.hir_id, result);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
@@ -1959,7 +1959,7 @@ fn visit_segment_args(&mut self, def: Def, depth: usize, generic_args: &'tcx hir
|
||||
};
|
||||
|
||||
let map = &self.map;
|
||||
let unsubst = if let Some(id) = self.tcx.hir().as_local_node_id(def_id) {
|
||||
let unsubst = if let Some(id) = self.tcx.hir().as_local_hir_id(def_id) {
|
||||
&map.object_lifetime_defaults[&id]
|
||||
} else {
|
||||
let tcx = self.tcx;
|
||||
@@ -2073,10 +2073,9 @@ fn visit_fn_like_elision(&mut self, inputs: &'tcx [hir::Ty], output: Option<&'tc
|
||||
.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_node_id)
|
||||
.find(|ti| ti.id.hir_id == parent)
|
||||
.map(|ti| ti.kind);
|
||||
}
|
||||
match *m {
|
||||
@@ -2095,10 +2094,9 @@ fn visit_fn_like_elision(&mut self, inputs: &'tcx [hir::Ty], output: Option<&'tc
|
||||
.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_node_id)
|
||||
.find(|ii| ii.id.hir_id == parent)
|
||||
.map(|ii| ii.kind);
|
||||
}
|
||||
Some(body)
|
||||
@@ -2398,7 +2396,7 @@ fn report_elision_failure(
|
||||
|
||||
let help_name = if let Some(body) = parent {
|
||||
let arg = &self.tcx.hir().body(body).arguments[index];
|
||||
format!("`{}`", self.tcx.hir().node_to_pretty_string(arg.pat.id))
|
||||
format!("`{}`", self.tcx.hir().hir_to_pretty_string(arg.pat.hir_id))
|
||||
} else {
|
||||
format!("argument {}", index + 1)
|
||||
};
|
||||
|
||||
@@ -317,10 +317,9 @@ struct MissingStabilityAnnotations<'a, 'tcx: 'a> {
|
||||
impl<'a, 'tcx: 'a> MissingStabilityAnnotations<'a, 'tcx> {
|
||||
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(node_id);
|
||||
self.access_levels.is_reachable(self.tcx.hir().hir_to_node_id(hir_id));
|
||||
if is_error {
|
||||
self.tcx.sess.span_err(
|
||||
span,
|
||||
@@ -762,7 +761,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
// compiler-generated `extern crate` items have a dummy span.
|
||||
if item.span.is_dummy() { return }
|
||||
|
||||
let def_id = self.tcx.hir().local_def_id(item.id);
|
||||
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
let cnum = match self.tcx.extern_mod_stmt_cnum(def_id) {
|
||||
Some(cnum) => cnum,
|
||||
None => return,
|
||||
@@ -792,7 +791,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
// There's no good place to insert stability check for non-Copy unions,
|
||||
// so semi-randomly perform it here in stability.rs
|
||||
hir::ItemKind::Union(..) if !self.tcx.features().untagged_unions => {
|
||||
let def_id = self.tcx.hir().local_def_id(item.id);
|
||||
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
let adt_def = self.tcx.adt_def(def_id);
|
||||
let ty = self.tcx.type_of(def_id);
|
||||
|
||||
|
||||
+14
-14
@@ -260,7 +260,7 @@ fn parent(self, id: DefId) -> Option<DefId> {
|
||||
}
|
||||
|
||||
impl Visibility {
|
||||
pub fn from_hir(visibility: &hir::Visibility, id: NodeId, tcx: TyCtxt<'_, '_, '_>) -> Self {
|
||||
pub fn from_hir(visibility: &hir::Visibility, id: hir::HirId, tcx: TyCtxt<'_, '_, '_>) -> Self {
|
||||
match visibility.node {
|
||||
hir::VisibilityKind::Public => Visibility::Public,
|
||||
hir::VisibilityKind::Crate(_) => Visibility::Restricted(DefId::local(CRATE_DEF_INDEX)),
|
||||
@@ -271,7 +271,7 @@ pub fn from_hir(visibility: &hir::Visibility, id: NodeId, tcx: TyCtxt<'_, '_, '_
|
||||
def => Visibility::Restricted(def.def_id()),
|
||||
},
|
||||
hir::VisibilityKind::Inherited => {
|
||||
Visibility::Restricted(tcx.hir().get_module_parent(id))
|
||||
Visibility::Restricted(tcx.hir().get_module_parent_by_hir_id(id))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2727,7 +2727,7 @@ fn associated_item_from_trait_item_ref(self,
|
||||
parent_vis: &hir::Visibility,
|
||||
trait_item_ref: &hir::TraitItemRef)
|
||||
-> AssociatedItem {
|
||||
let def_id = self.hir().local_def_id(trait_item_ref.id.node_id);
|
||||
let def_id = self.hir().local_def_id_from_hir_id(trait_item_ref.id.hir_id);
|
||||
let (kind, has_self) = match trait_item_ref.kind {
|
||||
hir::AssociatedItemKind::Const => (ty::AssociatedKind::Const, false),
|
||||
hir::AssociatedItemKind::Method { has_self } => {
|
||||
@@ -2741,7 +2741,7 @@ fn associated_item_from_trait_item_ref(self,
|
||||
ident: trait_item_ref.ident,
|
||||
kind,
|
||||
// Visibility of trait items is inherited from their traits.
|
||||
vis: Visibility::from_hir(parent_vis, trait_item_ref.id.node_id, self),
|
||||
vis: Visibility::from_hir(parent_vis, trait_item_ref.id.hir_id, self),
|
||||
defaultness: trait_item_ref.defaultness,
|
||||
def_id,
|
||||
container: TraitContainer(parent_def_id),
|
||||
@@ -2753,7 +2753,7 @@ fn associated_item_from_impl_item_ref(self,
|
||||
parent_def_id: DefId,
|
||||
impl_item_ref: &hir::ImplItemRef)
|
||||
-> AssociatedItem {
|
||||
let def_id = self.hir().local_def_id(impl_item_ref.id.node_id);
|
||||
let def_id = self.hir().local_def_id_from_hir_id(impl_item_ref.id.hir_id);
|
||||
let (kind, has_self) = match impl_item_ref.kind {
|
||||
hir::AssociatedItemKind::Const => (ty::AssociatedKind::Const, false),
|
||||
hir::AssociatedItemKind::Method { has_self } => {
|
||||
@@ -2767,7 +2767,7 @@ fn associated_item_from_impl_item_ref(self,
|
||||
ident: impl_item_ref.ident,
|
||||
kind,
|
||||
// Visibility of trait impl items doesn't matter.
|
||||
vis: ty::Visibility::from_hir(&impl_item_ref.vis, impl_item_ref.id.node_id, self),
|
||||
vis: ty::Visibility::from_hir(&impl_item_ref.vis, impl_item_ref.id.hir_id, self),
|
||||
defaultness: impl_item_ref.defaultness,
|
||||
def_id,
|
||||
container: ImplContainer(parent_def_id),
|
||||
@@ -3037,13 +3037,13 @@ pub fn with_freevars<T, F>(self, fid: NodeId, f: F) -> T where
|
||||
}
|
||||
|
||||
fn associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> AssociatedItem {
|
||||
let id = tcx.hir().as_local_node_id(def_id).unwrap();
|
||||
let parent_id = tcx.hir().get_parent(id);
|
||||
let parent_def_id = tcx.hir().local_def_id(parent_id);
|
||||
let parent_item = tcx.hir().expect_item(parent_id);
|
||||
let id = tcx.hir().as_local_hir_id(def_id).unwrap();
|
||||
let parent_id = tcx.hir().get_parent_item(id);
|
||||
let parent_def_id = tcx.hir().local_def_id_from_hir_id(parent_id);
|
||||
let parent_item = tcx.hir().expect_item_by_hir_id(parent_id);
|
||||
match parent_item.node {
|
||||
hir::ItemKind::Impl(.., ref impl_item_refs) => {
|
||||
if let Some(impl_item_ref) = impl_item_refs.iter().find(|i| i.id.node_id == id) {
|
||||
if let Some(impl_item_ref) = impl_item_refs.iter().find(|i| i.id.hir_id == id) {
|
||||
let assoc_item = tcx.associated_item_from_impl_item_ref(parent_def_id,
|
||||
impl_item_ref);
|
||||
debug_assert_eq!(assoc_item.def_id, def_id);
|
||||
@@ -3052,7 +3052,7 @@ fn associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Asso
|
||||
}
|
||||
|
||||
hir::ItemKind::Trait(.., ref trait_item_refs) => {
|
||||
if let Some(trait_item_ref) = trait_item_refs.iter().find(|i| i.id.node_id == id) {
|
||||
if let Some(trait_item_ref) = trait_item_refs.iter().find(|i| i.id.hir_id == id) {
|
||||
let assoc_item = tcx.associated_item_from_trait_item_ref(parent_def_id,
|
||||
&parent_item.vis,
|
||||
trait_item_ref);
|
||||
@@ -3106,13 +3106,13 @@ fn associated_item_def_ids<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
hir::ItemKind::Trait(.., ref trait_item_refs) => {
|
||||
trait_item_refs.iter()
|
||||
.map(|trait_item_ref| trait_item_ref.id)
|
||||
.map(|id| tcx.hir().local_def_id(id.node_id))
|
||||
.map(|id| tcx.hir().local_def_id_from_hir_id(id.hir_id))
|
||||
.collect()
|
||||
}
|
||||
hir::ItemKind::Impl(.., ref impl_item_refs) => {
|
||||
impl_item_refs.iter()
|
||||
.map(|impl_item_ref| impl_item_ref.id)
|
||||
.map(|id| tcx.hir().local_def_id(id.node_id))
|
||||
.map(|id| tcx.hir().local_def_id_from_hir_id(id.hir_id))
|
||||
.collect()
|
||||
}
|
||||
hir::ItemKind::TraitAlias(..) => vec![],
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
use rustc::middle::mem_categorization::Categorization;
|
||||
use rustc::middle::region;
|
||||
use rustc::ty::{self, TyCtxt, RegionKind};
|
||||
use syntax::ast;
|
||||
use syntax_pos::Span;
|
||||
use rustc::hir;
|
||||
use rustc::hir::Node;
|
||||
@@ -177,7 +176,7 @@ fn mutate(&mut self,
|
||||
self.check_assignment(assignment_id.local_id, assignment_span, assignee_cmt);
|
||||
}
|
||||
|
||||
fn decl_without_init(&mut self, _id: ast::NodeId, _span: Span) { }
|
||||
fn decl_without_init(&mut self, _id: hir::HirId, _span: Span) { }
|
||||
}
|
||||
|
||||
pub fn check_loans<'a, 'b, 'c, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
||||
@@ -887,11 +886,10 @@ fn check_assignment(&self,
|
||||
// Check for reassignments to (immutable) local variables. This
|
||||
// needs to be done here instead of in check_loans because we
|
||||
// depend on move data.
|
||||
if let Categorization::Local(local_id) = assignee_cmt.cat {
|
||||
if let Categorization::Local(hir_id) = assignee_cmt.cat {
|
||||
let lp = opt_loan_path(assignee_cmt).unwrap();
|
||||
self.move_data.each_assignment_of(assignment_id, &lp, |assign| {
|
||||
if assignee_cmt.mutbl.is_mutable() {
|
||||
let hir_id = self.bccx.tcx.hir().node_to_hir_id(local_id);
|
||||
self.bccx.used_mut_nodes.borrow_mut().insert(hir_id);
|
||||
} else {
|
||||
self.bccx.report_reassigned_immutable_variable(
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
use rustc::ty::{self, Ty};
|
||||
|
||||
use std::rc::Rc;
|
||||
use syntax::ast;
|
||||
use syntax_pos::Span;
|
||||
use rustc::hir::*;
|
||||
use rustc::hir::Node;
|
||||
@@ -48,9 +47,9 @@ pub enum PatternSource<'tcx> {
|
||||
/// with a reference to the let
|
||||
fn get_pattern_source<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, pat: &Pat) -> PatternSource<'tcx> {
|
||||
|
||||
let parent = tcx.hir().get_parent_node(pat.id);
|
||||
let parent = tcx.hir().get_parent_node_by_hir_id(pat.hir_id);
|
||||
|
||||
match tcx.hir().get(parent) {
|
||||
match tcx.hir().get_by_hir_id(parent) {
|
||||
Node::Expr(ref e) => {
|
||||
// the enclosing expression must be a `match` or something else
|
||||
assert!(match e.node {
|
||||
@@ -67,11 +66,10 @@ fn get_pattern_source<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, pat: &Pat) -> Patte
|
||||
|
||||
pub fn gather_decl<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
||||
move_data: &MoveData<'tcx>,
|
||||
var_id: ast::NodeId,
|
||||
var_id: hir::HirId,
|
||||
var_ty: Ty<'tcx>) {
|
||||
let loan_path = Rc::new(LoanPath::new(LpVar(var_id), var_ty));
|
||||
let hir_id = bccx.tcx.hir().node_to_hir_id(var_id);
|
||||
move_data.add_move(bccx.tcx, loan_path, hir_id.local_id, Declared);
|
||||
move_data.add_move(bccx.tcx, loan_path, var_id.local_id, Declared);
|
||||
}
|
||||
|
||||
pub fn gather_move_from_expr<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
||||
|
||||
@@ -104,8 +104,7 @@ fn scope(&self, cmt: &mc::cmt_<'tcx>) -> ty::Region<'tcx> {
|
||||
Categorization::Upvar(..) => {
|
||||
self.bccx.tcx.mk_region(ty::ReScope(self.item_scope))
|
||||
}
|
||||
Categorization::Local(local_id) => {
|
||||
let hir_id = self.bccx.tcx.hir().node_to_hir_id(local_id);
|
||||
Categorization::Local(hir_id) => {
|
||||
self.bccx.tcx.mk_region(ty::ReScope(
|
||||
self.bccx.region_scope_tree.var_scope(hir_id.local_id)))
|
||||
}
|
||||
|
||||
@@ -147,10 +147,10 @@ fn mutate(&mut self,
|
||||
assignee_cmt);
|
||||
}
|
||||
|
||||
fn decl_without_init(&mut self, id: ast::NodeId, _span: Span) {
|
||||
fn decl_without_init(&mut self, id: hir::HirId, _span: Span) {
|
||||
let ty = self.bccx
|
||||
.tables
|
||||
.node_type(self.bccx.tcx.hir().node_to_hir_id(id));
|
||||
.node_type(id);
|
||||
gather_moves::gather_decl(self.bccx, &self.move_data, id, ty);
|
||||
}
|
||||
}
|
||||
@@ -438,9 +438,8 @@ pub fn mark_loan_path_as_mutated(&self, loan_path: &LoanPath<'_>) {
|
||||
|
||||
while let Some(current_path) = wrapped_path {
|
||||
wrapped_path = match current_path.kind {
|
||||
LpVar(local_id) => {
|
||||
LpVar(hir_id) => {
|
||||
if !through_borrow {
|
||||
let hir_id = self.bccx.tcx.hir().node_to_hir_id(local_id);
|
||||
self.bccx.used_mut_nodes.borrow_mut().insert(hir_id);
|
||||
}
|
||||
None
|
||||
|
||||
@@ -335,7 +335,7 @@ fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
|
||||
#[derive(PartialEq, Eq, Hash, Debug)]
|
||||
pub enum LoanPathKind<'tcx> {
|
||||
LpVar(ast::NodeId), // `x` in README.md
|
||||
LpVar(hir::HirId), // `x` in README.md
|
||||
LpUpvar(ty::UpvarId), // `x` captured by-value into closure
|
||||
LpDowncast(Rc<LoanPath<'tcx>>, DefId), // `x` downcast to particular enum variant
|
||||
LpExtend(Rc<LoanPath<'tcx>>, mc::MutabilityCategory, LoanPathElem<'tcx>)
|
||||
@@ -417,8 +417,7 @@ fn closure_to_block(closure_id: LocalDefId,
|
||||
impl<'a, 'tcx> LoanPath<'tcx> {
|
||||
pub fn kill_scope(&self, bccx: &BorrowckCtxt<'a, 'tcx>) -> region::Scope {
|
||||
match self.kind {
|
||||
LpVar(local_id) => {
|
||||
let hir_id = bccx.tcx.hir().node_to_hir_id(local_id);
|
||||
LpVar(hir_id) => {
|
||||
bccx.region_scope_tree.var_scope(hir_id.local_id)
|
||||
}
|
||||
LpUpvar(upvar_id) => {
|
||||
@@ -919,7 +918,7 @@ fn report_bckerr(&self, err: &BckError<'a, 'tcx>) {
|
||||
self.note_immutability_blame(
|
||||
&mut db,
|
||||
err.cmt.immutability_blame(),
|
||||
self.tcx.hir().hir_to_node_id(err.cmt.hir_id)
|
||||
err.cmt.hir_id
|
||||
);
|
||||
db.emit();
|
||||
self.signal_error();
|
||||
@@ -1135,7 +1134,7 @@ pub fn report_aliasability_violation(&self,
|
||||
self.note_immutability_blame(
|
||||
&mut err,
|
||||
blame,
|
||||
self.tcx.hir().hir_to_node_id(cmt.hir_id)
|
||||
cmt.hir_id
|
||||
);
|
||||
|
||||
if is_closure {
|
||||
@@ -1175,8 +1174,8 @@ fn suggest_mut_for_immutable(&self, pty: &hir::Ty, is_implicit_self: bool) -> Op
|
||||
}
|
||||
}
|
||||
|
||||
fn local_binding_mode(&self, node_id: ast::NodeId) -> ty::BindingMode {
|
||||
let pat = match self.tcx.hir().get(node_id) {
|
||||
fn local_binding_mode(&self, hir_id: hir::HirId) -> ty::BindingMode {
|
||||
let pat = match self.tcx.hir().get_by_hir_id(hir_id) {
|
||||
Node::Binding(pat) => pat,
|
||||
node => bug!("bad node for local: {:?}", node)
|
||||
};
|
||||
@@ -1192,16 +1191,16 @@ fn local_binding_mode(&self, node_id: ast::NodeId) -> ty::BindingMode {
|
||||
}
|
||||
}
|
||||
|
||||
fn local_ty(&self, node_id: ast::NodeId) -> (Option<&hir::Ty>, bool) {
|
||||
let parent = self.tcx.hir().get_parent_node(node_id);
|
||||
let parent_node = self.tcx.hir().get(parent);
|
||||
fn local_ty(&self, hir_id: hir::HirId) -> (Option<&hir::Ty>, bool) {
|
||||
let parent = self.tcx.hir().get_parent_node_by_hir_id(hir_id);
|
||||
let parent_node = self.tcx.hir().get_by_hir_id(parent);
|
||||
|
||||
// The parent node is like a fn
|
||||
if let Some(fn_like) = FnLikeNode::from_node(parent_node) {
|
||||
// `nid`'s parent's `Body`
|
||||
let fn_body = self.tcx.hir().body(fn_like.body());
|
||||
// Get the position of `node_id` in the arguments list
|
||||
let arg_pos = fn_body.arguments.iter().position(|arg| arg.pat.id == node_id);
|
||||
let arg_pos = fn_body.arguments.iter().position(|arg| arg.pat.hir_id == hir_id);
|
||||
if let Some(i) = arg_pos {
|
||||
// The argument's `Ty`
|
||||
(Some(&fn_like.decl().inputs[i]),
|
||||
@@ -1217,17 +1216,17 @@ fn local_ty(&self, node_id: ast::NodeId) -> (Option<&hir::Ty>, bool) {
|
||||
fn note_immutability_blame(&self,
|
||||
db: &mut DiagnosticBuilder<'_>,
|
||||
blame: Option<ImmutabilityBlame<'_>>,
|
||||
error_node_id: ast::NodeId) {
|
||||
error_hir_id: hir::HirId) {
|
||||
match blame {
|
||||
None => {}
|
||||
Some(ImmutabilityBlame::ClosureEnv(_)) => {}
|
||||
Some(ImmutabilityBlame::ImmLocal(node_id)) => {
|
||||
self.note_immutable_local(db, error_node_id, node_id)
|
||||
Some(ImmutabilityBlame::ImmLocal(hir_id)) => {
|
||||
self.note_immutable_local(db, error_hir_id, hir_id)
|
||||
}
|
||||
Some(ImmutabilityBlame::LocalDeref(node_id)) => {
|
||||
match self.local_binding_mode(node_id) {
|
||||
Some(ImmutabilityBlame::LocalDeref(hir_id)) => {
|
||||
match self.local_binding_mode(hir_id) {
|
||||
ty::BindByReference(..) => {
|
||||
let let_span = self.tcx.hir().span(node_id);
|
||||
let let_span = self.tcx.hir().span_by_hir_id(hir_id);
|
||||
let suggestion = suggest_ref_mut(self.tcx, let_span);
|
||||
if let Some(replace_str) = suggestion {
|
||||
db.span_suggestion(
|
||||
@@ -1244,7 +1243,7 @@ fn note_immutability_blame(&self,
|
||||
}
|
||||
}
|
||||
ty::BindByValue(..) => {
|
||||
if let (Some(local_ty), is_implicit_self) = self.local_ty(node_id) {
|
||||
if let (Some(local_ty), is_implicit_self) = self.local_ty(hir_id) {
|
||||
if let Some(msg) =
|
||||
self.suggest_mut_for_immutable(local_ty, is_implicit_self) {
|
||||
db.span_label(local_ty.span, msg);
|
||||
@@ -1273,12 +1272,12 @@ fn note_immutability_blame(&self,
|
||||
// not a mutable reference) or to avoid borrowing altogether
|
||||
fn note_immutable_local(&self,
|
||||
db: &mut DiagnosticBuilder<'_>,
|
||||
borrowed_node_id: ast::NodeId,
|
||||
binding_node_id: ast::NodeId) {
|
||||
let let_span = self.tcx.hir().span(binding_node_id);
|
||||
if let ty::BindByValue(..) = self.local_binding_mode(binding_node_id) {
|
||||
borrowed_hir_id: hir::HirId,
|
||||
binding_hir_id: hir::HirId) {
|
||||
let let_span = self.tcx.hir().span_by_hir_id(binding_hir_id);
|
||||
if let ty::BindByValue(..) = self.local_binding_mode(binding_hir_id) {
|
||||
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(let_span) {
|
||||
let (ty, is_implicit_self) = self.local_ty(binding_node_id);
|
||||
let (ty, is_implicit_self) = self.local_ty(binding_hir_id);
|
||||
if is_implicit_self && snippet != "self" {
|
||||
// avoid suggesting `mut &self`.
|
||||
return
|
||||
@@ -1291,9 +1290,9 @@ fn note_immutable_local(&self,
|
||||
},
|
||||
)) = ty.map(|t| &t.node)
|
||||
{
|
||||
let borrow_expr_id = self.tcx.hir().get_parent_node(borrowed_node_id);
|
||||
let borrow_expr_id = self.tcx.hir().get_parent_node_by_hir_id(borrowed_hir_id);
|
||||
db.span_suggestion(
|
||||
self.tcx.hir().span(borrow_expr_id),
|
||||
self.tcx.hir().span_by_hir_id(borrow_expr_id),
|
||||
"consider removing the `&mut`, as it is an \
|
||||
immutable binding to a mutable reference",
|
||||
snippet,
|
||||
@@ -1373,7 +1372,7 @@ fn note_and_explain_mutbl_error(&self, db: &mut DiagnosticBuilder<'_>, err: &Bck
|
||||
if let Categorization::Deref(..) = err.cmt.cat {
|
||||
db.span_label(*error_span, "cannot borrow as mutable");
|
||||
} else if let Categorization::Local(local_id) = err.cmt.cat {
|
||||
let span = self.tcx.hir().span(local_id);
|
||||
let span = self.tcx.hir().span_by_hir_id(local_id);
|
||||
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) {
|
||||
if snippet.starts_with("ref mut ") || snippet.starts_with("&mut ") {
|
||||
db.span_label(*error_span, "cannot reborrow mutably");
|
||||
@@ -1401,7 +1400,7 @@ pub fn append_loan_path_to_string(&self,
|
||||
out.push_str(&self.tcx.hir().name_by_hir_id(id).as_str());
|
||||
}
|
||||
LpVar(id) => {
|
||||
out.push_str(&self.tcx.hir().name(id).as_str());
|
||||
out.push_str(&self.tcx.hir().name_by_hir_id(id).as_str());
|
||||
}
|
||||
|
||||
LpDowncast(ref lp_base, variant_def_id) => {
|
||||
@@ -1512,7 +1511,7 @@ impl<'tcx> fmt::Debug for LoanPath<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self.kind {
|
||||
LpVar(id) => {
|
||||
write!(f, "$({})", ty::tls::with(|tcx| tcx.hir().node_to_string(id)))
|
||||
write!(f, "$({})", ty::tls::with(|tcx| tcx.hir().hir_to_string(id)))
|
||||
}
|
||||
|
||||
LpUpvar(ty::UpvarId{ var_path: ty::UpvarPath {hir_id: var_id}, closure_expr_id }) => {
|
||||
@@ -1547,7 +1546,7 @@ impl<'tcx> fmt::Display for LoanPath<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self.kind {
|
||||
LpVar(id) => {
|
||||
write!(f, "$({})", ty::tls::with(|tcx| tcx.hir().node_to_user_string(id)))
|
||||
write!(f, "$({})", ty::tls::with(|tcx| tcx.hir().hir_to_user_string(id)))
|
||||
}
|
||||
|
||||
LpUpvar(ty::UpvarId{ var_path: ty::UpvarPath { hir_id }, closure_expr_id: _ }) => {
|
||||
|
||||
@@ -69,7 +69,7 @@ fn reachable_non_generics_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
|
||||
let mut reachable_non_generics: DefIdMap<_> = tcx.reachable_set(LOCAL_CRATE).0
|
||||
.iter()
|
||||
.filter_map(|&node_id| {
|
||||
.filter_map(|&hir_id| {
|
||||
// We want to ignore some FFI functions that are not exposed from
|
||||
// this crate. Reachable FFI functions can be lumped into two
|
||||
// categories:
|
||||
@@ -83,9 +83,9 @@ fn reachable_non_generics_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
//
|
||||
// As a result, if this id is an FFI item (foreign item) then we only
|
||||
// let it through if it's included statically.
|
||||
match tcx.hir().get(node_id) {
|
||||
match tcx.hir().get_by_hir_id(hir_id) {
|
||||
Node::ForeignItem(..) => {
|
||||
let def_id = tcx.hir().local_def_id(node_id);
|
||||
let def_id = tcx.hir().local_def_id_from_hir_id(hir_id);
|
||||
if tcx.is_statically_included_foreign_item(def_id) {
|
||||
Some(def_id)
|
||||
} else {
|
||||
@@ -105,7 +105,7 @@ fn reachable_non_generics_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
node: hir::ImplItemKind::Method(..),
|
||||
..
|
||||
}) => {
|
||||
let def_id = tcx.hir().local_def_id(node_id);
|
||||
let def_id = tcx.hir().local_def_id_from_hir_id(hir_id);
|
||||
let generics = tcx.generics_of(def_id);
|
||||
if !generics.requires_monomorphization(tcx) &&
|
||||
// Functions marked with #[inline] are only ever codegened
|
||||
@@ -343,8 +343,8 @@ fn upstream_monomorphizations_for_provider<'a, 'tcx>(
|
||||
}
|
||||
|
||||
fn is_unreachable_local_definition_provider(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> bool {
|
||||
if let Some(node_id) = tcx.hir().as_local_node_id(def_id) {
|
||||
!tcx.reachable_set(LOCAL_CRATE).0.contains(&node_id)
|
||||
if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) {
|
||||
!tcx.reachable_set(LOCAL_CRATE).0.contains(&hir_id)
|
||||
} else {
|
||||
bug!("is_unreachable_local_definition called with non-local DefId: {:?}",
|
||||
def_id)
|
||||
|
||||
@@ -408,8 +408,8 @@ fn post(&self, s: &mut pprust_hir::State, node: pprust_hir::AnnNode) -> io::Resu
|
||||
pprust_hir::AnnNode::Name(_) => Ok(()),
|
||||
pprust_hir::AnnNode::Item(item) => {
|
||||
s.s.space()?;
|
||||
s.synth_comment(format!("node_id: {} hir local_id: {}",
|
||||
item.id, item.hir_id.local_id.as_u32()))
|
||||
s.synth_comment(format!("hir_id: {} hir local_id: {}",
|
||||
item.hir_id, item.hir_id.local_id.as_u32()))
|
||||
}
|
||||
pprust_hir::AnnNode::SubItem(id) => {
|
||||
s.s.space()?;
|
||||
@@ -428,8 +428,8 @@ fn post(&self, s: &mut pprust_hir::State, node: pprust_hir::AnnNode) -> io::Resu
|
||||
}
|
||||
pprust_hir::AnnNode::Pat(pat) => {
|
||||
s.s.space()?;
|
||||
s.synth_comment(format!("pat node_id: {} hir local_id: {}",
|
||||
pat.id, pat.hir_id.local_id.as_u32()))
|
||||
s.synth_comment(format!("pat hir_id: {} hir local_id: {}",
|
||||
pat.hir_id, pat.hir_id.local_id.as_u32()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ pub fn create_simple_region_hierarchy(&mut self) {
|
||||
}
|
||||
|
||||
#[allow(dead_code)] // this seems like it could be useful, even if we don't use it now
|
||||
pub fn lookup_item(&self, names: &[String]) -> ast::NodeId {
|
||||
pub fn lookup_item(&self, names: &[String]) -> hir::HirId {
|
||||
return match search_mod(self, &self.infcx.tcx.hir().krate().module, 0, names) {
|
||||
Some(id) => id,
|
||||
None => {
|
||||
@@ -262,7 +262,7 @@ fn search_mod(
|
||||
m: &hir::Mod,
|
||||
idx: usize,
|
||||
names: &[String],
|
||||
) -> Option<ast::NodeId> {
|
||||
) -> Option<hir::HirId> {
|
||||
assert!(idx < names.len());
|
||||
for item in &m.item_ids {
|
||||
let item = this.infcx.tcx.hir().expect_item(item.id);
|
||||
@@ -273,9 +273,9 @@ fn search_mod(
|
||||
return None;
|
||||
}
|
||||
|
||||
fn search(this: &Env, it: &hir::Item, idx: usize, names: &[String]) -> Option<ast::NodeId> {
|
||||
fn search(this: &Env, it: &hir::Item, idx: usize, names: &[String]) -> Option<hir::HirId> {
|
||||
if idx == names.len() {
|
||||
return Some(it.id);
|
||||
return Some(it.hir_id);
|
||||
}
|
||||
|
||||
return match it.node {
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
use rustc::hir;
|
||||
use rustc::ty::TyCtxt;
|
||||
use rustc::ty::query::Providers;
|
||||
use syntax::ast;
|
||||
use syntax::attr;
|
||||
|
||||
pub fn find<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) -> Option<DefId> {
|
||||
@@ -19,17 +18,17 @@ fn proc_macro_decls_static<'tcx>(
|
||||
let mut finder = Finder { decls: None };
|
||||
tcx.hir().krate().visit_all_item_likes(&mut finder);
|
||||
|
||||
finder.decls.map(|id| tcx.hir().local_def_id(id))
|
||||
finder.decls.map(|id| tcx.hir().local_def_id_from_hir_id(id))
|
||||
}
|
||||
|
||||
struct Finder {
|
||||
decls: Option<ast::NodeId>,
|
||||
decls: Option<hir::HirId>,
|
||||
}
|
||||
|
||||
impl<'v> ItemLikeVisitor<'v> for Finder {
|
||||
fn visit_item(&mut self, item: &hir::Item) {
|
||||
if attr::contains_name(&item.attrs, "rustc_proc_macro_decls") {
|
||||
self.decls = Some(item.id);
|
||||
self.decls = Some(item.hir_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
use rustc::ty::{self, Ty};
|
||||
use rustc::{lint, util};
|
||||
use hir::Node;
|
||||
use util::nodemap::NodeSet;
|
||||
use util::nodemap::HirIdSet;
|
||||
use lint::{LateContext, LintContext, LintArray};
|
||||
use lint::{LintPass, LateLintPass, EarlyLintPass, EarlyContext};
|
||||
|
||||
@@ -137,7 +137,7 @@ fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
|
||||
hir::ItemKind::Enum(..) |
|
||||
hir::ItemKind::Struct(..) |
|
||||
hir::ItemKind::Union(..) => {
|
||||
let def_id = cx.tcx.hir().local_def_id(it.id);
|
||||
let def_id = cx.tcx.hir().local_def_id_from_hir_id(it.hir_id);
|
||||
self.check_heap_type(cx, it.span, cx.tcx.type_of(def_id))
|
||||
}
|
||||
_ => ()
|
||||
@@ -148,7 +148,7 @@ fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
|
||||
hir::ItemKind::Struct(ref struct_def, _) |
|
||||
hir::ItemKind::Union(ref struct_def, _) => {
|
||||
for struct_field in struct_def.fields() {
|
||||
let def_id = cx.tcx.hir().local_def_id(struct_field.id);
|
||||
let def_id = cx.tcx.hir().local_def_id_from_hir_id(struct_field.hir_id);
|
||||
self.check_heap_type(cx, struct_field.span,
|
||||
cx.tcx.type_of(def_id));
|
||||
}
|
||||
@@ -447,8 +447,7 @@ fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
|
||||
if let hir::VisibilityKind::Inherited = it.vis.node {
|
||||
self.private_traits.insert(it.hir_id);
|
||||
for trait_item_ref in trait_item_refs {
|
||||
let hir_id = cx.tcx.hir().node_to_hir_id(trait_item_ref.id.node_id);
|
||||
self.private_traits.insert(hir_id);
|
||||
self.private_traits.insert(trait_item_ref.id.hir_id);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -464,9 +463,7 @@ fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
|
||||
Some(Node::Item(item)) => {
|
||||
if let hir::VisibilityKind::Inherited = item.vis.node {
|
||||
for impl_item_ref in impl_item_refs {
|
||||
let hir_id = cx.tcx.hir().node_to_hir_id(
|
||||
impl_item_ref.id.node_id);
|
||||
self.private_traits.insert(hir_id);
|
||||
self.private_traits.insert(impl_item_ref.id.hir_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -560,7 +557,8 @@ fn get_lints(&self) -> LintArray {
|
||||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingCopyImplementations {
|
||||
fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) {
|
||||
if !cx.access_levels.is_reachable(item.id) {
|
||||
let node_id = cx.tcx.hir().hir_to_node_id(item.hir_id);
|
||||
if !cx.access_levels.is_reachable(node_id) {
|
||||
return;
|
||||
}
|
||||
let (def, ty) = match item.node {
|
||||
@@ -568,21 +566,21 @@ fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) {
|
||||
if !ast_generics.params.is_empty() {
|
||||
return;
|
||||
}
|
||||
let def = cx.tcx.adt_def(cx.tcx.hir().local_def_id(item.id));
|
||||
let def = cx.tcx.adt_def(cx.tcx.hir().local_def_id_from_hir_id(item.hir_id));
|
||||
(def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[])))
|
||||
}
|
||||
hir::ItemKind::Union(_, ref ast_generics) => {
|
||||
if !ast_generics.params.is_empty() {
|
||||
return;
|
||||
}
|
||||
let def = cx.tcx.adt_def(cx.tcx.hir().local_def_id(item.id));
|
||||
let def = cx.tcx.adt_def(cx.tcx.hir().local_def_id_from_hir_id(item.hir_id));
|
||||
(def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[])))
|
||||
}
|
||||
hir::ItemKind::Enum(_, ref ast_generics) => {
|
||||
if !ast_generics.params.is_empty() {
|
||||
return;
|
||||
}
|
||||
let def = cx.tcx.adt_def(cx.tcx.hir().local_def_id(item.id));
|
||||
let def = cx.tcx.adt_def(cx.tcx.hir().local_def_id_from_hir_id(item.hir_id));
|
||||
(def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[])))
|
||||
}
|
||||
_ => return,
|
||||
@@ -610,7 +608,7 @@ fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) {
|
||||
}
|
||||
|
||||
pub struct MissingDebugImplementations {
|
||||
impling_types: Option<NodeSet>,
|
||||
impling_types: Option<HirIdSet>,
|
||||
}
|
||||
|
||||
impl MissingDebugImplementations {
|
||||
@@ -631,7 +629,8 @@ fn get_lints(&self) -> LintArray {
|
||||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDebugImplementations {
|
||||
fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) {
|
||||
if !cx.access_levels.is_reachable(item.id) {
|
||||
let node_id = cx.tcx.hir().hir_to_node_id(item.hir_id);
|
||||
if !cx.access_levels.is_reachable(node_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -648,11 +647,11 @@ fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) {
|
||||
};
|
||||
|
||||
if self.impling_types.is_none() {
|
||||
let mut impls = NodeSet::default();
|
||||
let mut impls = HirIdSet::default();
|
||||
cx.tcx.for_each_impl(debug, |d| {
|
||||
if let Some(ty_def) = cx.tcx.type_of(d).ty_adt_def() {
|
||||
if let Some(node_id) = cx.tcx.hir().as_local_node_id(ty_def.did) {
|
||||
impls.insert(node_id);
|
||||
if let Some(hir_id) = cx.tcx.hir().as_local_hir_id(ty_def.did) {
|
||||
impls.insert(hir_id);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -661,7 +660,7 @@ fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) {
|
||||
debug!("{:?}", self.impling_types);
|
||||
}
|
||||
|
||||
if !self.impling_types.as_ref().unwrap().contains(&item.id) {
|
||||
if !self.impling_types.as_ref().unwrap().contains(&item.hir_id) {
|
||||
cx.span_lint(MISSING_DEBUG_IMPLEMENTATIONS,
|
||||
item.span,
|
||||
"type does not implement `fmt::Debug`; consider adding #[derive(Debug)] \
|
||||
@@ -858,7 +857,7 @@ fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
|
||||
_ => return,
|
||||
};
|
||||
|
||||
let def_id = cx.tcx.hir().local_def_id(it.id);
|
||||
let def_id = cx.tcx.hir().local_def_id_from_hir_id(it.hir_id);
|
||||
let prfn = match cx.tcx.extern_mod_stmt_cnum(def_id) {
|
||||
Some(cnum) => cx.tcx.plugin_registrar_fn(cnum),
|
||||
None => {
|
||||
@@ -1078,7 +1077,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnionsWithDropFields {
|
||||
fn check_item(&mut self, ctx: &LateContext<'_, '_>, item: &hir::Item) {
|
||||
if let hir::ItemKind::Union(ref vdata, _) = item.node {
|
||||
for field in vdata.fields() {
|
||||
let field_ty = ctx.tcx.type_of(ctx.tcx.hir().local_def_id(field.id));
|
||||
let field_ty = ctx.tcx.type_of(
|
||||
ctx.tcx.hir().local_def_id_from_hir_id(field.hir_id));
|
||||
if field_ty.needs_drop(ctx.tcx, ctx.param_env) {
|
||||
ctx.span_lint(UNIONS_WITH_DROP_FIELDS,
|
||||
field.span,
|
||||
@@ -1357,7 +1357,7 @@ fn check_item(
|
||||
|
||||
|
||||
if cx.tcx.features().trivial_bounds {
|
||||
let def_id = cx.tcx.hir().local_def_id(item.id);
|
||||
let def_id = cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
let predicates = cx.tcx.predicates_of(def_id);
|
||||
for &(predicate, span) in &predicates.predicates {
|
||||
let predicate_kind_name = match predicate {
|
||||
@@ -1497,14 +1497,14 @@ fn matches_ellipsis_pat(pat: &ast::Pat) -> Option<(&P<Expr>, &P<Expr>, Span)> {
|
||||
}
|
||||
|
||||
pub struct UnnameableTestItems {
|
||||
boundary: ast::NodeId, // NodeId of the item under which things are not nameable
|
||||
boundary: hir::HirId, // HirId of the item under which things are not nameable
|
||||
items_nameable: bool,
|
||||
}
|
||||
|
||||
impl UnnameableTestItems {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
boundary: ast::DUMMY_NODE_ID,
|
||||
boundary: hir::DUMMY_HIR_ID,
|
||||
items_nameable: true
|
||||
}
|
||||
}
|
||||
@@ -1526,7 +1526,7 @@ fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
|
||||
if let hir::ItemKind::Mod(..) = it.node {}
|
||||
else {
|
||||
self.items_nameable = false;
|
||||
self.boundary = it.id;
|
||||
self.boundary = it.hir_id;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -1541,7 +1541,7 @@ fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
|
||||
}
|
||||
|
||||
fn check_item_post(&mut self, _cx: &LateContext<'_, '_>, it: &hir::Item) {
|
||||
if !self.items_nameable && self.boundary == it.id {
|
||||
if !self.items_nameable && self.boundary == it.hir_id {
|
||||
self.items_nameable = true;
|
||||
}
|
||||
}
|
||||
@@ -1791,7 +1791,7 @@ fn consolidate_outlives_bound_spans(
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExplicitOutlivesRequirements {
|
||||
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
|
||||
let infer_static = cx.tcx.features().infer_static_outlives_requirements;
|
||||
let def_id = cx.tcx.hir().local_def_id(item.id);
|
||||
let def_id = cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
if let hir::ItemKind::Struct(_, ref generics) = item.node {
|
||||
let mut bound_count = 0;
|
||||
let mut lint_spans = Vec::new();
|
||||
|
||||
@@ -762,8 +762,8 @@ fn check_type_for_ffi_and_report_errors(&mut self, sp: Span, ty: Ty<'tcx>) {
|
||||
}
|
||||
}
|
||||
|
||||
fn check_foreign_fn(&mut self, id: ast::NodeId, decl: &hir::FnDecl) {
|
||||
let def_id = self.cx.tcx.hir().local_def_id(id);
|
||||
fn check_foreign_fn(&mut self, id: hir::HirId, decl: &hir::FnDecl) {
|
||||
let def_id = self.cx.tcx.hir().local_def_id_from_hir_id(id);
|
||||
let sig = self.cx.tcx.fn_sig(def_id);
|
||||
let sig = self.cx.tcx.erase_late_bound_regions(&sig);
|
||||
let inputs = if sig.c_variadic {
|
||||
@@ -786,8 +786,8 @@ fn check_foreign_fn(&mut self, id: ast::NodeId, decl: &hir::FnDecl) {
|
||||
}
|
||||
}
|
||||
|
||||
fn check_foreign_static(&mut self, id: ast::NodeId, span: Span) {
|
||||
let def_id = self.cx.tcx.hir().local_def_id(id);
|
||||
fn check_foreign_static(&mut self, id: hir::HirId, span: Span) {
|
||||
let def_id = self.cx.tcx.hir().local_def_id_from_hir_id(id);
|
||||
let ty = self.cx.tcx.type_of(def_id);
|
||||
self.check_type_for_ffi_and_report_errors(span, ty);
|
||||
}
|
||||
@@ -809,14 +809,14 @@ fn get_lints(&self) -> LintArray {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImproperCTypes {
|
||||
fn check_foreign_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::ForeignItem) {
|
||||
let mut vis = ImproperCTypesVisitor { cx };
|
||||
let abi = cx.tcx.hir().get_foreign_abi(it.id);
|
||||
let abi = cx.tcx.hir().get_foreign_abi_by_hir_id(it.hir_id);
|
||||
if abi != Abi::RustIntrinsic && abi != Abi::PlatformIntrinsic {
|
||||
match it.node {
|
||||
hir::ForeignItemKind::Fn(ref decl, _, _) => {
|
||||
vis.check_foreign_fn(it.id, decl);
|
||||
vis.check_foreign_fn(it.hir_id, decl);
|
||||
}
|
||||
hir::ForeignItemKind::Static(ref ty, _) => {
|
||||
vis.check_foreign_static(it.id, ty.span);
|
||||
vis.check_foreign_static(it.hir_id, ty.span);
|
||||
}
|
||||
hir::ForeignItemKind::Type => ()
|
||||
}
|
||||
@@ -839,7 +839,7 @@ fn get_lints(&self) -> LintArray {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for VariantSizeDifferences {
|
||||
fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
|
||||
if let hir::ItemKind::Enum(ref enum_definition, _) = it.node {
|
||||
let item_def_id = cx.tcx.hir().local_def_id(it.id);
|
||||
let item_def_id = cx.tcx.hir().local_def_id_from_hir_id(it.hir_id);
|
||||
let t = cx.tcx.type_of(item_def_id);
|
||||
let ty = cx.tcx.erase_regions(&t);
|
||||
match cx.layout_of(ty) {
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
use std::path::Path;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use std::u32;
|
||||
use syntax::ast::{self, CRATE_NODE_ID};
|
||||
use syntax::ast;
|
||||
use syntax::attr;
|
||||
use syntax::source_map::Spanned;
|
||||
use syntax::symbol::keywords;
|
||||
@@ -314,7 +314,7 @@ fn encode_info_for_items(&mut self) -> Index {
|
||||
let vis = Spanned { span: syntax_pos::DUMMY_SP, node: hir::VisibilityKind::Public };
|
||||
index.record(DefId::local(CRATE_DEF_INDEX),
|
||||
IsolatedEncoder::encode_info_for_mod,
|
||||
FromId(CRATE_NODE_ID, (&krate.module, &krate.attrs, &vis)));
|
||||
FromId(hir::CRATE_HIR_ID, (&krate.module, &krate.attrs, &vis)));
|
||||
let mut visitor = EncodeVisitor { index };
|
||||
krate.visit_all_item_likes(&mut visitor.as_deep_visitor());
|
||||
for macro_def in &krate.exported_macros {
|
||||
@@ -588,8 +588,8 @@ fn encode_enum_variant_info(&mut self,
|
||||
}
|
||||
};
|
||||
|
||||
let enum_id = tcx.hir().as_local_node_id(enum_did).unwrap();
|
||||
let enum_vis = &tcx.hir().expect_item(enum_id).vis;
|
||||
let enum_id = tcx.hir().as_local_hir_id(enum_did).unwrap();
|
||||
let enum_vis = &tcx.hir().expect_item_by_hir_id(enum_id).vis;
|
||||
|
||||
Entry {
|
||||
kind: EntryKind::Variant(self.lazy(&data)),
|
||||
@@ -624,7 +624,7 @@ fn encode_info_for_mod(&mut self,
|
||||
&hir::Visibility)>)
|
||||
-> Entry<'tcx> {
|
||||
let tcx = self.tcx;
|
||||
let def_id = tcx.hir().local_def_id(id);
|
||||
let def_id = tcx.hir().local_def_id_from_hir_id(id);
|
||||
debug!("IsolatedEncoder::encode_info_for_mod({:?})", def_id);
|
||||
|
||||
let data = ModData {
|
||||
@@ -714,8 +714,8 @@ fn encode_struct_ctor(&mut self, (adt_def_id, def_id): (DefId, DefId)) -> Entry<
|
||||
}
|
||||
};
|
||||
|
||||
let struct_id = tcx.hir().as_local_node_id(adt_def_id).unwrap();
|
||||
let struct_vis = &tcx.hir().expect_item(struct_id).vis;
|
||||
let struct_id = tcx.hir().as_local_hir_id(adt_def_id).unwrap();
|
||||
let struct_vis = &tcx.hir().expect_item_by_hir_id(struct_id).vis;
|
||||
let mut ctor_vis = ty::Visibility::from_hir(struct_vis, struct_id, tcx);
|
||||
for field in &variant.fields {
|
||||
if ctor_vis.is_at_least(field.vis, tcx) {
|
||||
@@ -1055,7 +1055,7 @@ fn encode_info_for_item(&mut self, (def_id, item): (DefId, &'tcx hir::Item)) ->
|
||||
EntryKind::Fn(self.lazy(&data))
|
||||
}
|
||||
hir::ItemKind::Mod(ref m) => {
|
||||
return self.encode_info_for_mod(FromId(item.id, (m, &item.attrs, &item.vis)));
|
||||
return self.encode_info_for_mod(FromId(item.hir_id, (m, &item.attrs, &item.vis)));
|
||||
}
|
||||
hir::ItemKind::ForeignMod(_) => EntryKind::ForeignMod,
|
||||
hir::ItemKind::GlobalAsm(..) => EntryKind::GlobalAsm,
|
||||
@@ -1069,7 +1069,7 @@ fn encode_info_for_item(&mut self, (def_id, item): (DefId, &'tcx hir::Item)) ->
|
||||
// for methods, write all the stuff get_trait_method
|
||||
// needs to know
|
||||
let struct_ctor = if !struct_def.is_struct() {
|
||||
Some(tcx.hir().local_def_id(struct_def.id()).index)
|
||||
Some(tcx.hir().local_def_id_from_hir_id(struct_def.hir_id()).index)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
@@ -1154,14 +1154,15 @@ fn encode_info_for_item(&mut self, (def_id, item): (DefId, &'tcx hir::Item)) ->
|
||||
|
||||
Entry {
|
||||
kind,
|
||||
visibility: self.lazy(&ty::Visibility::from_hir(&item.vis, item.id, tcx)),
|
||||
visibility: self.lazy(&ty::Visibility::from_hir(&item.vis, item.hir_id, tcx)),
|
||||
span: self.lazy(&item.span),
|
||||
attributes: self.encode_attributes(&item.attrs),
|
||||
children: match item.node {
|
||||
hir::ItemKind::ForeignMod(ref fm) => {
|
||||
self.lazy_seq(fm.items
|
||||
.iter()
|
||||
.map(|foreign_item| tcx.hir().local_def_id(foreign_item.id).index))
|
||||
.map(|foreign_item| tcx.hir().local_def_id_from_hir_id(
|
||||
foreign_item.hir_id).index))
|
||||
}
|
||||
hir::ItemKind::Enum(..) => {
|
||||
let def = self.tcx.adt_def(def_id);
|
||||
@@ -1609,7 +1610,7 @@ fn encode_info_for_foreign_item(&mut self,
|
||||
|
||||
Entry {
|
||||
kind,
|
||||
visibility: self.lazy(&ty::Visibility::from_hir(&nitem.vis, nitem.id, tcx)),
|
||||
visibility: self.lazy(&ty::Visibility::from_hir(&nitem.vis, nitem.hir_id, tcx)),
|
||||
span: self.lazy(&nitem.span),
|
||||
attributes: self.encode_attributes(&nitem.attrs),
|
||||
children: LazySeq::empty(),
|
||||
@@ -1645,7 +1646,7 @@ fn visit_expr(&mut self, ex: &'tcx hir::Expr) {
|
||||
}
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
intravisit::walk_item(self, item);
|
||||
let def_id = self.index.tcx.hir().local_def_id(item.id);
|
||||
let def_id = self.index.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
match item.node {
|
||||
hir::ItemKind::ExternCrate(_) |
|
||||
hir::ItemKind::Use(..) => (), // ignore these
|
||||
@@ -1655,7 +1656,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
}
|
||||
fn visit_foreign_item(&mut self, ni: &'tcx hir::ForeignItem) {
|
||||
intravisit::walk_foreign_item(self, ni);
|
||||
let def_id = self.index.tcx.hir().local_def_id(ni.id);
|
||||
let def_id = self.index.tcx.hir().local_def_id_from_hir_id(ni.hir_id);
|
||||
self.index.record(def_id,
|
||||
IsolatedEncoder::encode_info_for_foreign_item,
|
||||
(def_id, ni));
|
||||
@@ -1741,7 +1742,7 @@ fn encode_info_for_expr(&mut self, expr: &hir::Expr) {
|
||||
/// so it's easier to do that here then to wait until we would encounter
|
||||
/// normally in the visitor walk.
|
||||
fn encode_addl_info_for_item(&mut self, item: &hir::Item) {
|
||||
let def_id = self.tcx.hir().local_def_id(item.id);
|
||||
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
match item.node {
|
||||
hir::ItemKind::Static(..) |
|
||||
hir::ItemKind::Const(..) |
|
||||
@@ -1771,7 +1772,7 @@ fn encode_addl_info_for_item(&mut self, item: &hir::Item) {
|
||||
|
||||
// If the struct has a constructor, encode it.
|
||||
if !struct_def.is_struct() {
|
||||
let ctor_def_id = self.tcx.hir().local_def_id(struct_def.id());
|
||||
let ctor_def_id = self.tcx.hir().local_def_id_from_hir_id(struct_def.hir_id());
|
||||
self.record(ctor_def_id,
|
||||
IsolatedEncoder::encode_struct_ctor,
|
||||
(def_id, ctor_def_id));
|
||||
@@ -1806,7 +1807,7 @@ struct ImplVisitor<'a, 'tcx: 'a> {
|
||||
impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ImplVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, item: &hir::Item) {
|
||||
if let hir::ItemKind::Impl(..) = item.node {
|
||||
let impl_id = self.tcx.hir().local_def_id(item.id);
|
||||
let impl_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
if let Some(trait_ref) = self.tcx.impl_trait_ref(impl_id) {
|
||||
self.impls
|
||||
.entry(trait_ref.def_id)
|
||||
|
||||
@@ -25,11 +25,11 @@ fn visit_item(&mut self, it: &'tcx hir::Item) {
|
||||
};
|
||||
|
||||
let foreign_items = fm.items.iter()
|
||||
.map(|it| self.tcx.hir().local_def_id(it.id))
|
||||
.map(|it| self.tcx.hir().local_def_id_from_hir_id(it.hir_id))
|
||||
.collect();
|
||||
self.modules.push(ForeignModule {
|
||||
foreign_items,
|
||||
def_id: self.tcx.hir().local_def_id(it.id),
|
||||
def_id: self.tcx.hir().local_def_id_from_hir_id(it.hir_id),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -215,10 +215,10 @@ fn read(&self, _tcx: TyCtxt<'_, '_, '_>) {}
|
||||
/// HIR node that doesn't carry its own ID. This will allow an
|
||||
/// arbitrary `T` to be passed in, but register a read on the given
|
||||
/// `NodeId`.
|
||||
pub struct FromId<T>(pub ast::NodeId, pub T);
|
||||
pub struct FromId<T>(pub hir::HirId, pub T);
|
||||
|
||||
impl<T> DepGraphRead for FromId<T> {
|
||||
fn read(&self, tcx: TyCtxt<'_, '_, '_>) {
|
||||
tcx.hir().read(self.0);
|
||||
tcx.hir().read_by_hir_id(self.0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ fn visit_item(&mut self, it: &'tcx hir::Item) {
|
||||
name: None,
|
||||
kind: cstore::NativeUnknown,
|
||||
cfg: None,
|
||||
foreign_module: Some(self.tcx.hir().local_def_id(it.id)),
|
||||
foreign_module: Some(self.tcx.hir().local_def_id_from_hir_id(it.hir_id)),
|
||||
wasm_import_module: None,
|
||||
};
|
||||
let mut kind_specified = false;
|
||||
|
||||
@@ -229,7 +229,7 @@ fn create_constructor_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
-> Mir<'tcx>
|
||||
{
|
||||
let span = tcx.hir().span(ctor_id);
|
||||
if let hir::VariantData::Tuple(ref fields, ctor_id, _) = *v {
|
||||
if let hir::VariantData::Tuple(ref fields, ctor_id) = *v {
|
||||
tcx.infer_ctxt().enter(|infcx| {
|
||||
let mut mir = shim::build_adt_ctor(&infcx, ctor_id, fields, span);
|
||||
|
||||
@@ -245,7 +245,7 @@ fn create_constructor_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
};
|
||||
|
||||
mir_util::dump_mir(tcx, None, "mir_map", &0,
|
||||
MirSource::item(tcx.hir().local_def_id(ctor_id)),
|
||||
MirSource::item(tcx.hir().local_def_id_from_hir_id(ctor_id)),
|
||||
&mir, |_, _| Ok(()) );
|
||||
|
||||
mir
|
||||
|
||||
@@ -153,7 +153,7 @@ pub fn const_eval_literal(
|
||||
|
||||
pub fn pattern_from_hir(&mut self, p: &hir::Pat) -> Pattern<'tcx> {
|
||||
let tcx = self.tcx.global_tcx();
|
||||
let p = match tcx.hir().get(p.id) {
|
||||
let p = match tcx.hir().get_by_hir_id(p.hir_id) {
|
||||
Node::Pat(p) | Node::Binding(p) => p,
|
||||
node => bug!("pattern became {:?}", node)
|
||||
};
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
use smallvec::smallvec;
|
||||
use std::slice;
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::ptr::P;
|
||||
use syntax_pos::{Span, DUMMY_SP, MultiSpan};
|
||||
|
||||
@@ -241,7 +240,7 @@ fn check_match(
|
||||
}
|
||||
|
||||
fn check_irrefutable(&self, pat: &'tcx Pat, origin: &str) {
|
||||
let module = self.tcx.hir().get_module_parent(pat.id);
|
||||
let module = self.tcx.hir().get_module_parent_by_hir_id(pat.hir_id);
|
||||
MatchCheckCtxt::create_and_enter(self.tcx, self.param_env, module, |ref mut cx| {
|
||||
let mut patcx = PatternContext::new(self.tcx,
|
||||
self.param_env.and(self.identity_substs),
|
||||
@@ -586,7 +585,7 @@ fn borrow(&mut self,
|
||||
ty::ImmBorrow | ty::UniqueImmBorrow => {}
|
||||
}
|
||||
}
|
||||
fn decl_without_init(&mut self, _: ast::NodeId, _: Span) {}
|
||||
fn decl_without_init(&mut self, _: hir::HirId, _: Span) {}
|
||||
fn mutate(&mut self, _: hir::HirId, span: Span, _: &cmt_<'_>, mode: MutateMode) {
|
||||
match mode {
|
||||
MutateMode::JustWrite | MutateMode::WriteAndRead => {
|
||||
|
||||
@@ -952,7 +952,7 @@ fn visit_item(&mut self, item: &'v hir::Item) {
|
||||
hir::ItemKind::Union(_, ref generics) => {
|
||||
if generics.params.is_empty() {
|
||||
if self.mode == MonoItemCollectionMode::Eager {
|
||||
let def_id = self.tcx.hir().local_def_id(item.id);
|
||||
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
debug!("RootCollector: ADT drop-glue for {}",
|
||||
def_id_to_string(self.tcx, def_id));
|
||||
|
||||
@@ -964,11 +964,12 @@ fn visit_item(&mut self, item: &'v hir::Item) {
|
||||
hir::ItemKind::GlobalAsm(..) => {
|
||||
debug!("RootCollector: ItemKind::GlobalAsm({})",
|
||||
def_id_to_string(self.tcx,
|
||||
self.tcx.hir().local_def_id(item.id)));
|
||||
self.output.push(MonoItem::GlobalAsm(item.id));
|
||||
self.tcx.hir().local_def_id_from_hir_id(item.hir_id)));
|
||||
let node_id = self.tcx.hir().hir_to_node_id(item.hir_id);
|
||||
self.output.push(MonoItem::GlobalAsm(node_id));
|
||||
}
|
||||
hir::ItemKind::Static(..) => {
|
||||
let def_id = self.tcx.hir().local_def_id(item.id);
|
||||
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
debug!("RootCollector: ItemKind::Static({})",
|
||||
def_id_to_string(self.tcx, def_id));
|
||||
self.output.push(MonoItem::Static(def_id));
|
||||
@@ -978,7 +979,7 @@ fn visit_item(&mut self, item: &'v hir::Item) {
|
||||
// actually used somewhere. Just declaring them is insufficient.
|
||||
|
||||
// but even just declaring them must collect the items they refer to
|
||||
let def_id = self.tcx.hir().local_def_id(item.id);
|
||||
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
|
||||
let instance = Instance::mono(self.tcx, def_id);
|
||||
let cid = GlobalId {
|
||||
@@ -992,7 +993,7 @@ fn visit_item(&mut self, item: &'v hir::Item) {
|
||||
}
|
||||
}
|
||||
hir::ItemKind::Fn(..) => {
|
||||
let def_id = self.tcx.hir().local_def_id(item.id);
|
||||
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
self.push_if_root(def_id);
|
||||
}
|
||||
}
|
||||
@@ -1097,7 +1098,7 @@ fn create_mono_items_for_default_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
}
|
||||
}
|
||||
|
||||
let impl_def_id = tcx.hir().local_def_id(item.id);
|
||||
let impl_def_id = tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
|
||||
debug!("create_mono_items_for_default_impls(item={})",
|
||||
def_id_to_string(tcx, impl_def_id));
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
use rustc_data_structures::indexed_vec::{IndexVec, Idx};
|
||||
|
||||
use rustc_target::spec::abi::Abi;
|
||||
use syntax::ast;
|
||||
use syntax_pos::Span;
|
||||
|
||||
use std::fmt;
|
||||
@@ -855,14 +854,14 @@ fn build_call_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
}
|
||||
|
||||
pub fn build_adt_ctor<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a, 'gcx, 'tcx>,
|
||||
ctor_id: ast::NodeId,
|
||||
ctor_id: hir::HirId,
|
||||
fields: &[hir::StructField],
|
||||
span: Span)
|
||||
-> Mir<'tcx>
|
||||
{
|
||||
let tcx = infcx.tcx;
|
||||
let gcx = tcx.global_tcx();
|
||||
let def_id = tcx.hir().local_def_id(ctor_id);
|
||||
let def_id = tcx.hir().local_def_id_from_hir_id(ctor_id);
|
||||
let param_env = gcx.param_env(def_id);
|
||||
|
||||
// Normalize the sig.
|
||||
|
||||
@@ -80,8 +80,8 @@ fn visit_variant_data(&mut self,
|
||||
_: &'tcx hir::Generics,
|
||||
_: hir::HirId,
|
||||
_: Span) {
|
||||
if let hir::VariantData::Tuple(_, node_id, _) = *v {
|
||||
self.set.insert(self.tcx.hir().local_def_id(node_id));
|
||||
if let hir::VariantData::Tuple(_, hir_id) = *v {
|
||||
self.set.insert(self.tcx.hir().local_def_id_from_hir_id(hir_id));
|
||||
}
|
||||
intravisit::walk_struct_def(self, v)
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ struct VarianceTest<'a, 'tcx: 'a> {
|
||||
|
||||
impl<'a, 'tcx> ItemLikeVisitor<'tcx> for VarianceTest<'a, 'tcx> {
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
let item_def_id = self.tcx.hir().local_def_id(item.id);
|
||||
let item_def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
|
||||
if let ItemKind::Ty(..) = item.node {
|
||||
for attr in self.tcx.get_attrs(item_def_id).iter() {
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
use rustc::util::nodemap::{ItemLocalSet, HirIdSet};
|
||||
use rustc::hir;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use syntax::ast;
|
||||
use syntax_pos::{Span, DUMMY_SP};
|
||||
use log::debug;
|
||||
use Promotability::*;
|
||||
@@ -677,7 +676,7 @@ fn borrow(&mut self,
|
||||
}
|
||||
}
|
||||
|
||||
fn decl_without_init(&mut self, _id: ast::NodeId, _span: Span) {}
|
||||
fn decl_without_init(&mut self, _id: hir::HirId, _span: Span) {}
|
||||
fn mutate(&mut self,
|
||||
_assignment_id: hir::HirId,
|
||||
_assignment_span: Span,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
//! Used by `rustc` when compiling a plugin crate.
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::attr;
|
||||
use syntax_pos::Span;
|
||||
use rustc::hir::itemlikevisit::ItemLikeVisitor;
|
||||
@@ -10,7 +9,7 @@
|
||||
use rustc::ty::query::Providers;
|
||||
|
||||
struct RegistrarFinder {
|
||||
registrars: Vec<(ast::NodeId, Span)> ,
|
||||
registrars: Vec<(hir::HirId, Span)> ,
|
||||
}
|
||||
|
||||
impl<'v> ItemLikeVisitor<'v> for RegistrarFinder {
|
||||
@@ -18,7 +17,7 @@ fn visit_item(&mut self, item: &hir::Item) {
|
||||
if let hir::ItemKind::Fn(..) = item.node {
|
||||
if attr::contains_name(&item.attrs,
|
||||
"plugin_registrar") {
|
||||
self.registrars.push((item.id, item.span));
|
||||
self.registrars.push((item.hir_id, item.span));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,8 +46,8 @@ fn plugin_registrar_fn<'tcx>(
|
||||
match finder.registrars.len() {
|
||||
0 => None,
|
||||
1 => {
|
||||
let (node_id, _) = finder.registrars.pop().unwrap();
|
||||
Some(tcx.hir().local_def_id(node_id))
|
||||
let (hir_id, _) = finder.registrars.pop().unwrap();
|
||||
Some(tcx.hir().local_def_id_from_hir_id(hir_id))
|
||||
},
|
||||
_ => {
|
||||
let diagnostic = tcx.sess.diagnostic();
|
||||
|
||||
+100
-96
@@ -24,7 +24,7 @@
|
||||
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};
|
||||
use syntax::ast::Ident;
|
||||
use syntax::attr;
|
||||
use syntax::symbol::keywords;
|
||||
use syntax_pos::Span;
|
||||
@@ -220,16 +220,16 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool {
|
||||
|
||||
fn def_id_visibility<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
|
||||
-> (ty::Visibility, Span, &'static str) {
|
||||
match tcx.hir().as_local_node_id(def_id) {
|
||||
Some(node_id) => {
|
||||
let vis = match tcx.hir().get(node_id) {
|
||||
match tcx.hir().as_local_hir_id(def_id) {
|
||||
Some(hir_id) => {
|
||||
let vis = match tcx.hir().get_by_hir_id(hir_id) {
|
||||
Node::Item(item) => &item.vis,
|
||||
Node::ForeignItem(foreign_item) => &foreign_item.vis,
|
||||
Node::TraitItem(..) | Node::Variant(..) => {
|
||||
return def_id_visibility(tcx, tcx.hir().get_parent_did(node_id));
|
||||
return def_id_visibility(tcx, tcx.hir().get_parent_did_by_hir_id(hir_id));
|
||||
}
|
||||
Node::ImplItem(impl_item) => {
|
||||
match tcx.hir().get(tcx.hir().get_parent(node_id)) {
|
||||
match tcx.hir().get_by_hir_id(tcx.hir().get_parent_item(hir_id)) {
|
||||
Node::Item(item) => match &item.node {
|
||||
hir::ItemKind::Impl(.., None, _, _) => &impl_item.vis,
|
||||
hir::ItemKind::Impl(.., Some(trait_ref), _, _)
|
||||
@@ -240,16 +240,16 @@ fn def_id_visibility<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
|
||||
}
|
||||
}
|
||||
Node::StructCtor(vdata) => {
|
||||
let struct_node_id = tcx.hir().get_parent(node_id);
|
||||
let item = match tcx.hir().get(struct_node_id) {
|
||||
let struct_hir_id = tcx.hir().get_parent_item(hir_id);
|
||||
let item = match tcx.hir().get_by_hir_id(struct_hir_id) {
|
||||
Node::Item(item) => item,
|
||||
node => bug!("unexpected node kind: {:?}", node),
|
||||
};
|
||||
let (mut ctor_vis, mut span, mut descr) =
|
||||
(ty::Visibility::from_hir(&item.vis, struct_node_id, tcx),
|
||||
(ty::Visibility::from_hir(&item.vis, struct_hir_id, tcx),
|
||||
item.vis.span, item.vis.node.descr());
|
||||
for field in vdata.fields() {
|
||||
let field_vis = ty::Visibility::from_hir(&field.vis, node_id, tcx);
|
||||
let field_vis = ty::Visibility::from_hir(&field.vis, hir_id, tcx);
|
||||
if ctor_vis.is_at_least(field_vis, tcx) {
|
||||
ctor_vis = field_vis;
|
||||
span = field.vis.span;
|
||||
@@ -260,7 +260,7 @@ fn def_id_visibility<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
|
||||
// If the structure is marked as non_exhaustive then lower the
|
||||
// visibility to within the crate.
|
||||
if ctor_vis == ty::Visibility::Public {
|
||||
let adt_def = tcx.adt_def(tcx.hir().get_parent_did(node_id));
|
||||
let adt_def = tcx.adt_def(tcx.hir().get_parent_did_by_hir_id(hir_id));
|
||||
if adt_def.non_enum_variant().is_field_list_non_exhaustive() {
|
||||
ctor_vis = ty::Visibility::Restricted(DefId::local(CRATE_DEF_INDEX));
|
||||
span = attr::find_by_name(&item.attrs, "non_exhaustive").unwrap().span;
|
||||
@@ -277,7 +277,7 @@ fn def_id_visibility<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
|
||||
}
|
||||
node => bug!("unexpected node kind: {:?}", node)
|
||||
};
|
||||
(ty::Visibility::from_hir(vis, node_id, tcx), vis.span, vis.node.descr())
|
||||
(ty::Visibility::from_hir(vis, hir_id, tcx), vis.span, vis.node.descr())
|
||||
}
|
||||
None => {
|
||||
let vis = tcx.visibility(def_id);
|
||||
@@ -349,10 +349,10 @@ trait VisibilityLike: Sized {
|
||||
|
||||
// Returns an over-approximation (`skip_assoc_tys` = true) of visibility due to
|
||||
// associated types for which we can't determine visibility precisely.
|
||||
fn of_impl<'a, 'tcx>(node_id: ast::NodeId, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
fn of_impl<'a, 'tcx>(hir_id: hir::HirId, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
access_levels: &'a AccessLevels) -> Self {
|
||||
let mut find = FindMin { tcx, access_levels, min: Self::MAX };
|
||||
let def_id = tcx.hir().local_def_id(node_id);
|
||||
let def_id = tcx.hir().local_def_id_from_hir_id(hir_id);
|
||||
find.visit(tcx.type_of(def_id));
|
||||
if let Some(trait_ref) = tcx.impl_trait_ref(def_id) {
|
||||
find.visit_trait(trait_ref);
|
||||
@@ -409,16 +409,18 @@ struct ReachEverythingInTheInterfaceVisitor<'b, 'a: 'b, 'tcx: 'a> {
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> EmbargoVisitor<'a, 'tcx> {
|
||||
fn get(&self, id: ast::NodeId) -> Option<AccessLevel> {
|
||||
self.access_levels.map.get(&id).cloned()
|
||||
fn get(&self, id: hir::HirId) -> Option<AccessLevel> {
|
||||
let node_id = self.tcx.hir().hir_to_node_id(id);
|
||||
self.access_levels.map.get(&node_id).cloned()
|
||||
}
|
||||
|
||||
// Updates node level and returns the updated level.
|
||||
fn update(&mut self, id: ast::NodeId, level: Option<AccessLevel>) -> Option<AccessLevel> {
|
||||
fn update(&mut self, id: hir::HirId, level: Option<AccessLevel>) -> Option<AccessLevel> {
|
||||
let old_level = self.get(id);
|
||||
// Accessibility levels can only grow.
|
||||
if level > old_level {
|
||||
self.access_levels.map.insert(id, level.unwrap());
|
||||
let node_id = self.tcx.hir().hir_to_node_id(id);
|
||||
self.access_levels.map.insert(node_id, level.unwrap());
|
||||
self.changed = true;
|
||||
level
|
||||
} else {
|
||||
@@ -426,11 +428,11 @@ fn update(&mut self, id: ast::NodeId, level: Option<AccessLevel>) -> Option<Acce
|
||||
}
|
||||
}
|
||||
|
||||
fn reach(&mut self, item_id: ast::NodeId, access_level: Option<AccessLevel>)
|
||||
fn reach(&mut self, item_id: hir::HirId, access_level: Option<AccessLevel>)
|
||||
-> ReachEverythingInTheInterfaceVisitor<'_, 'a, 'tcx> {
|
||||
ReachEverythingInTheInterfaceVisitor {
|
||||
access_level: cmp::min(access_level, Some(AccessLevel::Reachable)),
|
||||
item_def_id: self.tcx.hir().local_def_id(item_id),
|
||||
item_def_id: self.tcx.hir().local_def_id_from_hir_id(item_id),
|
||||
ev: self,
|
||||
}
|
||||
}
|
||||
@@ -464,7 +466,7 @@ fn update_visibility_of_intermediate_use_statements(&mut self, segments: &[hir::
|
||||
let def_id = self.tcx.hir().local_def_id(item_id.id);
|
||||
if !self.tcx.hygienic_eq(segment.ident, item.ident, def_id) { continue; }
|
||||
if let hir::ItemKind::Use(..) = item.node {
|
||||
self.update(item.id, Some(AccessLevel::Exported));
|
||||
self.update(item.hir_id, Some(AccessLevel::Exported));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -483,7 +485,7 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
let inherited_item_level = match item.node {
|
||||
hir::ItemKind::Impl(..) =>
|
||||
Option::<AccessLevel>::of_impl(item.id, self.tcx, &self.access_levels),
|
||||
Option::<AccessLevel>::of_impl(item.hir_id, self.tcx, &self.access_levels),
|
||||
// Foreign modules inherit level from parents.
|
||||
hir::ItemKind::ForeignMod(..) => self.prev_level,
|
||||
// Other `pub` items inherit levels from parents.
|
||||
@@ -498,44 +500,44 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
};
|
||||
|
||||
// Update level of the item itself.
|
||||
let item_level = self.update(item.id, inherited_item_level);
|
||||
let item_level = self.update(item.hir_id, inherited_item_level);
|
||||
|
||||
// Update levels of nested things.
|
||||
match item.node {
|
||||
hir::ItemKind::Enum(ref def, _) => {
|
||||
for variant in &def.variants {
|
||||
let variant_level = self.update(variant.node.data.id(), item_level);
|
||||
let variant_level = self.update(variant.node.data.hir_id(), item_level);
|
||||
for field in variant.node.data.fields() {
|
||||
self.update(field.id, variant_level);
|
||||
self.update(field.hir_id, variant_level);
|
||||
}
|
||||
}
|
||||
}
|
||||
hir::ItemKind::Impl(.., ref trait_ref, _, ref impl_item_refs) => {
|
||||
for impl_item_ref in impl_item_refs {
|
||||
if trait_ref.is_some() || impl_item_ref.vis.node.is_pub() {
|
||||
self.update(impl_item_ref.id.node_id, item_level);
|
||||
self.update(impl_item_ref.id.hir_id, item_level);
|
||||
}
|
||||
}
|
||||
}
|
||||
hir::ItemKind::Trait(.., ref trait_item_refs) => {
|
||||
for trait_item_ref in trait_item_refs {
|
||||
self.update(trait_item_ref.id.node_id, item_level);
|
||||
self.update(trait_item_ref.id.hir_id, item_level);
|
||||
}
|
||||
}
|
||||
hir::ItemKind::Struct(ref def, _) | hir::ItemKind::Union(ref def, _) => {
|
||||
if !def.is_struct() {
|
||||
self.update(def.id(), item_level);
|
||||
self.update(def.hir_id(), item_level);
|
||||
}
|
||||
for field in def.fields() {
|
||||
if field.vis.node.is_pub() {
|
||||
self.update(field.id, item_level);
|
||||
self.update(field.hir_id, item_level);
|
||||
}
|
||||
}
|
||||
}
|
||||
hir::ItemKind::ForeignMod(ref foreign_mod) => {
|
||||
for foreign_item in &foreign_mod.items {
|
||||
if foreign_item.vis.node.is_pub() {
|
||||
self.update(foreign_item.id, item_level);
|
||||
self.update(foreign_item.hir_id, item_level);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -572,21 +574,21 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
// in the reachability pass (`middle/reachable.rs`). Types are marked as link-time
|
||||
// reachable if they are returned via `impl Trait`, even from private functions.
|
||||
let exist_level = cmp::max(item_level, Some(AccessLevel::ReachableFromImplTrait));
|
||||
self.reach(item.id, exist_level).generics().predicates().ty();
|
||||
self.reach(item.hir_id, exist_level).generics().predicates().ty();
|
||||
}
|
||||
// Visit everything.
|
||||
hir::ItemKind::Const(..) | hir::ItemKind::Static(..) |
|
||||
hir::ItemKind::Fn(..) | hir::ItemKind::Ty(..) => {
|
||||
if item_level.is_some() {
|
||||
self.reach(item.id, item_level).generics().predicates().ty();
|
||||
self.reach(item.hir_id, item_level).generics().predicates().ty();
|
||||
}
|
||||
}
|
||||
hir::ItemKind::Trait(.., ref trait_item_refs) => {
|
||||
if item_level.is_some() {
|
||||
self.reach(item.id, item_level).generics().predicates();
|
||||
self.reach(item.hir_id, item_level).generics().predicates();
|
||||
|
||||
for trait_item_ref in trait_item_refs {
|
||||
let mut reach = self.reach(trait_item_ref.id.node_id, item_level);
|
||||
let mut reach = self.reach(trait_item_ref.id.hir_id, item_level);
|
||||
reach.generics().predicates();
|
||||
|
||||
if trait_item_ref.kind == AssociatedItemKind::Type &&
|
||||
@@ -600,18 +602,18 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
}
|
||||
hir::ItemKind::TraitAlias(..) => {
|
||||
if item_level.is_some() {
|
||||
self.reach(item.id, item_level).generics().predicates();
|
||||
self.reach(item.hir_id, item_level).generics().predicates();
|
||||
}
|
||||
}
|
||||
// Visit everything except for private impl items.
|
||||
hir::ItemKind::Impl(.., ref impl_item_refs) => {
|
||||
if item_level.is_some() {
|
||||
self.reach(item.id, item_level).generics().predicates().ty().trait_ref();
|
||||
self.reach(item.hir_id, item_level).generics().predicates().ty().trait_ref();
|
||||
|
||||
for impl_item_ref in impl_item_refs {
|
||||
let impl_item_level = self.get(impl_item_ref.id.node_id);
|
||||
let impl_item_level = self.get(impl_item_ref.id.hir_id);
|
||||
if impl_item_level.is_some() {
|
||||
self.reach(impl_item_ref.id.node_id, impl_item_level)
|
||||
self.reach(impl_item_ref.id.hir_id, impl_item_level)
|
||||
.generics().predicates().ty();
|
||||
}
|
||||
}
|
||||
@@ -621,26 +623,26 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
// Visit everything, but enum variants have their own levels.
|
||||
hir::ItemKind::Enum(ref def, _) => {
|
||||
if item_level.is_some() {
|
||||
self.reach(item.id, item_level).generics().predicates();
|
||||
self.reach(item.hir_id, item_level).generics().predicates();
|
||||
}
|
||||
for variant in &def.variants {
|
||||
let variant_level = self.get(variant.node.data.id());
|
||||
let variant_level = self.get(variant.node.data.hir_id());
|
||||
if variant_level.is_some() {
|
||||
for field in variant.node.data.fields() {
|
||||
self.reach(field.id, variant_level).ty();
|
||||
self.reach(field.hir_id, variant_level).ty();
|
||||
}
|
||||
// Corner case: if the variant is reachable, but its
|
||||
// enum is not, make the enum reachable as well.
|
||||
self.update(item.id, variant_level);
|
||||
self.update(item.hir_id, variant_level);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Visit everything, but foreign items have their own levels.
|
||||
hir::ItemKind::ForeignMod(ref foreign_mod) => {
|
||||
for foreign_item in &foreign_mod.items {
|
||||
let foreign_item_level = self.get(foreign_item.id);
|
||||
let foreign_item_level = self.get(foreign_item.hir_id);
|
||||
if foreign_item_level.is_some() {
|
||||
self.reach(foreign_item.id, foreign_item_level)
|
||||
self.reach(foreign_item.hir_id, foreign_item_level)
|
||||
.generics().predicates().ty();
|
||||
}
|
||||
}
|
||||
@@ -649,11 +651,11 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
hir::ItemKind::Struct(ref struct_def, _) |
|
||||
hir::ItemKind::Union(ref struct_def, _) => {
|
||||
if item_level.is_some() {
|
||||
self.reach(item.id, item_level).generics().predicates();
|
||||
self.reach(item.hir_id, item_level).generics().predicates();
|
||||
for field in struct_def.fields() {
|
||||
let field_level = self.get(field.id);
|
||||
let field_level = self.get(field.hir_id);
|
||||
if field_level.is_some() {
|
||||
self.reach(field.id, field_level).ty();
|
||||
self.reach(field.hir_id, field_level).ty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -683,8 +685,8 @@ fn visit_mod(&mut self, m: &'tcx hir::Mod, _sp: Span, id: hir::HirId) {
|
||||
for export in exports.iter() {
|
||||
if export.vis == ty::Visibility::Public {
|
||||
if let Some(def_id) = export.def.opt_def_id() {
|
||||
if let Some(node_id) = self.tcx.hir().as_local_node_id(def_id) {
|
||||
self.update(node_id, Some(AccessLevel::Exported));
|
||||
if let Some(hir_id) = self.tcx.hir().as_local_hir_id(def_id) {
|
||||
self.update(hir_id, Some(AccessLevel::Exported));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -696,10 +698,8 @@ fn visit_mod(&mut self, m: &'tcx hir::Mod, _sp: Span, id: hir::HirId) {
|
||||
}
|
||||
|
||||
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(node_id, Some(AccessLevel::Public));
|
||||
self.update(md.hir_id, Some(AccessLevel::Public));
|
||||
return
|
||||
}
|
||||
|
||||
@@ -707,38 +707,39 @@ fn visit_macro_def(&mut self, md: &'tcx hir::MacroDef) {
|
||||
self.tcx,
|
||||
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 mut module_id = self.tcx.hir().as_local_hir_id(module_did).unwrap();
|
||||
let level = if md.vis.node.is_pub() { self.get(module_id) } else { None };
|
||||
let level = self.update(node_id, level);
|
||||
let level = self.update(md.hir_id, level);
|
||||
if level.is_none() {
|
||||
return
|
||||
}
|
||||
|
||||
loop {
|
||||
let module = if module_id == ast::CRATE_NODE_ID {
|
||||
let module = if module_id == hir::CRATE_HIR_ID {
|
||||
&self.tcx.hir().krate().module
|
||||
} else if let hir::ItemKind::Mod(ref module) =
|
||||
self.tcx.hir().expect_item(module_id).node {
|
||||
self.tcx.hir().expect_item_by_hir_id(module_id).node {
|
||||
module
|
||||
} else {
|
||||
unreachable!()
|
||||
};
|
||||
for id in &module.item_ids {
|
||||
self.update(id.id, level);
|
||||
let hir_id = self.tcx.hir().node_to_hir_id(id.id);
|
||||
self.update(hir_id, level);
|
||||
}
|
||||
let def_id = self.tcx.hir().local_def_id(module_id);
|
||||
let def_id = self.tcx.hir().local_def_id_from_hir_id(module_id);
|
||||
if let Some(exports) = self.tcx.module_exports(def_id) {
|
||||
for export in exports.iter() {
|
||||
if let Some(node_id) = self.tcx.hir().as_local_node_id(export.def.def_id()) {
|
||||
self.update(node_id, level);
|
||||
if let Some(hir_id) = self.tcx.hir().as_local_hir_id(export.def.def_id()) {
|
||||
self.update(hir_id, level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if module_id == ast::CRATE_NODE_ID {
|
||||
if module_id == hir::CRATE_HIR_ID {
|
||||
break
|
||||
}
|
||||
module_id = self.tcx.hir().get_parent_node(module_id);
|
||||
module_id = self.tcx.hir().get_parent_node_by_hir_id(module_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -779,8 +780,8 @@ fn trait_ref(&mut self) -> &mut Self {
|
||||
impl<'a, 'tcx> DefIdVisitor<'a, 'tcx> for ReachEverythingInTheInterfaceVisitor<'_, 'a, 'tcx> {
|
||||
fn tcx(&self) -> TyCtxt<'a, 'tcx, 'tcx> { self.ev.tcx }
|
||||
fn visit_def_id(&mut self, def_id: DefId, _kind: &str, _descr: &dyn fmt::Display) -> bool {
|
||||
if let Some(node_id) = self.ev.tcx.hir().as_local_node_id(def_id) {
|
||||
self.ev.update(node_id, self.access_level);
|
||||
if let Some(hir_id) = self.ev.tcx.hir().as_local_hir_id(def_id) {
|
||||
self.ev.update(hir_id, self.access_level);
|
||||
}
|
||||
false
|
||||
}
|
||||
@@ -796,7 +797,7 @@ fn visit_def_id(&mut self, def_id: DefId, _kind: &str, _descr: &dyn fmt::Display
|
||||
struct NamePrivacyVisitor<'a, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
tables: &'a ty::TypeckTables<'tcx>,
|
||||
current_item: ast::NodeId,
|
||||
current_item: hir::HirId,
|
||||
empty_tables: &'a ty::TypeckTables<'tcx>,
|
||||
}
|
||||
|
||||
@@ -808,7 +809,7 @@ fn check_field(&mut self,
|
||||
def: &'tcx ty::AdtDef, // definition of the struct or enum
|
||||
field: &'tcx ty::FieldDef) { // definition of the field
|
||||
let ident = Ident::new(keywords::Invalid.name(), use_ctxt);
|
||||
let current_hir = self.tcx.hir().node_to_hir_id(self.current_item);
|
||||
let current_hir = self.current_item;
|
||||
let def_id = self.tcx.adjust_ident(ident, def.did, current_hir).1;
|
||||
if !def.is_enum() && !field.vis.is_accessible_from(def_id, self.tcx) {
|
||||
struct_span_err!(self.tcx.sess, span, E0451, "field `{}` of {} `{}` is private",
|
||||
@@ -839,7 +840,7 @@ fn visit_nested_body(&mut self, body: hir::BodyId) {
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
let orig_current_item = mem::replace(&mut self.current_item, item.id);
|
||||
let orig_current_item = mem::replace(&mut self.current_item, item.hir_id);
|
||||
let orig_tables =
|
||||
mem::replace(&mut self.tables, item_tables(self.tcx, item.hir_id, self.empty_tables));
|
||||
intravisit::walk_item(self, item);
|
||||
@@ -1110,8 +1111,8 @@ fn visit_local(&mut self, local: &'tcx hir::Local) {
|
||||
|
||||
// Check types in item interfaces.
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
let orig_current_item =
|
||||
mem::replace(&mut self.current_item, self.tcx.hir().local_def_id(item.id));
|
||||
let orig_current_item = mem::replace(&mut self.current_item,
|
||||
self.tcx.hir().local_def_id_from_hir_id(item.hir_id));
|
||||
let orig_in_body = mem::replace(&mut self.in_body, false);
|
||||
let orig_tables =
|
||||
mem::replace(&mut self.tables, item_tables(self.tcx, item.hir_id, self.empty_tables));
|
||||
@@ -1190,10 +1191,11 @@ fn path_is_private_type(&self, path: &hir::Path) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
fn trait_is_public(&self, trait_id: ast::NodeId) -> bool {
|
||||
fn trait_is_public(&self, trait_id: hir::HirId) -> bool {
|
||||
// FIXME: this would preferably be using `exported_items`, but all
|
||||
// traits are exported currently (see `EmbargoVisitor.exported_trait`).
|
||||
self.access_levels.is_public(trait_id)
|
||||
let node_id = self.tcx.hir().hir_to_node_id(trait_id);
|
||||
self.access_levels.is_public(node_id)
|
||||
}
|
||||
|
||||
fn check_generic_bound(&mut self, bound: &hir::GenericBound) {
|
||||
@@ -1204,8 +1206,9 @@ fn check_generic_bound(&mut self, bound: &hir::GenericBound) {
|
||||
}
|
||||
}
|
||||
|
||||
fn item_is_public(&self, id: &ast::NodeId, vis: &hir::Visibility) -> bool {
|
||||
self.access_levels.is_reachable(*id) || vis.node.is_pub()
|
||||
fn item_is_public(&self, id: &hir::HirId, vis: &hir::Visibility) -> bool {
|
||||
let node_id = self.tcx.hir().hir_to_node_id(*id);
|
||||
self.access_levels.is_reachable(node_id) || vis.node.is_pub()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1253,7 +1256,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
hir::ItemKind::ForeignMod(_) => {}
|
||||
|
||||
hir::ItemKind::Trait(.., ref bounds, _) => {
|
||||
if !self.trait_is_public(item.id) {
|
||||
if !self.trait_is_public(item.hir_id) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1295,8 +1298,8 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
|tr| {
|
||||
let did = tr.path.def.def_id();
|
||||
|
||||
if let Some(node_id) = self.tcx.hir().as_local_node_id(did) {
|
||||
self.trait_is_public(node_id)
|
||||
if let Some(hir_id) = self.tcx.hir().as_local_hir_id(did) {
|
||||
self.trait_is_public(hir_id)
|
||||
} else {
|
||||
true // external traits must be public
|
||||
}
|
||||
@@ -1318,9 +1321,9 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
match impl_item.node {
|
||||
hir::ImplItemKind::Const(..) |
|
||||
hir::ImplItemKind::Method(..) => {
|
||||
let node_id = self.tcx.hir().hir_to_node_id(
|
||||
impl_item.hir_id);
|
||||
self.access_levels.is_reachable(node_id)
|
||||
self.access_levels.is_reachable(
|
||||
self.tcx.hir().hir_to_node_id(
|
||||
impl_item_ref.id.hir_id))
|
||||
}
|
||||
hir::ImplItemKind::Existential(..) |
|
||||
hir::ImplItemKind::Type(_) => false,
|
||||
@@ -1342,11 +1345,10 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
// don't erroneously report errors for private
|
||||
// types in private items.
|
||||
let impl_item = self.tcx.hir().impl_item(impl_item_ref.id);
|
||||
let node_id = self.tcx.hir().hir_to_node_id(impl_item.hir_id);
|
||||
match impl_item.node {
|
||||
hir::ImplItemKind::Const(..) |
|
||||
hir::ImplItemKind::Method(..)
|
||||
if self.item_is_public(&node_id, &impl_item.vis) =>
|
||||
if self.item_is_public(&impl_item.hir_id, &impl_item.vis) =>
|
||||
{
|
||||
intravisit::walk_impl_item(self, impl_item)
|
||||
}
|
||||
@@ -1387,7 +1389,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
// methods will be visible as `Public::foo`.
|
||||
let mut found_pub_static = false;
|
||||
for impl_item_ref in impl_item_refs {
|
||||
if self.item_is_public(&impl_item_ref.id.node_id, &impl_item_ref.vis) {
|
||||
if self.item_is_public(&impl_item_ref.id.hir_id, &impl_item_ref.vis) {
|
||||
let impl_item = self.tcx.hir().impl_item(impl_item_ref.id);
|
||||
match impl_item_ref.kind {
|
||||
AssociatedItemKind::Const => {
|
||||
@@ -1414,7 +1416,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
hir::ItemKind::Ty(..) => return,
|
||||
|
||||
// Not at all public, so we don't care.
|
||||
_ if !self.item_is_public(&item.id, &item.vis) => {
|
||||
_ if !self.item_is_public(&item.hir_id, &item.vis) => {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1450,7 +1452,8 @@ fn visit_generics(&mut self, generics: &'tcx hir::Generics) {
|
||||
}
|
||||
|
||||
fn visit_foreign_item(&mut self, item: &'tcx hir::ForeignItem) {
|
||||
if self.access_levels.is_reachable(item.id) {
|
||||
let node_id = self.tcx.hir().hir_to_node_id(item.hir_id);
|
||||
if self.access_levels.is_reachable(node_id) {
|
||||
intravisit::walk_foreign_item(self, item)
|
||||
}
|
||||
}
|
||||
@@ -1468,7 +1471,8 @@ fn visit_variant(&mut self,
|
||||
v: &'tcx hir::Variant,
|
||||
g: &'tcx hir::Generics,
|
||||
item_id: hir::HirId) {
|
||||
if self.access_levels.is_reachable(v.node.data.id()) {
|
||||
let node_id = self.tcx.hir().hir_to_node_id(v.node.data.hir_id());
|
||||
if self.access_levels.is_reachable(node_id) {
|
||||
self.in_variant = true;
|
||||
intravisit::walk_variant(self, v, g, item_id);
|
||||
self.in_variant = false;
|
||||
@@ -1671,7 +1675,7 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
let tcx = self.tcx;
|
||||
let item_visibility = ty::Visibility::from_hir(&item.vis, item.id, tcx);
|
||||
let item_visibility = ty::Visibility::from_hir(&item.vis, item.hir_id, tcx);
|
||||
|
||||
match item.node {
|
||||
// Crates are always public.
|
||||
@@ -1696,8 +1700,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
self.check(item.hir_id, item_visibility).generics().predicates();
|
||||
|
||||
for trait_item_ref in trait_item_refs {
|
||||
let hir_id = tcx.hir().node_to_hir_id(trait_item_ref.id.node_id);
|
||||
self.check_trait_or_impl_item(hir_id, trait_item_ref.kind,
|
||||
self.check_trait_or_impl_item(trait_item_ref.id.hir_id, trait_item_ref.kind,
|
||||
trait_item_ref.defaultness, item_visibility);
|
||||
}
|
||||
}
|
||||
@@ -1716,7 +1719,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
// Subitems of foreign modules have their own publicity.
|
||||
hir::ItemKind::ForeignMod(ref foreign_mod) => {
|
||||
for foreign_item in &foreign_mod.items {
|
||||
let vis = ty::Visibility::from_hir(&foreign_item.vis, item.id, tcx);
|
||||
let vis = ty::Visibility::from_hir(&foreign_item.vis, item.hir_id, tcx);
|
||||
self.check(foreign_item.hir_id, vis).generics().predicates().ty();
|
||||
}
|
||||
}
|
||||
@@ -1726,7 +1729,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
self.check(item.hir_id, item_visibility).generics().predicates();
|
||||
|
||||
for field in struct_def.fields() {
|
||||
let field_visibility = ty::Visibility::from_hir(&field.vis, item.id, tcx);
|
||||
let field_visibility = ty::Visibility::from_hir(&field.vis, item.hir_id, tcx);
|
||||
self.check(field.hir_id, min(item_visibility, field_visibility, tcx)).ty();
|
||||
}
|
||||
}
|
||||
@@ -1735,17 +1738,18 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
// A trait impl is public when both its type and its trait are public
|
||||
// Subitems of trait impls have inherited publicity.
|
||||
hir::ItemKind::Impl(.., ref trait_ref, _, ref impl_item_refs) => {
|
||||
let impl_vis = ty::Visibility::of_impl(item.id, tcx, &Default::default());
|
||||
let impl_vis = ty::Visibility::of_impl(item.hir_id, tcx, &Default::default());
|
||||
self.check(item.hir_id, impl_vis).generics().predicates();
|
||||
for impl_item_ref in impl_item_refs {
|
||||
let impl_item = tcx.hir().impl_item(impl_item_ref.id);
|
||||
let impl_item_vis = if trait_ref.is_none() {
|
||||
min(ty::Visibility::from_hir(&impl_item.vis, item.id, tcx), impl_vis, tcx)
|
||||
min(ty::Visibility::from_hir(&impl_item.vis, item.hir_id, tcx),
|
||||
impl_vis,
|
||||
tcx)
|
||||
} else {
|
||||
impl_vis
|
||||
};
|
||||
let hir_id = tcx.hir().node_to_hir_id(impl_item_ref.id.node_id);
|
||||
self.check_trait_or_impl_item(hir_id, impl_item_ref.kind,
|
||||
self.check_trait_or_impl_item(impl_item_ref.id.hir_id, impl_item_ref.kind,
|
||||
impl_item_ref.defaultness, impl_item_vis);
|
||||
}
|
||||
}
|
||||
@@ -1773,7 +1777,7 @@ fn check_mod_privacy<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, module_def_id: DefId) {
|
||||
let mut visitor = NamePrivacyVisitor {
|
||||
tcx,
|
||||
tables: &empty_tables,
|
||||
current_item: DUMMY_NODE_ID,
|
||||
current_item: hir::DUMMY_HIR_ID,
|
||||
empty_tables: &empty_tables,
|
||||
};
|
||||
let (module, span, node_id) = tcx.hir().get_module(module_def_id);
|
||||
@@ -1827,7 +1831,7 @@ fn privacy_access_levels<'tcx>(
|
||||
break
|
||||
}
|
||||
}
|
||||
visitor.update(ast::CRATE_NODE_ID, Some(AccessLevel::Public));
|
||||
visitor.update(hir::CRATE_HIR_ID, Some(AccessLevel::Public));
|
||||
|
||||
{
|
||||
let mut visitor = ObsoleteVisiblePrivateTypesVisitor {
|
||||
|
||||
@@ -760,11 +760,11 @@ fn compare_synthetic_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
.source_map()
|
||||
.span_to_snippet(trait_span)
|
||||
.ok()?;
|
||||
let trait_m = tcx.hir().as_local_node_id(trait_m.def_id)?;
|
||||
let trait_m = tcx.hir().trait_item(hir::TraitItemId { node_id: trait_m });
|
||||
let trait_m = tcx.hir().as_local_hir_id(trait_m.def_id)?;
|
||||
let trait_m = tcx.hir().trait_item(hir::TraitItemId { hir_id: trait_m });
|
||||
|
||||
let impl_m = tcx.hir().as_local_node_id(impl_m.def_id)?;
|
||||
let impl_m = tcx.hir().impl_item(hir::ImplItemId { node_id: impl_m });
|
||||
let impl_m = tcx.hir().as_local_hir_id(impl_m.def_id)?;
|
||||
let impl_m = tcx.hir().impl_item(hir::ImplItemId { hir_id: impl_m });
|
||||
|
||||
// in case there are no generics, take the spot between the function name
|
||||
// and the opening paren of the argument list
|
||||
@@ -805,8 +805,8 @@ fn compare_synthetic_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
(None, Some(hir::SyntheticTyParamKind::ImplTrait)) => {
|
||||
err.span_label(impl_span, "expected `impl Trait`, found generic parameter");
|
||||
(|| {
|
||||
let impl_m = tcx.hir().as_local_node_id(impl_m.def_id)?;
|
||||
let impl_m = tcx.hir().impl_item(hir::ImplItemId { node_id: impl_m });
|
||||
let impl_m = tcx.hir().as_local_hir_id(impl_m.def_id)?;
|
||||
let impl_m = tcx.hir().impl_item(hir::ImplItemId { hir_id: impl_m });
|
||||
let input_tys = match impl_m.node {
|
||||
hir::ImplItemKind::Method(ref sig, _) => &sig.decl.inputs,
|
||||
_ => unreachable!(),
|
||||
|
||||
@@ -22,7 +22,7 @@ fn equate_intrinsic_type<'a, 'tcx>(
|
||||
inputs: Vec<Ty<'tcx>>,
|
||||
output: Ty<'tcx>,
|
||||
) {
|
||||
let def_id = tcx.hir().local_def_id(it.id);
|
||||
let def_id = tcx.hir().local_def_id_from_hir_id(it.hir_id);
|
||||
|
||||
match it.node {
|
||||
hir::ForeignItemKind::Fn(..) => {}
|
||||
|
||||
@@ -732,7 +732,7 @@ struct Visitor<'a, 'tcx: 'a> {
|
||||
impl<'v, 'a, 'tcx> itemlikevisit::ItemLikeVisitor<'v> for Visitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, i: &'v hir::Item) {
|
||||
if let hir::ItemKind::Trait(..) = i.node {
|
||||
let def_id = self.map.local_def_id(i.id);
|
||||
let def_id = self.map.local_def_id_from_hir_id(i.hir_id);
|
||||
self.traits.push(def_id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1008,9 +1008,10 @@ fn visit_pat(&mut self, p: &'gcx hir::Pat) {
|
||||
if let PatKind::Binding(_, _, _, ident, _) = p.node {
|
||||
let var_ty = self.assign(p.span, p.hir_id, None);
|
||||
|
||||
let node_id = self.fcx.tcx.hir().hir_to_node_id(p.hir_id);
|
||||
if !self.fcx.tcx.features().unsized_locals {
|
||||
self.fcx.require_type_is_sized(var_ty, p.span,
|
||||
traits::VariableType(p.id));
|
||||
traits::VariableType(node_id));
|
||||
}
|
||||
|
||||
debug!("Pattern binding {} is assigned to {} with type {:?}",
|
||||
@@ -1289,9 +1290,9 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
|
||||
}
|
||||
|
||||
fn check_struct<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
id: ast::NodeId,
|
||||
id: hir::HirId,
|
||||
span: Span) {
|
||||
let def_id = tcx.hir().local_def_id(id);
|
||||
let def_id = tcx.hir().local_def_id_from_hir_id(id);
|
||||
let def = tcx.adt_def(def_id);
|
||||
def.destructor(tcx); // force the destructor to be evaluated
|
||||
check_representable(tcx, span, def_id);
|
||||
@@ -1305,9 +1306,9 @@ fn check_struct<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
}
|
||||
|
||||
fn check_union<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
id: ast::NodeId,
|
||||
id: hir::HirId,
|
||||
span: Span) {
|
||||
let def_id = tcx.hir().local_def_id(id);
|
||||
let def_id = tcx.hir().local_def_id_from_hir_id(id);
|
||||
let def = tcx.adt_def(def_id);
|
||||
def.destructor(tcx); // force the destructor to be evaluated
|
||||
check_representable(tcx, span, def_id);
|
||||
@@ -1338,28 +1339,28 @@ fn check_opaque<'a, 'tcx>(
|
||||
|
||||
pub fn check_item_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Item) {
|
||||
debug!(
|
||||
"check_item_type(it.id={}, it.name={})",
|
||||
it.id,
|
||||
tcx.item_path_str(tcx.hir().local_def_id(it.id))
|
||||
"check_item_type(it.hir_id={}, it.name={})",
|
||||
it.hir_id,
|
||||
tcx.item_path_str(tcx.hir().local_def_id_from_hir_id(it.hir_id))
|
||||
);
|
||||
let _indenter = indenter();
|
||||
match it.node {
|
||||
// Consts can play a role in type-checking, so they are included here.
|
||||
hir::ItemKind::Static(..) => {
|
||||
let def_id = tcx.hir().local_def_id(it.id);
|
||||
let def_id = tcx.hir().local_def_id_from_hir_id(it.hir_id);
|
||||
tcx.typeck_tables_of(def_id);
|
||||
maybe_check_static_with_link_section(tcx, def_id, it.span);
|
||||
}
|
||||
hir::ItemKind::Const(..) => {
|
||||
tcx.typeck_tables_of(tcx.hir().local_def_id(it.id));
|
||||
tcx.typeck_tables_of(tcx.hir().local_def_id_from_hir_id(it.hir_id));
|
||||
}
|
||||
hir::ItemKind::Enum(ref enum_definition, _) => {
|
||||
check_enum(tcx, it.span, &enum_definition.variants, it.id);
|
||||
check_enum(tcx, it.span, &enum_definition.variants, it.hir_id);
|
||||
}
|
||||
hir::ItemKind::Fn(..) => {} // entirely within check_item_body
|
||||
hir::ItemKind::Impl(.., ref impl_item_refs) => {
|
||||
debug!("ItemKind::Impl {} with id {}", it.ident, it.id);
|
||||
let impl_def_id = tcx.hir().local_def_id(it.id);
|
||||
debug!("ItemKind::Impl {} with id {}", it.ident, it.hir_id);
|
||||
let impl_def_id = tcx.hir().local_def_id_from_hir_id(it.hir_id);
|
||||
if let Some(impl_trait_ref) = tcx.impl_trait_ref(impl_def_id) {
|
||||
check_impl_items_against_trait(
|
||||
tcx,
|
||||
@@ -1373,23 +1374,23 @@ pub fn check_item_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Ite
|
||||
}
|
||||
}
|
||||
hir::ItemKind::Trait(..) => {
|
||||
let def_id = tcx.hir().local_def_id(it.id);
|
||||
let def_id = tcx.hir().local_def_id_from_hir_id(it.hir_id);
|
||||
check_on_unimplemented(tcx, def_id, it);
|
||||
}
|
||||
hir::ItemKind::Struct(..) => {
|
||||
check_struct(tcx, it.id, it.span);
|
||||
check_struct(tcx, it.hir_id, it.span);
|
||||
}
|
||||
hir::ItemKind::Union(..) => {
|
||||
check_union(tcx, it.id, it.span);
|
||||
check_union(tcx, it.hir_id, it.span);
|
||||
}
|
||||
hir::ItemKind::Existential(..) => {
|
||||
let def_id = tcx.hir().local_def_id(it.id);
|
||||
let def_id = tcx.hir().local_def_id_from_hir_id(it.hir_id);
|
||||
|
||||
let substs = InternalSubsts::identity_for_item(tcx, def_id);
|
||||
check_opaque(tcx, def_id, substs, it.span);
|
||||
}
|
||||
hir::ItemKind::Ty(..) => {
|
||||
let def_id = tcx.hir().local_def_id(it.id);
|
||||
let def_id = tcx.hir().local_def_id_from_hir_id(it.hir_id);
|
||||
let pty_ty = tcx.type_of(def_id);
|
||||
let generics = tcx.generics_of(def_id);
|
||||
check_bounds_are_used(tcx, &generics, pty_ty);
|
||||
@@ -1407,7 +1408,7 @@ pub fn check_item_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Ite
|
||||
}
|
||||
} else {
|
||||
for item in &m.items {
|
||||
let generics = tcx.generics_of(tcx.hir().local_def_id(item.id));
|
||||
let generics = tcx.generics_of(tcx.hir().local_def_id_from_hir_id(item.hir_id));
|
||||
if generics.params.len() - generics.own_counts().lifetimes != 0 {
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
@@ -1476,7 +1477,7 @@ fn maybe_check_static_with_link_section(tcx: TyCtxt<'_, '_, '_>, id: DefId, span
|
||||
fn check_on_unimplemented<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
trait_def_id: DefId,
|
||||
item: &hir::Item) {
|
||||
let item_def_id = tcx.hir().local_def_id(item.id);
|
||||
let item_def_id = tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
// an error would be reported if this fails.
|
||||
let _ = traits::OnUnimplementedDirective::of_item(tcx, trait_def_id, item_def_id);
|
||||
}
|
||||
@@ -1842,8 +1843,8 @@ fn check_transparent<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sp: Span, def_id: De
|
||||
pub fn check_enum<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
sp: Span,
|
||||
vs: &'tcx [hir::Variant],
|
||||
id: ast::NodeId) {
|
||||
let def_id = tcx.hir().local_def_id(id);
|
||||
id: hir::HirId) {
|
||||
let def_id = tcx.hir().local_def_id_from_hir_id(id);
|
||||
let def = tcx.adt_def(def_id);
|
||||
def.destructor(tcx); // force the destructor to be evaluated
|
||||
|
||||
|
||||
@@ -635,7 +635,7 @@ fn borrow(
|
||||
}
|
||||
}
|
||||
|
||||
fn decl_without_init(&mut self, _id: ast::NodeId, _span: Span) {}
|
||||
fn decl_without_init(&mut self, _id: hir::HirId, _span: Span) {}
|
||||
|
||||
fn mutate(
|
||||
&mut self,
|
||||
|
||||
@@ -241,7 +241,7 @@ fn check_type_defn<'a, 'tcx, F>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
{
|
||||
for_item(tcx, item).with_fcx(|fcx, fcx_tcx| {
|
||||
let variants = lookup_fields(fcx);
|
||||
let def_id = fcx.tcx.hir().local_def_id(item.id);
|
||||
let def_id = fcx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
let packed = fcx.tcx.adt_def(def_id).repr.packed();
|
||||
|
||||
for variant in &variants {
|
||||
@@ -302,9 +302,9 @@ fn check_type_defn<'a, 'tcx, F>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
}
|
||||
|
||||
fn check_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item: &hir::Item) {
|
||||
debug!("check_trait: {:?}", item.id);
|
||||
debug!("check_trait: {:?}", item.hir_id);
|
||||
|
||||
let trait_def_id = tcx.hir().local_def_id(item.id);
|
||||
let trait_def_id = tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
|
||||
let trait_def = tcx.trait_def(trait_def_id);
|
||||
if trait_def.is_marker {
|
||||
@@ -326,7 +326,7 @@ fn check_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item: &hir::Item) {
|
||||
|
||||
fn check_item_fn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item: &hir::Item) {
|
||||
for_item(tcx, item).with_fcx(|fcx, tcx| {
|
||||
let def_id = fcx.tcx.hir().local_def_id(item.id);
|
||||
let def_id = fcx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
let sig = fcx.tcx.fn_sig(def_id);
|
||||
let sig = fcx.normalize_associated_types_in(item.span, &sig);
|
||||
let mut implied_bounds = vec![];
|
||||
@@ -376,7 +376,7 @@ fn check_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
debug!("check_impl: {:?}", item);
|
||||
|
||||
for_item(tcx, item).with_fcx(|fcx, tcx| {
|
||||
let item_def_id = fcx.tcx.hir().local_def_id(item.id);
|
||||
let item_def_id = fcx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
|
||||
match *ast_trait_ref {
|
||||
Some(ref ast_trait_ref) => {
|
||||
@@ -887,7 +887,7 @@ fn check_variances_for_type_defn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
item: &hir::Item,
|
||||
hir_generics: &hir::Generics)
|
||||
{
|
||||
let item_def_id = tcx.hir().local_def_id(item.id);
|
||||
let item_def_id = tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
let ty = tcx.type_of(item_def_id);
|
||||
if tcx.has_error_field(ty) {
|
||||
return;
|
||||
@@ -1018,7 +1018,7 @@ pub fn new(tcx: TyCtxt<'a, 'gcx, 'gcx>)
|
||||
impl<'a, 'tcx> ItemLikeVisitor<'tcx> for CheckTypeWellFormedVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, i: &'tcx hir::Item) {
|
||||
debug!("visit_item: {:?}", i);
|
||||
let def_id = self.tcx.hir().local_def_id(i.id);
|
||||
let def_id = self.tcx.hir().local_def_id_from_hir_id(i.hir_id);
|
||||
self.tcx.ensure().check_item_well_formed(def_id);
|
||||
}
|
||||
|
||||
@@ -1050,7 +1050,7 @@ struct AdtField<'tcx> {
|
||||
impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
fn non_enum_variant(&self, struct_def: &hir::VariantData) -> AdtVariant<'tcx> {
|
||||
let fields = struct_def.fields().iter().map(|field| {
|
||||
let field_ty = self.tcx.type_of(self.tcx.hir().local_def_id(field.id));
|
||||
let field_ty = self.tcx.type_of(self.tcx.hir().local_def_id_from_hir_id(field.hir_id));
|
||||
let field_ty = self.normalize_associated_types_in(field.span,
|
||||
&field_ty);
|
||||
AdtField { ty: field_ty, span: field.span }
|
||||
|
||||
@@ -212,7 +212,7 @@ struct ExternCrateToLint {
|
||||
impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for CollectExternCrateVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, item: &hir::Item) {
|
||||
if let hir::ItemKind::ExternCrate(orig_name) = item.node {
|
||||
let extern_crate_def_id = self.tcx.hir().local_def_id(item.id);
|
||||
let extern_crate_def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
self.crates_to_lint.push(
|
||||
ExternCrateToLint {
|
||||
def_id: extern_crate_def_id,
|
||||
|
||||
@@ -85,7 +85,7 @@ fn visit_item(&mut self, item: &hir::Item) {
|
||||
_ => return
|
||||
};
|
||||
|
||||
let def_id = self.tcx.hir().local_def_id(item.id);
|
||||
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
let self_ty = self.tcx.type_of(def_id);
|
||||
let lang_items = self.tcx.lang_items();
|
||||
match self_ty.sty {
|
||||
@@ -288,7 +288,7 @@ fn check_def_id(&mut self, item: &hir::Item, def_id: DefId) {
|
||||
// Add the implementation to the mapping from implementation to base
|
||||
// type def ID, if there is a base type for this implementation and
|
||||
// the implementation does not have any associated traits.
|
||||
let impl_def_id = self.tcx.hir().local_def_id(item.id);
|
||||
let impl_def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
let mut rc_vec = self.impls_map.inherent_impls
|
||||
.entry(def_id)
|
||||
.or_default();
|
||||
|
||||
@@ -120,7 +120,7 @@ fn visit_item(&mut self, item: &'v hir::Item) {
|
||||
hir::ItemKind::Struct(..) |
|
||||
hir::ItemKind::Trait(..) |
|
||||
hir::ItemKind::Union(..) => {
|
||||
let type_def_id = self.tcx.hir().local_def_id(item.id);
|
||||
let type_def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
self.check_for_overlapping_inherent_impls(type_def_id);
|
||||
}
|
||||
_ => {}
|
||||
|
||||
@@ -22,11 +22,11 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OrphanChecker<'cx, 'tcx> {
|
||||
/// to prevent inundating the user with a bunch of similar error
|
||||
/// reports.
|
||||
fn visit_item(&mut self, item: &hir::Item) {
|
||||
let def_id = self.tcx.hir().local_def_id(item.id);
|
||||
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
// "Trait" impl
|
||||
if let hir::ItemKind::Impl(.., Some(_), _, _) = item.node {
|
||||
debug!("coherence2::orphan check: trait impl {}",
|
||||
self.tcx.hir().node_to_string(item.id));
|
||||
self.tcx.hir().hir_to_string(item.hir_id));
|
||||
let trait_ref = self.tcx.impl_trait_ref(def_id).unwrap();
|
||||
let trait_def_id = trait_ref.def_id;
|
||||
let cm = self.tcx.sess.source_map();
|
||||
|
||||
@@ -21,7 +21,8 @@ fn check_unsafety_coherence(&mut self,
|
||||
unsafety: hir::Unsafety,
|
||||
polarity: hir::ImplPolarity)
|
||||
{
|
||||
if let Some(trait_ref) = self.tcx.impl_trait_ref(self.tcx.hir().local_def_id(item.id)) {
|
||||
let local_did = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
if let Some(trait_ref) = self.tcx.impl_trait_ref(local_did) {
|
||||
let trait_def = self.tcx.trait_def(trait_ref.def_id);
|
||||
let unsafe_attr = impl_generics.and_then(|generics| {
|
||||
generics.params.iter().find(|p| p.pure_wrt_drop).map(|_| "may_dangle")
|
||||
|
||||
@@ -118,7 +118,7 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
convert_item(self.tcx, item.id);
|
||||
convert_item(self.tcx, item.hir_id);
|
||||
intravisit::walk_item(self, item);
|
||||
}
|
||||
|
||||
@@ -397,10 +397,10 @@ fn is_param<'a, 'tcx>(
|
||||
}
|
||||
}
|
||||
|
||||
fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) {
|
||||
let it = tcx.hir().expect_item(item_id);
|
||||
debug!("convert: item {} with id {}", it.ident, it.id);
|
||||
let def_id = tcx.hir().local_def_id(item_id);
|
||||
fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: hir::HirId) {
|
||||
let it = tcx.hir().expect_item_by_hir_id(item_id);
|
||||
debug!("convert: item {} with id {}", it.ident, it.hir_id);
|
||||
let def_id = tcx.hir().local_def_id_from_hir_id(item_id);
|
||||
match it.node {
|
||||
// These don't define types.
|
||||
hir::ItemKind::ExternCrate(_)
|
||||
@@ -409,7 +409,7 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) {
|
||||
| hir::ItemKind::GlobalAsm(_) => {}
|
||||
hir::ItemKind::ForeignMod(ref foreign_mod) => {
|
||||
for item in &foreign_mod.items {
|
||||
let def_id = tcx.hir().local_def_id(item.id);
|
||||
let def_id = tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
tcx.generics_of(def_id);
|
||||
tcx.type_of(def_id);
|
||||
tcx.predicates_of(def_id);
|
||||
@@ -447,14 +447,14 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) {
|
||||
tcx.predicates_of(def_id);
|
||||
|
||||
for f in struct_def.fields() {
|
||||
let def_id = tcx.hir().local_def_id(f.id);
|
||||
let def_id = tcx.hir().local_def_id_from_hir_id(f.hir_id);
|
||||
tcx.generics_of(def_id);
|
||||
tcx.type_of(def_id);
|
||||
tcx.predicates_of(def_id);
|
||||
}
|
||||
|
||||
if !struct_def.is_struct() {
|
||||
convert_variant_ctor(tcx, struct_def.id());
|
||||
convert_variant_ctor(tcx, struct_def.hir_id());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -510,8 +510,8 @@ fn convert_impl_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_item_id: hir::H
|
||||
}
|
||||
}
|
||||
|
||||
fn convert_variant_ctor<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ctor_id: ast::NodeId) {
|
||||
let def_id = tcx.hir().local_def_id(ctor_id);
|
||||
fn convert_variant_ctor<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ctor_id: hir::HirId) {
|
||||
let def_id = tcx.hir().local_def_id_from_hir_id(ctor_id);
|
||||
tcx.generics_of(def_id);
|
||||
tcx.type_of(def_id);
|
||||
tcx.predicates_of(def_id);
|
||||
@@ -555,7 +555,7 @@ fn convert_enum_variant_types<'a, 'tcx>(
|
||||
);
|
||||
|
||||
for f in variant.node.data.fields() {
|
||||
let def_id = tcx.hir().local_def_id(f.id);
|
||||
let def_id = tcx.hir().local_def_id_from_hir_id(f.hir_id);
|
||||
tcx.generics_of(def_id);
|
||||
tcx.type_of(def_id);
|
||||
tcx.predicates_of(def_id);
|
||||
@@ -563,7 +563,7 @@ fn convert_enum_variant_types<'a, 'tcx>(
|
||||
|
||||
// Convert the ctor, if any. This also registers the variant as
|
||||
// an item.
|
||||
convert_variant_ctor(tcx, variant.node.data.id());
|
||||
convert_variant_ctor(tcx, variant.node.data.hir_id());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -577,12 +577,12 @@ fn convert_variant<'a, 'tcx>(
|
||||
attribute_def_id: DefId
|
||||
) -> ty::VariantDef {
|
||||
let mut seen_fields: FxHashMap<ast::Ident, Span> = Default::default();
|
||||
let node_id = tcx.hir().as_local_node_id(did).unwrap();
|
||||
let hir_id = tcx.hir().as_local_hir_id(did).unwrap();
|
||||
let fields = def
|
||||
.fields()
|
||||
.iter()
|
||||
.map(|f| {
|
||||
let fid = tcx.hir().local_def_id(f.id);
|
||||
let fid = tcx.hir().local_def_id_from_hir_id(f.hir_id);
|
||||
let dup_span = seen_fields.get(&f.ident.modern()).cloned();
|
||||
if let Some(prev_span) = dup_span {
|
||||
struct_span_err!(
|
||||
@@ -601,7 +601,7 @@ fn convert_variant<'a, 'tcx>(
|
||||
ty::FieldDef {
|
||||
did: fid,
|
||||
ident: f.ident,
|
||||
vis: ty::Visibility::from_hir(&f.vis, node_id, tcx),
|
||||
vis: ty::Visibility::from_hir(&f.vis, hir_id, tcx),
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
@@ -634,7 +634,7 @@ fn adt_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::Ad
|
||||
def.variants
|
||||
.iter()
|
||||
.map(|v| {
|
||||
let did = tcx.hir().local_def_id(v.node.data.id());
|
||||
let did = tcx.hir().local_def_id_from_hir_id(v.node.data.hir_id());
|
||||
let discr = if let Some(ref e) = v.node.disr_expr {
|
||||
distance_from_explicit = 0;
|
||||
ty::VariantDiscr::Explicit(tcx.hir().local_def_id_from_hir_id(e.hir_id))
|
||||
@@ -652,7 +652,7 @@ fn adt_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::Ad
|
||||
ItemKind::Struct(ref def, _) => {
|
||||
// Use separate constructor id for unit/tuple structs and reuse did for braced structs.
|
||||
let ctor_id = if !def.is_struct() {
|
||||
Some(tcx.hir().local_def_id(def.id()))
|
||||
Some(tcx.hir().local_def_id_from_hir_id(def.hir_id()))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
@@ -937,12 +937,12 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty
|
||||
//
|
||||
// Something of a hack: use the node id for the trait, also as
|
||||
// the node id for the Self type parameter.
|
||||
let param_id = item.id;
|
||||
let param_id = item.hir_id;
|
||||
|
||||
opt_self = Some(ty::GenericParamDef {
|
||||
index: 0,
|
||||
name: keywords::SelfUpper.name().as_interned_str(),
|
||||
def_id: tcx.hir().local_def_id(param_id),
|
||||
def_id: tcx.hir().local_def_id_from_hir_id(param_id),
|
||||
pure_wrt_drop: false,
|
||||
kind: ty::GenericParamDefKind::Type {
|
||||
has_default: false,
|
||||
@@ -1477,7 +1477,7 @@ fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'thi
|
||||
intravisit::NestedVisitorMap::All(&self.tcx.hir())
|
||||
}
|
||||
fn visit_item(&mut self, it: &'tcx Item) {
|
||||
let def_id = self.tcx.hir().local_def_id(it.id);
|
||||
let def_id = self.tcx.hir().local_def_id_from_hir_id(it.hir_id);
|
||||
// the existential type itself or its children are not within its reveal scope
|
||||
if def_id != self.def_id {
|
||||
self.check(def_id);
|
||||
@@ -1577,7 +1577,7 @@ fn fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> ty::PolyFnSig
|
||||
let ty = tcx.type_of(tcx.hir().get_parent_did(node_id));
|
||||
let inputs = fields
|
||||
.iter()
|
||||
.map(|f| tcx.type_of(tcx.hir().local_def_id(f.id)));
|
||||
.map(|f| tcx.type_of(tcx.hir().local_def_id_from_hir_id(f.hir_id)));
|
||||
ty::Binder::bind(tcx.mk_fn_sig(
|
||||
inputs,
|
||||
ty,
|
||||
|
||||
@@ -79,7 +79,7 @@ struct ImplWfCheck<'a, 'tcx: 'a> {
|
||||
impl<'a, 'tcx> ItemLikeVisitor<'tcx> for ImplWfCheck<'a, 'tcx> {
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
if let hir::ItemKind::Impl(.., ref impl_item_refs) = item.node {
|
||||
let impl_def_id = self.tcx.hir().local_def_id(item.id);
|
||||
let impl_def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
enforce_impl_params_are_constrained(self.tcx,
|
||||
impl_def_id,
|
||||
impl_item_refs);
|
||||
@@ -108,7 +108,7 @@ fn enforce_impl_params_are_constrained<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
|
||||
// Disallow unconstrained lifetimes, but only if they appear in assoc types.
|
||||
let lifetimes_in_associated_types: FxHashSet<_> = impl_item_refs.iter()
|
||||
.map(|item_ref| tcx.hir().local_def_id(item_ref.id.node_id))
|
||||
.map(|item_ref| tcx.hir().local_def_id_from_hir_id(item_ref.id.hir_id))
|
||||
.filter(|&def_id| {
|
||||
let item = tcx.associated_item(def_id);
|
||||
item.kind == ty::AssociatedKind::Type && item.defaultness.has_value()
|
||||
|
||||
@@ -52,16 +52,16 @@ pub struct InferVisitor<'cx, 'tcx: 'cx> {
|
||||
|
||||
impl<'cx, 'tcx> ItemLikeVisitor<'tcx> for InferVisitor<'cx, 'tcx> {
|
||||
fn visit_item(&mut self, item: &hir::Item) {
|
||||
let item_did = self.tcx.hir().local_def_id(item.id);
|
||||
let item_did = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
|
||||
debug!("InferVisitor::visit_item(item={:?})", item_did);
|
||||
|
||||
let node_id = self
|
||||
let hir_id = self
|
||||
.tcx
|
||||
.hir()
|
||||
.as_local_node_id(item_did)
|
||||
.as_local_hir_id(item_did)
|
||||
.expect("expected local def-id");
|
||||
let item = match self.tcx.hir().get(node_id) {
|
||||
let item = match self.tcx.hir().get_by_hir_id(hir_id) {
|
||||
Node::Item(item) => item,
|
||||
_ => bug!(),
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@ struct OutlivesTest<'a, 'tcx: 'a> {
|
||||
|
||||
impl<'a, 'tcx> ItemLikeVisitor<'tcx> for OutlivesTest<'a, 'tcx> {
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
let item_def_id = self.tcx.hir().local_def_id(item.id);
|
||||
let item_def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
|
||||
// For unit testing: check for a special "rustc_outlives"
|
||||
// attribute and report an error with various results if found.
|
||||
|
||||
@@ -128,7 +128,7 @@ fn add_inferreds_for_item(&mut self, id: hir::HirId) {
|
||||
impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for TermsContext<'a, 'tcx> {
|
||||
fn visit_item(&mut self, item: &hir::Item) {
|
||||
debug!("add_inferreds for item {}",
|
||||
self.tcx.hir().node_to_string(item.id));
|
||||
self.tcx.hir().hir_to_string(item.hir_id));
|
||||
|
||||
match item.node {
|
||||
hir::ItemKind::Struct(ref struct_def, _) |
|
||||
|
||||
@@ -12,7 +12,7 @@ struct VarianceTest<'a, 'tcx: 'a> {
|
||||
|
||||
impl<'a, 'tcx> ItemLikeVisitor<'tcx> for VarianceTest<'a, 'tcx> {
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
let item_def_id = self.tcx.hir().local_def_id(item.id);
|
||||
let item_def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
|
||||
// For unit testing: check for a special "rustc_variance"
|
||||
// attribute and report an error with various results if found.
|
||||
|
||||
+23
-19
@@ -1725,7 +1725,7 @@ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
(self.generics.clean(cx), (&self.decl, self.body).clean(cx))
|
||||
});
|
||||
|
||||
let did = cx.tcx.hir().local_def_id(self.id);
|
||||
let did = cx.tcx.hir().local_def_id_from_hir_id(self.id);
|
||||
let constness = if cx.tcx.is_min_const_fn(did) {
|
||||
hir::Constness::Const
|
||||
} else {
|
||||
@@ -1932,7 +1932,7 @@ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
name: Some(self.name.clean(cx)),
|
||||
attrs: attrs,
|
||||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
@@ -1962,7 +1962,7 @@ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
name: Some(self.name.clean(cx)),
|
||||
attrs,
|
||||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
@@ -2913,14 +2913,16 @@ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Type {
|
||||
|
||||
impl Clean<Item> for hir::StructField {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
let local_did = cx.tcx.hir().local_def_id_from_hir_id(self.hir_id);
|
||||
|
||||
Item {
|
||||
name: Some(self.ident.name).clean(cx),
|
||||
attrs: self.attrs.clean(cx),
|
||||
source: self.span.clean(cx),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: get_stability(cx, cx.tcx.hir().local_def_id(self.id)),
|
||||
deprecation: get_deprecation(cx, cx.tcx.hir().local_def_id(self.id)),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
stability: get_stability(cx, local_did),
|
||||
deprecation: get_deprecation(cx, local_did),
|
||||
def_id: local_did,
|
||||
inner: StructFieldItem(self.ty.clean(cx)),
|
||||
}
|
||||
}
|
||||
@@ -2992,7 +2994,7 @@ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
name: Some(self.name.clean(cx)),
|
||||
attrs: self.attrs.clean(cx),
|
||||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
@@ -3012,7 +3014,7 @@ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
name: Some(self.name.clean(cx)),
|
||||
attrs: self.attrs.clean(cx),
|
||||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
@@ -3059,7 +3061,7 @@ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
name: Some(self.name.clean(cx)),
|
||||
attrs: self.attrs.clean(cx),
|
||||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
@@ -3086,7 +3088,7 @@ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
visibility: None,
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.def.id()),
|
||||
def_id: cx.tcx.hir().local_def_id_from_hir_id(self.def.hir_id()),
|
||||
inner: VariantItem(Variant {
|
||||
kind: self.def.clean(cx),
|
||||
}),
|
||||
@@ -3375,7 +3377,7 @@ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
name: Some(self.name.clean(cx)),
|
||||
attrs: self.attrs.clean(cx),
|
||||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id.clone()),
|
||||
def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
@@ -3399,7 +3401,7 @@ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
name: Some(self.name.clean(cx)),
|
||||
attrs: self.attrs.clean(cx),
|
||||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id.clone()),
|
||||
def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
@@ -3450,7 +3452,7 @@ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
name: Some(self.name.clean(cx)),
|
||||
attrs: self.attrs.clean(cx),
|
||||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
@@ -3475,7 +3477,7 @@ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
name: Some(self.name.clean(cx)),
|
||||
attrs: self.attrs.clean(cx),
|
||||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
@@ -3589,7 +3591,7 @@ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Vec<Item> {
|
||||
name: None,
|
||||
attrs: self.attrs.clean(cx),
|
||||
source: self.whence.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
@@ -3819,14 +3821,16 @@ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
}
|
||||
};
|
||||
|
||||
let local_did = cx.tcx.hir().local_def_id_from_hir_id(self.hir_id);
|
||||
|
||||
Item {
|
||||
name: Some(self.ident.clean(cx)),
|
||||
attrs: self.attrs.clean(cx),
|
||||
source: self.span.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
def_id: local_did,
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: get_stability(cx, cx.tcx.hir().local_def_id(self.id)),
|
||||
deprecation: get_deprecation(cx, cx.tcx.hir().local_def_id(self.id)),
|
||||
stability: get_stability(cx, local_did),
|
||||
deprecation: get_deprecation(cx, local_did),
|
||||
inner,
|
||||
}
|
||||
}
|
||||
@@ -4034,7 +4038,7 @@ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
visibility: Some(Public),
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
|
||||
inner: ProcMacroItem(ProcMacro {
|
||||
kind: self.kind,
|
||||
helpers: self.helpers.clean(cx),
|
||||
|
||||
+13
-13
@@ -89,7 +89,7 @@ pub struct Struct {
|
||||
pub vis: hir::Visibility,
|
||||
pub stab: Option<attr::Stability>,
|
||||
pub depr: Option<attr::Deprecation>,
|
||||
pub id: NodeId,
|
||||
pub id: hir::HirId,
|
||||
pub struct_type: StructType,
|
||||
pub name: Name,
|
||||
pub generics: hir::Generics,
|
||||
@@ -102,7 +102,7 @@ pub struct Union {
|
||||
pub vis: hir::Visibility,
|
||||
pub stab: Option<attr::Stability>,
|
||||
pub depr: Option<attr::Deprecation>,
|
||||
pub id: NodeId,
|
||||
pub id: hir::HirId,
|
||||
pub struct_type: StructType,
|
||||
pub name: Name,
|
||||
pub generics: hir::Generics,
|
||||
@@ -118,7 +118,7 @@ pub struct Enum {
|
||||
pub variants: hir::HirVec<Variant>,
|
||||
pub generics: hir::Generics,
|
||||
pub attrs: hir::HirVec<ast::Attribute>,
|
||||
pub id: NodeId,
|
||||
pub id: hir::HirId,
|
||||
pub whence: Span,
|
||||
pub name: Name,
|
||||
}
|
||||
@@ -135,7 +135,7 @@ pub struct Variant {
|
||||
pub struct Function {
|
||||
pub decl: hir::FnDecl,
|
||||
pub attrs: hir::HirVec<ast::Attribute>,
|
||||
pub id: NodeId,
|
||||
pub id: hir::HirId,
|
||||
pub name: Name,
|
||||
pub vis: hir::Visibility,
|
||||
pub stab: Option<attr::Stability>,
|
||||
@@ -150,7 +150,7 @@ pub struct Typedef {
|
||||
pub ty: P<hir::Ty>,
|
||||
pub gen: hir::Generics,
|
||||
pub name: Name,
|
||||
pub id: ast::NodeId,
|
||||
pub id: hir::HirId,
|
||||
pub attrs: hir::HirVec<ast::Attribute>,
|
||||
pub whence: Span,
|
||||
pub vis: hir::Visibility,
|
||||
@@ -161,7 +161,7 @@ pub struct Typedef {
|
||||
pub struct Existential {
|
||||
pub exist_ty: hir::ExistTy,
|
||||
pub name: Name,
|
||||
pub id: ast::NodeId,
|
||||
pub id: hir::HirId,
|
||||
pub attrs: hir::HirVec<ast::Attribute>,
|
||||
pub whence: Span,
|
||||
pub vis: hir::Visibility,
|
||||
@@ -179,7 +179,7 @@ pub struct Static {
|
||||
pub vis: hir::Visibility,
|
||||
pub stab: Option<attr::Stability>,
|
||||
pub depr: Option<attr::Deprecation>,
|
||||
pub id: ast::NodeId,
|
||||
pub id: hir::HirId,
|
||||
pub whence: Span,
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ pub struct Constant {
|
||||
pub vis: hir::Visibility,
|
||||
pub stab: Option<attr::Stability>,
|
||||
pub depr: Option<attr::Deprecation>,
|
||||
pub id: ast::NodeId,
|
||||
pub id: hir::HirId,
|
||||
pub whence: Span,
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ pub struct Trait {
|
||||
pub generics: hir::Generics,
|
||||
pub bounds: hir::HirVec<hir::GenericBound>,
|
||||
pub attrs: hir::HirVec<ast::Attribute>,
|
||||
pub id: ast::NodeId,
|
||||
pub id: hir::HirId,
|
||||
pub whence: Span,
|
||||
pub vis: hir::Visibility,
|
||||
pub stab: Option<attr::Stability>,
|
||||
@@ -215,7 +215,7 @@ pub struct TraitAlias {
|
||||
pub generics: hir::Generics,
|
||||
pub bounds: hir::HirVec<hir::GenericBound>,
|
||||
pub attrs: hir::HirVec<ast::Attribute>,
|
||||
pub id: ast::NodeId,
|
||||
pub id: hir::HirId,
|
||||
pub whence: Span,
|
||||
pub vis: hir::Visibility,
|
||||
pub stab: Option<attr::Stability>,
|
||||
@@ -236,7 +236,7 @@ pub struct Impl {
|
||||
pub vis: hir::Visibility,
|
||||
pub stab: Option<attr::Stability>,
|
||||
pub depr: Option<attr::Deprecation>,
|
||||
pub id: ast::NodeId,
|
||||
pub id: hir::HirId,
|
||||
}
|
||||
|
||||
// For Macro we store the DefId instead of the NodeId, since we also create
|
||||
@@ -263,7 +263,7 @@ pub struct ExternCrate {
|
||||
|
||||
pub struct Import {
|
||||
pub name: Name,
|
||||
pub id: NodeId,
|
||||
pub id: hir::HirId,
|
||||
pub vis: hir::Visibility,
|
||||
pub attrs: hir::HirVec<ast::Attribute>,
|
||||
pub path: hir::Path,
|
||||
@@ -273,7 +273,7 @@ pub struct Import {
|
||||
|
||||
pub struct ProcMacro {
|
||||
pub name: Name,
|
||||
pub id: NodeId,
|
||||
pub id: hir::HirId,
|
||||
pub kind: MacroKind,
|
||||
pub helpers: Vec<Name>,
|
||||
pub attrs: hir::HirVec<ast::Attribute>,
|
||||
|
||||
+19
-19
@@ -101,7 +101,7 @@ pub fn visit_variant_data(&mut self, item: &hir::Item,
|
||||
debug!("Visiting struct");
|
||||
let struct_type = struct_type_from_def(&*sd);
|
||||
Struct {
|
||||
id: item.id,
|
||||
id: item.hir_id,
|
||||
struct_type,
|
||||
name,
|
||||
vis: item.vis.clone(),
|
||||
@@ -120,7 +120,7 @@ pub fn visit_union_data(&mut self, item: &hir::Item,
|
||||
debug!("Visiting union");
|
||||
let struct_type = struct_type_from_def(&*sd);
|
||||
Union {
|
||||
id: item.id,
|
||||
id: item.hir_id,
|
||||
struct_type,
|
||||
name,
|
||||
vis: item.vis.clone(),
|
||||
@@ -152,7 +152,7 @@ pub fn visit_enum_def(&mut self, it: &hir::Item,
|
||||
depr: self.deprecation(it.hir_id),
|
||||
generics: params.clone(),
|
||||
attrs: it.attrs.clone(),
|
||||
id: it.id,
|
||||
id: it.hir_id,
|
||||
whence: it.span,
|
||||
}
|
||||
}
|
||||
@@ -202,7 +202,7 @@ pub fn visit_fn(&mut self, om: &mut Module, item: &hir::Item,
|
||||
|
||||
om.proc_macros.push(ProcMacro {
|
||||
name,
|
||||
id: item.id,
|
||||
id: item.hir_id,
|
||||
kind,
|
||||
helpers,
|
||||
attrs: item.attrs.clone(),
|
||||
@@ -213,7 +213,7 @@ pub fn visit_fn(&mut self, om: &mut Module, item: &hir::Item,
|
||||
}
|
||||
None => {
|
||||
om.fns.push(Function {
|
||||
id: item.id,
|
||||
id: item.hir_id,
|
||||
vis: item.vis.clone(),
|
||||
stab: self.stability(item.hir_id),
|
||||
depr: self.deprecation(item.hir_id),
|
||||
@@ -262,7 +262,7 @@ pub fn visit_mod_contents(&mut self, span: Span, attrs: hir::HirVec<ast::Attribu
|
||||
///
|
||||
/// Returns `true` if the target has been inlined.
|
||||
fn maybe_inline_local(&mut self,
|
||||
id: ast::NodeId,
|
||||
id: hir::HirId,
|
||||
def: Def,
|
||||
renamed: Option<ast::Ident>,
|
||||
glob: bool,
|
||||
@@ -291,7 +291,7 @@ fn inherits_doc_hidden(cx: &core::DocContext<'_, '_, '_>, mut node: ast::NodeId)
|
||||
return false;
|
||||
};
|
||||
|
||||
let use_attrs = tcx.hir().attrs(id);
|
||||
let use_attrs = tcx.hir().attrs_by_hir_id(id);
|
||||
// Don't inline `doc(hidden)` imports so they can be stripped at a later stage.
|
||||
let is_no_inline = use_attrs.lists("doc").has_word("no_inline") ||
|
||||
use_attrs.lists("doc").has_word("hidden");
|
||||
@@ -357,7 +357,7 @@ fn inherits_doc_hidden(cx: &core::DocContext<'_, '_, '_>, mut node: ast::NodeId)
|
||||
Node::ForeignItem(it) if !glob => {
|
||||
// Generate a fresh `extern {}` block if we want to inline a foreign item.
|
||||
om.foreigns.push(hir::ForeignMod {
|
||||
abi: tcx.hir().get_foreign_abi(it.id),
|
||||
abi: tcx.hir().get_foreign_abi_by_hir_id(it.hir_id),
|
||||
items: vec![hir::ForeignItem {
|
||||
ident: renamed.unwrap_or(it.ident),
|
||||
.. it.clone()
|
||||
@@ -381,7 +381,7 @@ pub fn visit_item(&mut self, item: &hir::Item,
|
||||
let ident = renamed.unwrap_or(item.ident);
|
||||
|
||||
if item.vis.node.is_pub() {
|
||||
let def_id = self.cx.tcx.hir().local_def_id(item.id);
|
||||
let def_id = self.cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
self.store_path(def_id);
|
||||
}
|
||||
|
||||
@@ -401,7 +401,7 @@ pub fn visit_item(&mut self, item: &hir::Item,
|
||||
_ if self.inlining && !item.vis.node.is_pub() => {}
|
||||
hir::ItemKind::GlobalAsm(..) => {}
|
||||
hir::ItemKind::ExternCrate(orig_name) => {
|
||||
let def_id = self.cx.tcx.hir().local_def_id(item.id);
|
||||
let def_id = self.cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
|
||||
om.extern_crates.push(ExternCrate {
|
||||
cnum: self.cx.tcx.extern_mod_stmt_cnum(def_id)
|
||||
.unwrap_or(LOCAL_CRATE),
|
||||
@@ -436,7 +436,7 @@ pub fn visit_item(&mut self, item: &hir::Item,
|
||||
}
|
||||
});
|
||||
let ident = if is_glob { None } else { Some(ident) };
|
||||
if self.maybe_inline_local(item.id,
|
||||
if self.maybe_inline_local(item.hir_id,
|
||||
path.def,
|
||||
ident,
|
||||
is_glob,
|
||||
@@ -448,7 +448,7 @@ pub fn visit_item(&mut self, item: &hir::Item,
|
||||
|
||||
om.imports.push(Import {
|
||||
name: ident.name,
|
||||
id: item.id,
|
||||
id: item.hir_id,
|
||||
vis: item.vis.clone(),
|
||||
attrs: item.attrs.clone(),
|
||||
path: (**path).clone(),
|
||||
@@ -477,7 +477,7 @@ pub fn visit_item(&mut self, item: &hir::Item,
|
||||
ty: ty.clone(),
|
||||
gen: gen.clone(),
|
||||
name: ident.name,
|
||||
id: item.id,
|
||||
id: item.hir_id,
|
||||
attrs: item.attrs.clone(),
|
||||
whence: item.span,
|
||||
vis: item.vis.clone(),
|
||||
@@ -490,7 +490,7 @@ pub fn visit_item(&mut self, item: &hir::Item,
|
||||
let t = Existential {
|
||||
exist_ty: exist_ty.clone(),
|
||||
name: ident.name,
|
||||
id: item.id,
|
||||
id: item.hir_id,
|
||||
attrs: item.attrs.clone(),
|
||||
whence: item.span,
|
||||
vis: item.vis.clone(),
|
||||
@@ -504,7 +504,7 @@ pub fn visit_item(&mut self, item: &hir::Item,
|
||||
type_: ty.clone(),
|
||||
mutability: mut_.clone(),
|
||||
expr: exp.clone(),
|
||||
id: item.id,
|
||||
id: item.hir_id,
|
||||
name: ident.name,
|
||||
attrs: item.attrs.clone(),
|
||||
whence: item.span,
|
||||
@@ -518,7 +518,7 @@ pub fn visit_item(&mut self, item: &hir::Item,
|
||||
let s = Constant {
|
||||
type_: ty.clone(),
|
||||
expr: exp.clone(),
|
||||
id: item.id,
|
||||
id: item.hir_id,
|
||||
name: ident.name,
|
||||
attrs: item.attrs.clone(),
|
||||
whence: item.span,
|
||||
@@ -539,7 +539,7 @@ pub fn visit_item(&mut self, item: &hir::Item,
|
||||
items,
|
||||
generics: gen.clone(),
|
||||
bounds: b.iter().cloned().collect(),
|
||||
id: item.id,
|
||||
id: item.hir_id,
|
||||
attrs: item.attrs.clone(),
|
||||
whence: item.span,
|
||||
vis: item.vis.clone(),
|
||||
@@ -553,7 +553,7 @@ pub fn visit_item(&mut self, item: &hir::Item,
|
||||
name: ident.name,
|
||||
generics: gen.clone(),
|
||||
bounds: b.iter().cloned().collect(),
|
||||
id: item.id,
|
||||
id: item.hir_id,
|
||||
attrs: item.attrs.clone(),
|
||||
whence: item.span,
|
||||
vis: item.vis.clone(),
|
||||
@@ -585,7 +585,7 @@ pub fn visit_item(&mut self, item: &hir::Item,
|
||||
for_: ty.clone(),
|
||||
items,
|
||||
attrs: item.attrs.clone(),
|
||||
id: item.id,
|
||||
id: item.hir_id,
|
||||
whence: item.span,
|
||||
vis: item.vis.clone(),
|
||||
stab: self.stability(item.hir_id),
|
||||
|
||||
Reference in New Issue
Block a user