]> git.proxmox.com Git - rustc.git/blob - compiler/rustc_middle/src/ty/binding.rs
New upstream version 1.48.0~beta.8+dfsg1
[rustc.git] / compiler / rustc_middle / src / ty / binding.rs
1 use rustc_hir::BindingAnnotation;
2 use rustc_hir::BindingAnnotation::*;
3 use rustc_hir::Mutability;
4
5 #[derive(Clone, PartialEq, TyEncodable, TyDecodable, Debug, Copy, HashStable)]
6 pub enum BindingMode {
7 BindByReference(Mutability),
8 BindByValue(Mutability),
9 }
10
11 CloneTypeFoldableAndLiftImpls! { BindingMode, }
12
13 impl BindingMode {
14 pub fn convert(ba: BindingAnnotation) -> BindingMode {
15 match ba {
16 Unannotated => BindingMode::BindByValue(Mutability::Not),
17 Mutable => BindingMode::BindByValue(Mutability::Mut),
18 Ref => BindingMode::BindByReference(Mutability::Not),
19 RefMut => BindingMode::BindByReference(Mutability::Mut),
20 }
21 }
22 }