summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_middle/src/ty/binding.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_middle/src/ty/binding.rs')
-rw-r--r--compiler/rustc_middle/src/ty/binding.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/ty/binding.rs b/compiler/rustc_middle/src/ty/binding.rs
new file mode 100644
index 000000000..3d65429f2
--- /dev/null
+++ b/compiler/rustc_middle/src/ty/binding.rs
@@ -0,0 +1,22 @@
+use rustc_hir::BindingAnnotation;
+use rustc_hir::BindingAnnotation::*;
+use rustc_hir::Mutability;
+
+#[derive(Clone, PartialEq, TyEncodable, TyDecodable, Debug, Copy, HashStable)]
+pub enum BindingMode {
+ BindByReference(Mutability),
+ BindByValue(Mutability),
+}
+
+TrivialTypeTraversalAndLiftImpls! { BindingMode, }
+
+impl BindingMode {
+ pub fn convert(ba: BindingAnnotation) -> BindingMode {
+ match ba {
+ Unannotated => BindingMode::BindByValue(Mutability::Not),
+ Mutable => BindingMode::BindByValue(Mutability::Mut),
+ Ref => BindingMode::BindByReference(Mutability::Not),
+ RefMut => BindingMode::BindByReference(Mutability::Mut),
+ }
+ }
+}