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