Skip to content

Commit d287726

Browse files
authored
Rollup merge of #98639 - camsteffen:no-node-binding, r=compiler-errors
Factor out `hir::Node::Binding`
2 parents 9a6fa4f + ec82bc1 commit d287726

File tree

18 files changed

+22
-37
lines changed

18 files changed

+22
-37
lines changed

compiler/rustc_ast_lowering/src/index.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
192192
}
193193

194194
fn visit_pat(&mut self, pat: &'hir Pat<'hir>) {
195-
let node =
196-
if let PatKind::Binding(..) = pat.kind { Node::Binding(pat) } else { Node::Pat(pat) };
197-
self.insert(pat.span, pat.hir_id, node);
195+
self.insert(pat.span, pat.hir_id, Node::Pat(pat));
198196

199197
self.with_parent(pat.hir_id, |this| {
200198
intravisit::walk_pat(this, pat);

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
362362

363363
let upvar_hir_id = captured_place.get_root_variable();
364364

365-
if let Some(Node::Binding(pat)) = self.infcx.tcx.hir().find(upvar_hir_id)
365+
if let Some(Node::Pat(pat)) = self.infcx.tcx.hir().find(upvar_hir_id)
366366
&& let hir::PatKind::Binding(
367367
hir::BindingAnnotation::Unannotated,
368368
_,

compiler/rustc_const_eval/src/interpret/validity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
244244
// for a generator).
245245
let var_hir_id = captured_place.get_root_variable();
246246
let node = self.ecx.tcx.hir().get(var_hir_id);
247-
if let hir::Node::Binding(pat) = node {
247+
if let hir::Node::Pat(pat) = node {
248248
if let hir::PatKind::Binding(_, _, ident, _) = pat.kind {
249249
name = Some(ident.name);
250250
}

compiler/rustc_hir/src/hir.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3326,7 +3326,6 @@ pub enum Node<'hir> {
33263326
Ty(&'hir Ty<'hir>),
33273327
TypeBinding(&'hir TypeBinding<'hir>),
33283328
TraitRef(&'hir TraitRef<'hir>),
3329-
Binding(&'hir Pat<'hir>),
33303329
Pat(&'hir Pat<'hir>),
33313330
Arm(&'hir Arm<'hir>),
33323331
Block(&'hir Block<'hir>),
@@ -3378,7 +3377,6 @@ impl<'hir> Node<'hir> {
33783377
| Node::Block(..)
33793378
| Node::Ctor(..)
33803379
| Node::Pat(..)
3381-
| Node::Binding(..)
33823380
| Node::Arm(..)
33833381
| Node::Local(..)
33843382
| Node::Crate(..)

compiler/rustc_hir_pretty/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl<'a> State<'a> {
8787
Node::Ty(a) => self.print_type(&a),
8888
Node::TypeBinding(a) => self.print_type_binding(&a),
8989
Node::TraitRef(a) => self.print_trait_ref(&a),
90-
Node::Binding(a) | Node::Pat(a) => self.print_pat(&a),
90+
Node::Pat(a) => self.print_pat(&a),
9191
Node::Arm(a) => self.print_arm(&a),
9292
Node::Infer(_) => self.word("_"),
9393
Node::Block(a) => {

compiler/rustc_middle/src/hir/map/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ impl<'hir> Map<'hir> {
302302
| Node::Infer(_)
303303
| Node::TraitRef(_)
304304
| Node::Pat(_)
305-
| Node::Binding(_)
306305
| Node::Local(_)
307306
| Node::Param(_)
308307
| Node::Arm(_)
@@ -901,7 +900,7 @@ impl<'hir> Map<'hir> {
901900
#[inline]
902901
fn opt_ident(self, id: HirId) -> Option<Ident> {
903902
match self.get(id) {
904-
Node::Binding(&Pat { kind: PatKind::Binding(_, _, ident, _), .. }) => Some(ident),
903+
Node::Pat(&Pat { kind: PatKind::Binding(_, _, ident, _), .. }) => Some(ident),
905904
// A `Ctor` doesn't have an identifier itself, but its parent
906905
// struct/variant does. Compare with `hir::Map::opt_span`.
907906
Node::Ctor(..) => match self.find(self.get_parent_node(id))? {
@@ -1046,7 +1045,6 @@ impl<'hir> Map<'hir> {
10461045
Node::Ty(ty) => ty.span,
10471046
Node::TypeBinding(tb) => tb.span,
10481047
Node::TraitRef(tr) => tr.path.span,
1049-
Node::Binding(pat) => pat.span,
10501048
Node::Pat(pat) => pat.span,
10511049
Node::Arm(arm) => arm.span,
10521050
Node::Block(block) => block.span,
@@ -1263,7 +1261,6 @@ fn hir_id_to_string(map: Map<'_>, id: HirId) -> String {
12631261
Some(Node::Ty(_)) => node_str("type"),
12641262
Some(Node::TypeBinding(_)) => node_str("type binding"),
12651263
Some(Node::TraitRef(_)) => node_str("trait ref"),
1266-
Some(Node::Binding(_)) => node_str("local"),
12671264
Some(Node::Pat(_)) => node_str("pat"),
12681265
Some(Node::Param(_)) => node_str("param"),
12691266
Some(Node::Arm(_)) => node_str("arm"),

compiler/rustc_mir_build/src/build/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
997997
continue;
998998
};
999999
let pat = match tcx.hir().get(arg.pat.hir_id) {
1000-
Node::Pat(pat) | Node::Binding(pat) => pat,
1000+
Node::Pat(pat) => pat,
10011001
node => bug!("pattern became {:?}", node),
10021002
};
10031003
let pattern = pat_from_hir(tcx, self.param_env, self.typeck_results, pat);

compiler/rustc_mir_build/src/thir/cx/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl<'tcx> Cx<'tcx> {
8080
#[tracing::instrument(level = "debug", skip(self))]
8181
pub(crate) fn pattern_from_hir(&mut self, p: &hir::Pat<'_>) -> Pat<'tcx> {
8282
let p = match self.tcx.hir().get(p.hir_id) {
83-
Node::Pat(p) | Node::Binding(p) => p,
83+
Node::Pat(p) => p,
8484
node => bug!("pattern became {:?}", node),
8585
};
8686
pat_from_hir(self.tcx, self.param_env, self.typeck_results(), p)

compiler/rustc_save_analysis/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -623,9 +623,9 @@ impl<'tcx> SaveContext<'tcx> {
623623
}
624624
},
625625

626-
Node::Binding(&hir::Pat {
627-
kind: hir::PatKind::Binding(_, canonical_id, ..), ..
628-
}) => Res::Local(canonical_id),
626+
Node::Pat(&hir::Pat { kind: hir::PatKind::Binding(_, canonical_id, ..), .. }) => {
627+
Res::Local(canonical_id)
628+
}
629629

630630
_ => Res::Err,
631631
}

compiler/rustc_typeck/src/check/demand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
223223
None,
224224
hir::Path { res: hir::def::Res::Local(hir_id), .. },
225225
)) => {
226-
if let Some(hir::Node::Binding(pat)) = self.tcx.hir().find(*hir_id) {
226+
if let Some(hir::Node::Pat(pat)) = self.tcx.hir().find(*hir_id) {
227227
let parent = self.tcx.hir().get_parent_node(pat.hir_id);
228228
primary_span = pat.span;
229229
secondary_span = pat.span;

0 commit comments

Comments
 (0)