Skip to content

Commit 2a65cbe

Browse files
committedMar 8, 2019
Auto merge of #58915 - ljedrz:deprecate_nodeid_methods, r=Zoxc
HirIdification: almost there The next iteration of HirIdification (#57578). Replaces a bunch of `NodeId` method calls (mostly `as_local_node_id`) with `HirId` ones. Removes `NodeId` from: - [x] `PathSegment` - [x] `PatKind` - [x] `Destination` (replaces it with `HirId`) In addition this PR also removes `Visitor::visit_def_mention`, which doesn't seem to be doing anything.
·
1.88.01.35.0
2 parents b58a006 + 24fad4c commit 2a65cbe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+438
-488
lines changed
 

‎src/librustc/cfg/construct.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -571,9 +571,9 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
571571
match destination.target_id {
572572
Ok(loop_id) => {
573573
for b in &self.breakable_block_scopes {
574-
if b.block_expr_id == self.tcx.hir().node_to_hir_id(loop_id).local_id {
574+
if b.block_expr_id == loop_id.local_id {
575575
let scope = region::Scope {
576-
id: self.tcx.hir().node_to_hir_id(loop_id).local_id,
576+
id: loop_id.local_id,
577577
data: region::ScopeData::Node
578578
};
579579
return (scope, match scope_cf_kind {
@@ -583,9 +583,9 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
583583
}
584584
}
585585
for l in &self.loop_scopes {
586-
if l.loop_id == self.tcx.hir().node_to_hir_id(loop_id).local_id {
586+
if l.loop_id == loop_id.local_id {
587587
let scope = region::Scope {
588-
id: self.tcx.hir().node_to_hir_id(loop_id).local_id,
588+
id: loop_id.local_id,
589589
data: region::ScopeData::Node
590590
};
591591
return (scope, match scope_cf_kind {

‎src/librustc/hir/intravisit.rs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
use syntax::ast::{Ident, Name, Attribute};
3535
use syntax_pos::Span;
3636
use crate::hir::*;
37-
use crate::hir::def::Def;
3837
use crate::hir::map::Map;
3938
use super::itemlikevisit::DeepVisitor;
4039

@@ -228,9 +227,6 @@ pub trait Visitor<'v> : Sized {
228227
fn visit_id(&mut self, _hir_id: HirId) {
229228
// Nothing to do.
230229
}
231-
fn visit_def_mention(&mut self, _def: Def) {
232-
// Nothing to do.
233-
}
234230
fn visit_name(&mut self, _span: Span, _name: Name) {
235231
// Nothing to do.
236232
}
@@ -494,13 +490,10 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
494490
visitor.visit_ty(typ);
495491
visitor.visit_generics(type_parameters)
496492
}
497-
ItemKind::Existential(ExistTy {ref generics, ref bounds, impl_trait_fn}) => {
493+
ItemKind::Existential(ExistTy { ref generics, ref bounds, impl_trait_fn: _ }) => {
498494
visitor.visit_id(item.hir_id);
499495
walk_generics(visitor, generics);
500496
walk_list!(visitor, visit_param_bound, bounds);
501-
if let Some(impl_trait_fn) = impl_trait_fn {
502-
visitor.visit_def_mention(Def::Fn(impl_trait_fn))
503-
}
504497
}
505498
ItemKind::Enum(ref enum_definition, ref type_parameters) => {
506499
visitor.visit_generics(type_parameters);
@@ -640,7 +633,6 @@ pub fn walk_qpath<'v, V: Visitor<'v>>(visitor: &mut V, qpath: &'v QPath, id: Hir
640633
}
641634

642635
pub fn walk_path<'v, V: Visitor<'v>>(visitor: &mut V, path: &'v Path) {
643-
visitor.visit_def_mention(path.def);
644636
for segment in &path.segments {
645637
visitor.visit_path_segment(path.span, segment);
646638
}
@@ -697,8 +689,7 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
697689
PatKind::Ref(ref subpattern, _) => {
698690
visitor.visit_pat(subpattern)
699691
}
700-
PatKind::Binding(_, canonical_id, _hir_id, ident, ref optional_subpattern) => {
701-
visitor.visit_def_mention(Def::Local(canonical_id));
692+
PatKind::Binding(_, _hir_id, ident, ref optional_subpattern) => {
702693
visitor.visit_ident(ident);
703694
walk_list!(visitor, visit_pat, optional_subpattern);
704695
}
@@ -1064,18 +1055,12 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
10641055
ExprKind::Break(ref destination, ref opt_expr) => {
10651056
if let Some(ref label) = destination.label {
10661057
visitor.visit_label(label);
1067-
if let Ok(node_id) = destination.target_id {
1068-
visitor.visit_def_mention(Def::Label(node_id))
1069-
}
10701058
}
10711059
walk_list!(visitor, visit_expr, opt_expr);
10721060
}
10731061
ExprKind::Continue(ref destination) => {
10741062
if let Some(ref label) = destination.label {
10751063
visitor.visit_label(label);
1076-
if let Ok(node_id) = destination.target_id {
1077-
visitor.visit_def_mention(Def::Label(node_id))
1078-
}
10791064
}
10801065
}
10811066
ExprKind::Ret(ref optional_expression) => {

0 commit comments

Comments
 (0)
Please sign in to comment.