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