@@ -33,7 +33,7 @@ pub fn compute_restrictions(bccx: @BorrowckCtxt,
33
33
cmt_original : cmt
34
34
} ;
35
35
36
- ctxt. compute ( cmt, restr)
36
+ ctxt. restrict ( cmt, restr)
37
37
}
38
38
39
39
///////////////////////////////////////////////////////////////////////////
@@ -50,9 +50,9 @@ impl RestrictionsContext {
50
50
self . bccx . tcx
51
51
}
52
52
53
- fn compute ( & self ,
54
- cmt : mc:: cmt ,
55
- restrictions : RestrictionSet ) -> RestrictionResult {
53
+ fn restrict ( & self ,
54
+ cmt : mc:: cmt ,
55
+ restrictions : RestrictionSet ) -> RestrictionResult {
56
56
57
57
// Check for those cases where we cannot control the aliasing
58
58
// and make sure that we are not being asked to.
@@ -86,7 +86,9 @@ impl RestrictionsContext {
86
86
// When we borrow the interior of an enum, we have to
87
87
// ensure the enum itself is not mutated, because that
88
88
// could cause the type of the memory to change.
89
- self . compute ( cmt_base, restrictions | RESTR_MUTATE | RESTR_CLAIM )
89
+ self . restrict (
90
+ cmt_base,
91
+ restrictions | RESTR_MUTATE | RESTR_CLAIM )
90
92
}
91
93
92
94
mc:: cat_interior( cmt_base, i) => {
@@ -95,7 +97,7 @@ impl RestrictionsContext {
95
97
// Overwriting the base would not change the type of
96
98
// the memory, so no additional restrictions are
97
99
// needed.
98
- let result = self . compute ( cmt_base, restrictions) ;
100
+ let result = self . restrict ( cmt_base, restrictions) ;
99
101
self . extend ( result, cmt. mutbl , LpInterior ( i) , restrictions)
100
102
}
101
103
@@ -105,7 +107,7 @@ impl RestrictionsContext {
105
107
// When we borrow the interior of an owned pointer, we
106
108
// cannot permit the base to be mutated, because that
107
109
// would cause the unique pointer to be freed.
108
- let result = self . compute (
110
+ let result = self . restrict (
109
111
cmt_base,
110
112
restrictions | RESTR_MUTATE | RESTR_CLAIM ) ;
111
113
self . extend ( result, cmt. mutbl , LpDeref , restrictions)
@@ -180,16 +182,15 @@ impl RestrictionsContext {
180
182
// mutability, we can only prevent mutation or prevent
181
183
// freezing if it is not aliased. Therefore, in such
182
184
// cases we restrict aliasing on `cmt_base`.
183
- if restrictions. intersects ( RESTR_MUTATE |
184
- RESTR_CLAIM |
185
- RESTR_FREEZE ) {
185
+ if restrictions != RESTR_EMPTY {
186
186
// R-Deref-Mut-Borrowed-1
187
- let result = self . compute ( cmt_base, restrictions | RESTR_ALIAS ) ;
187
+ let result = self . restrict (
188
+ cmt_base,
189
+ RESTR_ALIAS | RESTR_MUTATE | RESTR_CLAIM ) ;
188
190
self . extend ( result, cmt. mutbl , LpDeref , restrictions)
189
191
} else {
190
192
// R-Deref-Mut-Borrowed-2
191
- let result = self . compute ( cmt_base, restrictions) ;
192
- self . extend ( result, cmt. mutbl , LpDeref , restrictions)
193
+ Safe
193
194
}
194
195
}
195
196
@@ -200,7 +201,7 @@ impl RestrictionsContext {
200
201
201
202
mc:: cat_stack_upvar( cmt_base) |
202
203
mc:: cat_discr( cmt_base, _) => {
203
- self . compute ( cmt_base, restrictions)
204
+ self . restrict ( cmt_base, restrictions)
204
205
}
205
206
}
206
207
}
0 commit comments