about summary refs log tree commit diff
path: root/compiler/rustc_hir/src
diff options
context:
space:
mode:
authorJules Bertholet <julesbertholet@quoi.xyz>2024-04-16 19:23:30 -0400
committerJules Bertholet <julesbertholet@quoi.xyz>2024-04-17 09:34:39 -0400
commit2a4624ddd1d4084f385bbd704e0f90c85e16c42f (patch)
tree537a2011738e639ebbd562d10d78c13a67fe0b30 /compiler/rustc_hir/src
parentd19e48d79ab428387bbc354d677d7d9ba221d174 (diff)
downloadrust-2a4624ddd1d4084f385bbd704e0f90c85e16c42f.tar.gz
rust-2a4624ddd1d4084f385bbd704e0f90c85e16c42f.zip
Rename `BindingAnnotation` to `BindingMode`
Diffstat (limited to 'compiler/rustc_hir/src')
-rw-r--r--compiler/rustc_hir/src/hir.rs4
-rw-r--r--compiler/rustc_hir/src/pat_util.rs15
2 files changed, 8 insertions, 11 deletions
diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs
index b39056d8690..1ca30a48a51 100644
--- a/compiler/rustc_hir/src/hir.rs
+++ b/compiler/rustc_hir/src/hir.rs
@@ -7,7 +7,7 @@ use crate::LangItem;
 use rustc_ast as ast;
 use rustc_ast::util::parser::ExprPrecedence;
 use rustc_ast::{Attribute, FloatTy, IntTy, Label, LitKind, TraitObjectSyntax, UintTy};
-pub use rustc_ast::{BinOp, BinOpKind, BindingAnnotation, BorrowKind, ByRef, CaptureBy};
+pub use rustc_ast::{BinOp, BinOpKind, BindingMode, BorrowKind, ByRef, CaptureBy};
 pub use rustc_ast::{ImplPolarity, IsAuto, Movability, Mutability, UnOp};
 use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
 use rustc_data_structures::fingerprint::Fingerprint;
@@ -1151,7 +1151,7 @@ pub enum PatKind<'hir> {
     /// The `HirId` is the canonical ID for the variable being bound,
     /// (e.g., in `Ok(x) | Err(x)`, both `x` use the same canonical ID),
     /// which is the pattern ID of the first `x`.
-    Binding(BindingAnnotation, HirId, Ident, Option<&'hir Pat<'hir>>),
+    Binding(BindingMode, HirId, Ident, Option<&'hir Pat<'hir>>),
 
     /// A struct or struct variant pattern (e.g., `Variant {x, y, ..}`).
     /// The `bool` is `true` in the presence of a `..`.
diff --git a/compiler/rustc_hir/src/pat_util.rs b/compiler/rustc_hir/src/pat_util.rs
index 1eaab3d2aca..9991b02b1e1 100644
--- a/compiler/rustc_hir/src/pat_util.rs
+++ b/compiler/rustc_hir/src/pat_util.rs
@@ -1,6 +1,6 @@
 use crate::def::{CtorOf, DefKind, Res};
 use crate::def_id::{DefId, DefIdSet};
-use crate::hir::{self, BindingAnnotation, ByRef, HirId, PatKind};
+use crate::hir::{self, BindingMode, ByRef, HirId, PatKind};
 use rustc_span::symbol::Ident;
 use rustc_span::Span;
 
@@ -60,7 +60,7 @@ impl<T: ExactSizeIterator> EnumerateAndAdjustIterator for T {
 impl hir::Pat<'_> {
     /// Call `f` on every "binding" in a pattern, e.g., on `a` in
     /// `match foo() { Some(a) => (), None => () }`
-    pub fn each_binding(&self, mut f: impl FnMut(hir::BindingAnnotation, HirId, Span, Ident)) {
+    pub fn each_binding(&self, mut f: impl FnMut(hir::BindingMode, HirId, Span, Ident)) {
         self.walk_always(|p| {
             if let PatKind::Binding(binding_mode, _, ident, _) = p.kind {
                 f(binding_mode, p.hir_id, p.span, ident);
@@ -74,10 +74,7 @@ impl hir::Pat<'_> {
     /// When encountering an or-pattern `p_0 | ... | p_n` only the first non-never pattern will be
     /// visited. If they're all never patterns we visit nothing, which is ok since a never pattern
     /// cannot have bindings.
-    pub fn each_binding_or_first(
-        &self,
-        f: &mut impl FnMut(hir::BindingAnnotation, HirId, Span, Ident),
-    ) {
+    pub fn each_binding_or_first(&self, f: &mut impl FnMut(hir::BindingMode, HirId, Span, Ident)) {
         self.walk(|p| match &p.kind {
             PatKind::Or(ps) => {
                 for p in *ps {
@@ -98,7 +95,7 @@ impl hir::Pat<'_> {
 
     pub fn simple_ident(&self) -> Option<Ident> {
         match self.kind {
-            PatKind::Binding(BindingAnnotation(ByRef::No, _), _, ident, None) => Some(ident),
+            PatKind::Binding(BindingMode(ByRef::No, _), _, ident, None) => Some(ident),
             _ => None,
         }
     }
@@ -135,8 +132,8 @@ impl hir::Pat<'_> {
     pub fn contains_explicit_ref_binding(&self) -> Option<hir::Mutability> {
         let mut result = None;
         self.each_binding(|annotation, _, _, _| match annotation {
-            hir::BindingAnnotation::REF if result.is_none() => result = Some(hir::Mutability::Not),
-            hir::BindingAnnotation::REF_MUT => result = Some(hir::Mutability::Mut),
+            hir::BindingMode::REF if result.is_none() => result = Some(hir::Mutability::Not),
+            hir::BindingMode::REF_MUT => result = Some(hir::Mutability::Mut),
             _ => {}
         });
         result