10
10
11
11
//! Computes the restrictions that result from a borrow.
12
12
13
- pub use self :: RestrictionResult :: * ;
14
-
15
13
use borrowck:: * ;
16
14
use rustc:: middle:: expr_use_visitor as euv;
17
15
use rustc:: middle:: mem_categorization as mc;
@@ -69,19 +67,19 @@ impl<'a, 'tcx> RestrictionsContext<'a, 'tcx> {
69
67
// are inherently non-aliasable, they can only be
70
68
// accessed later through the borrow itself and hence
71
69
// must inherently comply with its terms.
72
- Safe
70
+ RestrictionResult :: Safe
73
71
}
74
72
75
73
Categorization :: Local ( local_id) => {
76
74
// R-Variable, locally declared
77
75
let lp = new_lp ( LpVar ( local_id) ) ;
78
- SafeIf ( lp. clone ( ) , vec ! [ lp] )
76
+ RestrictionResult :: SafeIf ( lp. clone ( ) , vec ! [ lp] )
79
77
}
80
78
81
79
Categorization :: Upvar ( mc:: Upvar { id, .. } ) => {
82
80
// R-Variable, captured into closure
83
81
let lp = new_lp ( LpUpvar ( id) ) ;
84
- SafeIf ( lp. clone ( ) , vec ! [ lp] )
82
+ RestrictionResult :: SafeIf ( lp. clone ( ) , vec ! [ lp] )
85
83
}
86
84
87
85
Categorization :: Downcast ( cmt_base, _) => {
@@ -106,7 +104,7 @@ impl<'a, 'tcx> RestrictionsContext<'a, 'tcx> {
106
104
}
107
105
108
106
Categorization :: StaticItem => {
109
- Safe
107
+ RestrictionResult :: Safe
110
108
}
111
109
112
110
Categorization :: Deref ( cmt_base, _, pk) => {
@@ -133,11 +131,11 @@ impl<'a, 'tcx> RestrictionsContext<'a, 'tcx> {
133
131
cmt : cmt_base,
134
132
code : err_borrowed_pointer_too_short (
135
133
self . loan_region , lt) } ) ;
136
- return Safe ;
134
+ return RestrictionResult :: Safe ;
137
135
}
138
136
139
137
match bk {
140
- ty:: ImmBorrow => Safe ,
138
+ ty:: ImmBorrow => RestrictionResult :: Safe ,
141
139
ty:: MutBorrow | ty:: UniqueImmBorrow => {
142
140
// R-Deref-Mut-Borrowed
143
141
//
@@ -150,7 +148,7 @@ impl<'a, 'tcx> RestrictionsContext<'a, 'tcx> {
150
148
}
151
149
}
152
150
// Borrowck is not relevant for raw pointers
153
- mc:: UnsafePtr ( ..) => Safe
151
+ mc:: UnsafePtr ( ..) => RestrictionResult :: Safe
154
152
}
155
153
}
156
154
}
@@ -161,12 +159,12 @@ impl<'a, 'tcx> RestrictionsContext<'a, 'tcx> {
161
159
cmt : & mc:: cmt < ' tcx > ,
162
160
elem : LoanPathElem ) -> RestrictionResult < ' tcx > {
163
161
match result {
164
- Safe => Safe ,
165
- SafeIf ( base_lp, mut base_vec) => {
162
+ RestrictionResult :: Safe => RestrictionResult :: Safe ,
163
+ RestrictionResult :: SafeIf ( base_lp, mut base_vec) => {
166
164
let v = LpExtend ( base_lp, cmt. mutbl , elem) ;
167
165
let lp = Rc :: new ( LoanPath :: new ( v, cmt. ty ) ) ;
168
166
base_vec. push ( lp. clone ( ) ) ;
169
- SafeIf ( lp, base_vec)
167
+ RestrictionResult :: SafeIf ( lp, base_vec)
170
168
}
171
169
}
172
170
}
0 commit comments