Skip to content

Commit 0ea2a20

Browse files
committed
Add PointerKind to LpDeref
1 parent 2246d56 commit 0ea2a20

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

src/librustc/middle/borrowck/gather_loans/restrictions.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl RestrictionsContext {
101101
self.extend(result, cmt.mutbl, LpInterior(i), restrictions)
102102
}
103103

104-
mc::cat_deref(cmt_base, _, mc::uniq_ptr) => {
104+
mc::cat_deref(cmt_base, _, pk @ mc::uniq_ptr) => {
105105
// R-Deref-Send-Pointer
106106
//
107107
// When we borrow the interior of an owned pointer, we
@@ -110,7 +110,7 @@ impl RestrictionsContext {
110110
let result = self.restrict(
111111
cmt_base,
112112
restrictions | RESTR_MUTATE | RESTR_CLAIM);
113-
self.extend(result, cmt.mutbl, LpDeref, restrictions)
113+
self.extend(result, cmt.mutbl, LpDeref(pk), restrictions)
114114
}
115115

116116
mc::cat_copied_upvar(*) | // FIXME(#2152) allow mutation of upvars
@@ -129,7 +129,7 @@ impl RestrictionsContext {
129129
Safe
130130
}
131131

132-
mc::cat_deref(cmt_base, _, mc::gc_ptr(m_mutbl)) => {
132+
mc::cat_deref(cmt_base, _, pk @ mc::gc_ptr(m_mutbl)) => {
133133
// R-Deref-Managed-Borrowed
134134
//
135135
// Technically, no restrictions are *necessary* here.
@@ -170,14 +170,14 @@ impl RestrictionsContext {
170170
match opt_loan_path(cmt_base) {
171171
None => Safe,
172172
Some(lp_base) => {
173-
let lp = @LpExtend(lp_base, cmt.mutbl, LpDeref);
173+
let lp = @LpExtend(lp_base, cmt.mutbl, LpDeref(pk));
174174
SafeIf(lp, ~[Restriction {loan_path: lp,
175175
set: restrictions}])
176176
}
177177
}
178178
}
179179

180-
mc::cat_deref(cmt_base, _, mc::region_ptr(m_mutbl, _)) => {
180+
mc::cat_deref(cmt_base, _, pk @ mc::region_ptr(m_mutbl, _)) => {
181181
// Because an `&mut` pointer does not inherit its
182182
// mutability, we can only prevent mutation or prevent
183183
// freezing if it is not aliased. Therefore, in such
@@ -187,7 +187,7 @@ impl RestrictionsContext {
187187
let result = self.restrict(
188188
cmt_base,
189189
RESTR_ALIAS | RESTR_MUTATE | RESTR_CLAIM);
190-
self.extend(result, cmt.mutbl, LpDeref, restrictions)
190+
self.extend(result, cmt.mutbl, LpDeref(pk), restrictions)
191191
} else {
192192
// R-Deref-Mut-Borrowed-2
193193
Safe

src/librustc/middle/borrowck/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ pub enum LoanPath {
261261

262262
#[deriving(Eq, IterBytes)]
263263
pub enum LoanPathElem {
264-
LpDeref, // `*LV` in doc.rs
264+
LpDeref(mc::PointerKind), // `*LV` in doc.rs
265265
LpInterior(mc::InteriorKind) // `LV.f` in doc.rs
266266
}
267267

@@ -295,9 +295,9 @@ pub fn opt_loan_path(cmt: mc::cmt) -> Option<@LoanPath> {
295295
Some(@LpVar(id))
296296
}
297297

298-
mc::cat_deref(cmt_base, _, _) => {
298+
mc::cat_deref(cmt_base, _, pk) => {
299299
do opt_loan_path(cmt_base).map_move |lp| {
300-
@LpExtend(lp, cmt.mutbl, LpDeref)
300+
@LpExtend(lp, cmt.mutbl, LpDeref(pk))
301301
}
302302
}
303303

@@ -728,7 +728,7 @@ impl BorrowckCtxt {
728728
loan_path: &LoanPath,
729729
out: &mut ~str) {
730730
match *loan_path {
731-
LpExtend(_, _, LpDeref) => {
731+
LpExtend(_, _, LpDeref(_)) => {
732732
out.push_char('(');
733733
self.append_loan_path_to_str(loan_path, out);
734734
out.push_char(')');
@@ -776,7 +776,7 @@ impl BorrowckCtxt {
776776
out.push_str("[]");
777777
}
778778

779-
LpExtend(lp_base, _, LpDeref) => {
779+
LpExtend(lp_base, _, LpDeref(_)) => {
780780
out.push_char('*');
781781
self.append_loan_path_to_str(lp_base, out);
782782
}
@@ -854,7 +854,7 @@ impl Repr for LoanPath {
854854
fmt!("$(%?)", id)
855855
}
856856

857-
&LpExtend(lp, _, LpDeref) => {
857+
&LpExtend(lp, _, LpDeref(_)) => {
858858
fmt!("%s.*", lp.repr(tcx))
859859
}
860860

src/librustc/middle/mem_categorization.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,18 @@ use syntax::print::pprust;
5959

6060
#[deriving(Eq)]
6161
pub enum categorization {
62-
cat_rvalue(ast::NodeId), // temporary val, argument is its scope
62+
cat_rvalue(ast::NodeId), // temporary val, argument is its scope
6363
cat_static_item,
6464
cat_implicit_self,
6565
cat_copied_upvar(CopiedUpvar), // upvar copied into @fn or ~fn env
6666
cat_stack_upvar(cmt), // by ref upvar from &fn
67-
cat_local(ast::NodeId), // local variable
68-
cat_arg(ast::NodeId), // formal argument
69-
cat_deref(cmt, uint, ptr_kind), // deref of a ptr
67+
cat_local(ast::NodeId), // local variable
68+
cat_arg(ast::NodeId), // formal argument
69+
cat_deref(cmt, uint, PointerKind), // deref of a ptr
7070
cat_interior(cmt, InteriorKind), // something interior: field, tuple, etc
7171
cat_downcast(cmt), // selects a particular enum variant (*)
72-
cat_discr(cmt, ast::NodeId), // match discriminant (see preserve())
73-
cat_self(ast::NodeId), // explicit `self`
72+
cat_discr(cmt, ast::NodeId), // match discriminant (see preserve())
73+
cat_self(ast::NodeId), // explicit `self`
7474

7575
// (*) downcast is only required if the enum has more than one variant
7676
}
@@ -82,8 +82,8 @@ pub struct CopiedUpvar {
8282
}
8383

8484
// different kinds of pointers:
85-
#[deriving(Eq)]
86-
pub enum ptr_kind {
85+
#[deriving(Eq, IterBytes)]
86+
pub enum PointerKind {
8787
uniq_ptr,
8888
gc_ptr(ast::mutability),
8989
region_ptr(ast::mutability, ty::Region),
@@ -147,7 +147,7 @@ pub type cmt = @cmt_;
147147
// We pun on *T to mean both actual deref of a ptr as well
148148
// as accessing of components:
149149
pub enum deref_kind {
150-
deref_ptr(ptr_kind),
150+
deref_ptr(PointerKind),
151151
deref_interior(InteriorKind),
152152
}
153153

@@ -1233,7 +1233,7 @@ impl Repr for categorization {
12331233
}
12341234
}
12351235

1236-
pub fn ptr_sigil(ptr: ptr_kind) -> ~str {
1236+
pub fn ptr_sigil(ptr: PointerKind) -> ~str {
12371237
match ptr {
12381238
uniq_ptr => ~"~",
12391239
gc_ptr(_) => ~"@",

0 commit comments

Comments
 (0)