@@ -30,16 +30,15 @@ pub fn compute_restrictions(bccx: &BorrowckCtxt,
30
30
span : Span ,
31
31
cause : euv:: LoanCause ,
32
32
cmt : mc:: cmt ,
33
- loan_region : ty:: Region ,
34
- restr : RestrictionSet ) -> RestrictionResult {
33
+ loan_region : ty:: Region ) -> RestrictionResult {
35
34
let ctxt = RestrictionsContext {
36
35
bccx : bccx,
37
36
span : span,
38
37
cause : cause,
39
38
loan_region : loan_region,
40
39
} ;
41
40
42
- ctxt. restrict ( cmt, restr )
41
+ ctxt. restrict ( cmt)
43
42
}
44
43
45
44
///////////////////////////////////////////////////////////////////////////
@@ -54,11 +53,8 @@ struct RestrictionsContext<'a> {
54
53
55
54
impl < ' a > RestrictionsContext < ' a > {
56
55
fn restrict ( & self ,
57
- cmt : mc:: cmt ,
58
- restrictions : RestrictionSet ) -> RestrictionResult {
59
- debug ! ( "restrict(cmt={}, restrictions={})" ,
60
- cmt. repr( self . bccx. tcx) ,
61
- restrictions. repr( self . bccx. tcx) ) ;
56
+ cmt : mc:: cmt ) -> RestrictionResult {
57
+ debug ! ( "restrict(cmt={})" , cmt. repr( self . bccx. tcx) ) ;
62
58
63
59
match cmt. cat . clone ( ) {
64
60
mc:: cat_rvalue( ..) => {
@@ -75,19 +71,14 @@ impl<'a> RestrictionsContext<'a> {
75
71
mc:: cat_upvar( ty:: UpvarId { var_id : local_id, ..} , _) => {
76
72
// R-Variable
77
73
let lp = Rc :: new ( LpVar ( local_id) ) ;
78
- SafeIf ( lp. clone ( ) , vec ! ( Restriction {
79
- loan_path: lp,
80
- set: restrictions
81
- } ) )
74
+ SafeIf ( lp. clone ( ) , vec ! ( Restriction { loan_path: lp } ) )
82
75
}
83
76
84
77
mc:: cat_downcast( cmt_base) => {
85
78
// When we borrow the interior of an enum, we have to
86
79
// ensure the enum itself is not mutated, because that
87
80
// could cause the type of the memory to change.
88
- self . restrict (
89
- cmt_base,
90
- restrictions | RESTR_MUTATE )
81
+ self . restrict ( cmt_base)
91
82
}
92
83
93
84
mc:: cat_interior( cmt_base, i) => {
@@ -96,8 +87,8 @@ impl<'a> RestrictionsContext<'a> {
96
87
// Overwriting the base would not change the type of
97
88
// the memory, so no additional restrictions are
98
89
// needed.
99
- let result = self . restrict ( cmt_base, restrictions ) ;
100
- self . extend ( result, cmt. mutbl , LpInterior ( i) , restrictions )
90
+ let result = self . restrict ( cmt_base) ;
91
+ self . extend ( result, cmt. mutbl , LpInterior ( i) )
101
92
}
102
93
103
94
mc:: cat_deref( cmt_base, _, pk @ mc:: OwnedPtr ) |
@@ -112,10 +103,8 @@ impl<'a> RestrictionsContext<'a> {
112
103
// same, because this could be the last ref.
113
104
// Eventually we should make these non-special and
114
105
// just rely on Deref<T> implementation.
115
- let result = self . restrict (
116
- cmt_base,
117
- restrictions | RESTR_MUTATE ) ;
118
- self . extend ( result, cmt. mutbl , LpDeref ( pk) , restrictions)
106
+ let result = self . restrict ( cmt_base) ;
107
+ self . extend ( result, cmt. mutbl , LpDeref ( pk) )
119
108
}
120
109
121
110
mc:: cat_copied_upvar( ..) | // FIXME(#2152) allow mutation of upvars
@@ -152,8 +141,8 @@ impl<'a> RestrictionsContext<'a> {
152
141
return Safe ;
153
142
}
154
143
155
- let result = self . restrict ( cmt_base, restrictions ) ;
156
- self . extend ( result, cmt. mutbl , LpDeref ( pk) , restrictions )
144
+ let result = self . restrict ( cmt_base) ;
145
+ self . extend ( result, cmt. mutbl , LpDeref ( pk) )
157
146
}
158
147
159
148
mc:: cat_deref( _, _, mc:: UnsafePtr ( ..) ) => {
@@ -162,24 +151,20 @@ impl<'a> RestrictionsContext<'a> {
162
151
}
163
152
164
153
mc:: cat_discr( cmt_base, _) => {
165
- self . restrict ( cmt_base, restrictions )
154
+ self . restrict ( cmt_base)
166
155
}
167
156
}
168
157
}
169
158
170
159
fn extend ( & self ,
171
160
result : RestrictionResult ,
172
161
mc : mc:: MutabilityCategory ,
173
- elem : LoanPathElem ,
174
- restrictions : RestrictionSet ) -> RestrictionResult {
162
+ elem : LoanPathElem ) -> RestrictionResult {
175
163
match result {
176
164
Safe => Safe ,
177
165
SafeIf ( base_lp, mut base_vec) => {
178
166
let lp = Rc :: new ( LpExtend ( base_lp, mc, elem) ) ;
179
- base_vec. push ( Restriction {
180
- loan_path : lp. clone ( ) ,
181
- set : restrictions
182
- } ) ;
167
+ base_vec. push ( Restriction { loan_path : lp. clone ( ) } ) ;
183
168
SafeIf ( lp, base_vec)
184
169
}
185
170
}
0 commit comments