Skip to content

Commit 558a07b

Browse files
committed
hir: remove NodeId from PatKind
1 parent 78f91e3 commit 558a07b

File tree

24 files changed

+48
-53
lines changed

24 files changed

+48
-53
lines changed

src/librustc/hir/intravisit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -697,8 +697,8 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
697697
PatKind::Ref(ref subpattern, _) => {
698698
visitor.visit_pat(subpattern)
699699
}
700-
PatKind::Binding(_, canonical_id, _hir_id, ident, ref optional_subpattern) => {
701-
visitor.visit_def_mention(Def::Local(canonical_id));
700+
PatKind::Binding(_, _hir_id, ident, ref optional_subpattern) => {
701+
// visitor.visit_def_mention(Def::Local(hir_id));
702702
visitor.visit_ident(ident);
703703
walk_list!(visitor, visit_pat, optional_subpattern);
704704
}

src/librustc/hir/lowering.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3679,11 +3679,10 @@ impl<'a> LoweringContext<'a> {
36793679
Some(Def::Local(id)) => id,
36803680
_ => p.id,
36813681
};
3682-
let hir_id = self.lower_node_id(canonical_id).hir_id;
3682+
36833683
hir::PatKind::Binding(
36843684
self.lower_binding_mode(binding_mode),
3685-
canonical_id,
3686-
hir_id,
3685+
self.lower_node_id(canonical_id).hir_id,
36873686
ident,
36883687
sub.as_ref().map(|x| self.lower_pat(x)),
36893688
)
@@ -4985,7 +4984,7 @@ impl<'a> LoweringContext<'a> {
49854984
(
49864985
P(hir::Pat {
49874986
hir_id,
4988-
node: hir::PatKind::Binding(bm, node_id, hir_id, ident.with_span_pos(span), None),
4987+
node: hir::PatKind::Binding(bm, hir_id, ident.with_span_pos(span), None),
49894988
span,
49904989
}),
49914990
node_id

src/librustc/hir/map/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ impl<'hir> Map<'hir> {
10161016
Node::Field(f) => f.ident.name,
10171017
Node::Lifetime(lt) => lt.name.ident().name,
10181018
Node::GenericParam(param) => param.name.ident().name,
1019-
Node::Binding(&Pat { node: PatKind::Binding(_, _, _, l, _), .. }) => l.name,
1019+
Node::Binding(&Pat { node: PatKind::Binding(_, _, l, _), .. }) => l.name,
10201020
Node::StructCtor(_) => self.name(self.get_parent(id)),
10211021
_ => bug!("no name for {}", self.node_to_string(id))
10221022
}

src/librustc/hir/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -936,10 +936,10 @@ pub enum PatKind {
936936
Wild,
937937

938938
/// A fresh binding `ref mut binding @ OPT_SUBPATTERN`.
939-
/// The `NodeId` is the canonical ID for the variable being bound,
939+
/// The `HirId` is the canonical ID for the variable being bound,
940940
/// (e.g., in `Ok(x) | Err(x)`, both `x` use the same canonical ID),
941941
/// which is the pattern ID of the first `x`.
942-
Binding(BindingAnnotation, NodeId, HirId, Ident, Option<P<Pat>>),
942+
Binding(BindingAnnotation, HirId, Ident, Option<P<Pat>>),
943943

944944
/// A struct or struct variant pattern (e.g., `Variant {x, y, ..}`).
945945
/// The `bool` is `true` in the presence of a `..`.

src/librustc/hir/pat_util.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl hir::Pat {
7070
where F: FnMut(hir::BindingAnnotation, HirId, Span, ast::Ident),
7171
{
7272
self.walk(|p| {
73-
if let PatKind::Binding(binding_mode, _, _, ident, _) = p.node {
73+
if let PatKind::Binding(binding_mode, _, ident, _) = p.node {
7474
f(binding_mode, p.hir_id, p.span, ident);
7575
}
7676
true
@@ -110,8 +110,8 @@ impl hir::Pat {
110110

111111
pub fn simple_ident(&self) -> Option<ast::Ident> {
112112
match self.node {
113-
PatKind::Binding(hir::BindingAnnotation::Unannotated, _, _, ident, None) |
114-
PatKind::Binding(hir::BindingAnnotation::Mutable, _, _, ident, None) => Some(ident),
113+
PatKind::Binding(hir::BindingAnnotation::Unannotated, _, ident, None) |
114+
PatKind::Binding(hir::BindingAnnotation::Mutable, _, ident, None) => Some(ident),
115115
_ => None,
116116
}
117117
}

src/librustc/hir/print.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1765,7 +1765,7 @@ impl<'a> State<'a> {
17651765
// is that it doesn't matter
17661766
match pat.node {
17671767
PatKind::Wild => self.s.word("_")?,
1768-
PatKind::Binding(binding_mode, _, _, ident, ref sub) => {
1768+
PatKind::Binding(binding_mode, _, ident, ref sub) => {
17691769
match binding_mode {
17701770
hir::BindingAnnotation::Ref => {
17711771
self.word_nbsp("ref")?;

src/librustc/ich/impls_hir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ impl_stable_hash_for!(enum hir::RangeEnd {
448448

449449
impl_stable_hash_for!(enum hir::PatKind {
450450
Wild,
451-
Binding(binding_mode, var, hir_id, name, sub),
451+
Binding(binding_mode, hir_id, name, sub),
452452
Struct(path, field_pats, dotdot),
453453
TupleStruct(path, field_pats, dotdot),
454454
Path(path),

src/librustc/middle/expr_use_visitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
860860

861861
// Each match binding is effectively an assignment to the
862862
// binding being produced.
863-
let def = Def::Local(canonical_id);
863+
let def = Def::Local(mc.tcx.hir().hir_to_node_id(canonical_id));
864864
if let Ok(ref binding_cmt) = mc.cat_def(pat.hir_id, pat.span, pat_ty, def) {
865865
delegate.mutate(pat.hir_id, pat.span, binding_cmt, MutateMode::Init);
866866
}

src/librustc/middle/liveness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ fn add_from_pat<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, pat: &P<hir::Pat>) {
407407
while let Some(pat) = pats.pop_front() {
408408
use crate::hir::PatKind::*;
409409
match pat.node {
410-
Binding(_, _, _, _, ref inner_pat) => {
410+
Binding(_, _, _, ref inner_pat) => {
411411
pats.extend(inner_pat.iter());
412412
}
413413
Struct(_, ref fields, _) => {

src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ pub fn gather_move_from_pat<'a, 'c, 'tcx: 'c>(bccx: &BorrowckCtxt<'a, 'tcx>,
9898
cmt: &'c mc::cmt_<'tcx>) {
9999
let source = get_pattern_source(bccx.tcx,move_pat);
100100
let pat_span_path_opt = match move_pat.node {
101-
PatKind::Binding(_, _, _, ident, _) => {
101+
PatKind::Binding(_, _, ident, _) => {
102102
Some(MovePlace {
103103
span: move_pat.span,
104104
name: ident.name,

0 commit comments

Comments
 (0)