From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- compiler/rustc_middle/src/ty/binding.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 compiler/rustc_middle/src/ty/binding.rs (limited to 'compiler/rustc_middle/src/ty/binding.rs') 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), + } + } +} -- cgit v1.2.3