Skip to content

Commit 509fc92

Browse files
committed
Removed remnants of @mut and ~mut from comments and the type system.
1 parent 68ebe81 commit 509fc92

39 files changed

+189
-260
lines changed

src/librustc/metadata/decoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ fn get_explicit_self(item: ebml::Doc) -> ast::ExplicitSelf_ {
782782
match explicit_self_kind as char {
783783
's' => ast::SelfStatic,
784784
'v' => ast::SelfValue(get_mutability(string[1])),
785-
'@' => ast::SelfBox(get_mutability(string[1])),
785+
'@' => ast::SelfBox,
786786
'~' => ast::SelfUniq(get_mutability(string[1])),
787787
// FIXME(#4846) expl. region
788788
'&' => ast::SelfRegion(None, get_mutability(string[1])),

src/librustc/metadata/encoder.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -687,9 +687,8 @@ fn encode_explicit_self(ebml_w: &mut writer::Encoder, explicit_self: ast::Explic
687687
ebml_w.writer.write(&[ '&' as u8 ]);
688688
encode_mutability(ebml_w, m);
689689
}
690-
SelfBox(m) => {
690+
SelfBox => {
691691
ebml_w.writer.write(&[ '@' as u8 ]);
692-
encode_mutability(ebml_w, m);
693692
}
694693
SelfUniq(m) => {
695694
ebml_w.writer.write(&[ '~' as u8 ]);

src/librustc/metadata/tydecode.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t {
343343
return ty::mk_self(st.tcx, did);
344344
}
345345
'@' => return ty::mk_box(st.tcx, parse_ty(st, |x,y| conv(x,y))),
346-
'~' => return ty::mk_uniq(st.tcx, parse_mt(st, |x,y| conv(x,y))),
346+
'~' => return ty::mk_uniq(st.tcx, parse_ty(st, |x,y| conv(x,y))),
347347
'*' => return ty::mk_ptr(st.tcx, parse_mt(st, |x,y| conv(x,y))),
348348
'&' => {
349349
let r = parse_region(st, |x,y| conv(x,y));

src/librustc/metadata/tyencode.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ fn enc_sty(w: &mut MemWriter, cx: @ctxt, st: &ty::sty) {
292292
mywrite!(w, "]");
293293
}
294294
ty::ty_box(typ) => { mywrite!(w, "@"); enc_ty(w, cx, typ); }
295-
ty::ty_uniq(mt) => { mywrite!(w, "~"); enc_mt(w, cx, mt); }
295+
ty::ty_uniq(typ) => { mywrite!(w, "~"); enc_ty(w, cx, typ); }
296296
ty::ty_ptr(mt) => { mywrite!(w, "*"); enc_mt(w, cx, mt); }
297297
ty::ty_rptr(r, mt) => {
298298
mywrite!(w, "&");

src/librustc/middle/borrowck/doc.rs

+7-44
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ data as mutable).
248248
2. `LIFETIME(LV, LT, MQ)`: The lifetime of the borrow does not exceed
249249
the lifetime of the value being borrowed. This pass is also
250250
responsible for inserting root annotations to keep managed values
251-
alive and for dynamically freezing `@mut` boxes.
251+
alive.
252252
253253
3. `RESTRICTIONS(LV, LT, ACTIONS) = RS`: This pass checks and computes the
254254
restrictions to maintain memory safety. These are the restrictions
@@ -308,22 +308,17 @@ be borrowed if MQ is immutable or const:
308308
309309
### Checking mutability of mutable pointer types
310310
311-
`&mut T` and `@mut T` can be frozen, so it is acceptable to borrow
312-
them as either imm or mut:
311+
`&mut T` can be frozen, so it is acceptable to borrow it as either imm or mut:
313312
314313
MUTABILITY(*LV, MQ) // M-Deref-Borrowed-Mut
315314
TYPE(LV) = &mut Ty
316315
317-
MUTABILITY(*LV, MQ) // M-Deref-Managed-Mut
318-
TYPE(LV) = @mut Ty
319-
320316
## Checking lifetime
321317
322-
These rules aim to ensure that no data is borrowed for a scope that
323-
exceeds its lifetime. In addition, these rules manage the rooting and
324-
dynamic freezing of `@` and `@mut` values. These two computations wind
325-
up being intimately related. Formally, we define a predicate
326-
`LIFETIME(LV, LT, MQ)`, which states that "the lvalue `LV` can be
318+
These rules aim to ensure that no data is borrowed for a scope that exceeds
319+
its lifetime. In addition, these rules manage the rooting of `@` values.
320+
These two computations wind up being intimately related. Formally, we define
321+
a predicate `LIFETIME(LV, LT, MQ)`, which states that "the lvalue `LV` can be
327322
safely borrowed for the lifetime `LT` with mutability `MQ`". The Rust
328323
code corresponding to this predicate is the module
329324
`middle::borrowck::gather_loans::lifetime`.
@@ -352,7 +347,7 @@ The scope of a managed referent is also the scope of the pointer. This
352347
is a conservative approximation, since there may be other aliases fo
353348
that same managed box that would cause it to live longer:
354349
355-
SCOPE(*LV) = SCOPE(LV) if LV has type @T or @mut T
350+
SCOPE(*LV) = SCOPE(LV) if LV has type @T
356351
357352
The scope of a borrowed referent is the scope associated with the
358353
pointer. This is a conservative approximation, since the data that
@@ -441,29 +436,6 @@ makes a note in a side-table that the box `LV` must be rooted into the
441436
stack when `*LV` is evaluated, and that this root can be released when
442437
the scope `LT` exits.
443438
444-
### Checking lifetime for derefs of managed, mutable pointers
445-
446-
Loans of the contents of mutable managed pointers are simpler in some
447-
ways that loans of immutable managed pointers, because we can never
448-
rely on the user to root them (since the contents are, after all,
449-
mutable). This means that the burden always falls to the compiler, so
450-
there is only one rule:
451-
452-
LIFETIME(*LV, LT, MQ) // L-Deref-Managed-Mut-Compiler-Root
453-
TYPE(LV) = @mut Ty
454-
LT <= innermost enclosing loop/func
455-
ROOT LV at *LV for LT
456-
LOCK LV at *LV as MQ for LT
457-
458-
Note that there is an additional clause this time `LOCK LV at *LV as
459-
MQ for LT`. This clause states that in addition to rooting `LV`, the
460-
compiler should also "lock" the box dynamically, meaning that we
461-
register that the box has been borrowed as mutable or immutable,
462-
depending on `MQ`. This lock will fail if the box has already been
463-
borrowed and either the old loan or the new loan is a mutable loan
464-
(multiple immutable loans are okay). The lock is released as we exit
465-
the scope `LT`.
466-
467439
## Computing the restrictions
468440
469441
The final rules govern the computation of *restrictions*, meaning that
@@ -835,15 +807,6 @@ prohibited from both freezes and claims. This would avoid the need to
835807
prevent `const` borrows of the base pointer when the referent is
836808
borrowed.
837809
838-
### Restrictions for loans of mutable managed referents
839-
840-
With `@mut` referents, we don't make any static guarantees. But as a
841-
convenience, we still register a restriction against `*LV`, because
842-
that way if we *can* find a simple static error, we will:
843-
844-
RESTRICTIONS(*LV, LT, ACTIONS) = [*LV, ACTIONS] // R-Deref-Managed-Borrowed
845-
TYPE(LV) = @mut Ty
846-
847810
# Moves and initialization
848811
849812
The borrow checker is also in charge of ensuring that:

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl<'a> GuaranteeLifetimeContext<'a> {
137137
//
138138
// As a second example, consider *this* scenario:
139139
//
140-
// let x = @mut @Some(3);
140+
// let x = @@Some(3);
141141
// match x { @@Some(y) {...} @@None {...} }
142142
//
143143
// Here again, `x` need only be rooted in the `some` arm.
@@ -156,7 +156,7 @@ impl<'a> GuaranteeLifetimeContext<'a> {
156156
// with a second basic block. However, the naive approach
157157
// also yielded suboptimal results for patterns like:
158158
//
159-
// let x = @mut @...;
159+
// let x = @@...;
160160
// match x { @@some_variant(y) | @@some_other_variant(y) =>
161161
//
162162
// The reason is that we would root the value once for

src/librustc/middle/liveness.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ fn visit_fn(v: &mut LivenessVisitor,
409409
match *fk {
410410
visit::FkMethod(_, _, method) => {
411411
match method.explicit_self.node {
412-
SelfValue(_) | SelfRegion(..) | SelfBox(_) | SelfUniq(_) => {
412+
SelfValue(_) | SelfRegion(..) | SelfBox | SelfUniq(_) => {
413413
fn_maps.add_variable(Arg(method.self_id,
414414
special_idents::self_));
415415
}

src/librustc/middle/trans/base.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -357,20 +357,18 @@ pub fn malloc_raw_dyn<'a>(
357357
rslt(r.bcx, PointerCast(r.bcx, r.val, llty_value.ptr_to()))
358358
} else {
359359
// we treat ~fn, @fn and @[] as @ here, which isn't ideal
360-
let (mk_fn, langcall) = match heap {
360+
let langcall = match heap {
361361
heap_managed | heap_managed_unique => {
362-
(ty::mk_imm_box,
363-
require_alloc_fn(bcx, t, MallocFnLangItem))
362+
require_alloc_fn(bcx, t, MallocFnLangItem)
364363
}
365364
heap_exchange_closure => {
366-
(ty::mk_imm_box,
367-
require_alloc_fn(bcx, t, ClosureExchangeMallocFnLangItem))
365+
require_alloc_fn(bcx, t, ClosureExchangeMallocFnLangItem)
368366
}
369367
_ => fail!("heap_exchange already handled")
370368
};
371369

372370
// Grab the TypeRef type of box_ptr_ty.
373-
let box_ptr_ty = mk_fn(bcx.tcx(), t);
371+
let box_ptr_ty = ty::mk_box(bcx.tcx(), t);
374372
let llty = type_of(ccx, box_ptr_ty);
375373

376374
// Get the tydesc for the body:

src/librustc/middle/trans/closure.rs

-5
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,6 @@ impl EnvValue {
131131
}
132132
}
133133

134-
pub fn mk_tuplified_uniq_cbox_ty(tcx: ty::ctxt, cdata_ty: ty::t) -> ty::t {
135-
let cbox_ty = tuplify_box_ty(tcx, cdata_ty);
136-
return ty::mk_imm_uniq(tcx, cbox_ty);
137-
}
138-
139134
// Given a closure ty, emits a corresponding tuple ty
140135
pub fn mk_closure_tys(tcx: ty::ctxt,
141136
bound_values: &[EnvValue])

src/librustc/middle/trans/datum.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ impl Datum {
569569

570570
let (content_ty, header) = match ty::get(self.ty).sty {
571571
ty::ty_box(typ) => (typ, true),
572-
ty::ty_uniq(mt) => (mt.ty, false),
572+
ty::ty_uniq(typ) => (typ, false),
573573
ty::ty_vec(_, ty::vstore_uniq) | ty::ty_str(ty::vstore_uniq) => {
574574
let unit_ty = ty::sequence_element_type(bcx.tcx(), self.ty);
575575
let unboxed_vec_ty = ty::mk_mut_unboxed_vec(bcx.tcx(), unit_ty);

src/librustc/middle/trans/debuginfo.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -2147,12 +2147,15 @@ fn type_metadata(cx: &CrateContext,
21472147
}
21482148
}
21492149
},
2150-
ty::ty_uniq(ref mt) if ty::type_contents(cx.tcx, mt.ty).owns_managed() => {
2151-
create_pointer_to_box_metadata(cx, t, mt.ty)
2152-
},
2153-
ty::ty_uniq(ref mt) |
2154-
ty::ty_ptr(ref mt) |
2155-
ty::ty_rptr(_, ref mt) => {
2150+
ty::ty_uniq(typ) => {
2151+
if ty::type_contents(cx.tcx, typ).owns_managed() {
2152+
create_pointer_to_box_metadata(cx, t, typ)
2153+
} else {
2154+
let pointee = type_metadata(cx, typ, usage_site_span);
2155+
pointer_type_metadata(cx, t, pointee)
2156+
}
2157+
}
2158+
ty::ty_ptr(ref mt) | ty::ty_rptr(_, ref mt) => {
21562159
let pointee = type_metadata(cx, mt.ty, usage_site_span);
21572160
pointer_type_metadata(cx, t, pointee)
21582161
},
@@ -2176,7 +2179,7 @@ fn type_metadata(cx: &CrateContext,
21762179

21772180
let mut created_types = debug_context(cx).created_types.borrow_mut();
21782181
created_types.get().insert(cache_id, type_metadata);
2179-
return type_metadata;
2182+
type_metadata
21802183
}
21812184

21822185
#[deriving(Eq)]

src/librustc/middle/trans/glue.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -108,22 +108,26 @@ fn simplified_glue_type(tcx: ty::ctxt, field: uint, t: ty::t) -> ty::t {
108108
}
109109

110110
if field == abi::tydesc_field_take_glue && ty::type_is_boxed(t) {
111-
return ty::mk_imm_box(tcx, ty::mk_nil());
111+
return ty::mk_box(tcx, ty::mk_nil());
112112
}
113113

114114
if field == abi::tydesc_field_drop_glue {
115115
match ty::get(t).sty {
116116
ty::ty_box(typ)
117117
if !ty::type_needs_drop(tcx, typ) =>
118-
return ty::mk_imm_box(tcx, ty::mk_nil()),
118+
return ty::mk_box(tcx, ty::mk_nil()),
119119

120120
ty::ty_vec(mt, ty::vstore_box)
121121
if !ty::type_needs_drop(tcx, mt.ty) =>
122-
return ty::mk_imm_box(tcx, ty::mk_nil()),
122+
return ty::mk_box(tcx, ty::mk_nil()),
123123

124-
ty::ty_uniq(mt) | ty::ty_vec(mt, ty::vstore_uniq)
124+
ty::ty_uniq(typ)
125+
if !ty::type_needs_drop(tcx, typ) =>
126+
return ty::mk_uniq(tcx, ty::mk_nil()),
127+
128+
ty::ty_vec(mt, ty::vstore_uniq)
125129
if !ty::type_needs_drop(tcx, mt.ty) =>
126-
return ty::mk_imm_uniq(tcx, ty::mk_nil()),
130+
return ty::mk_uniq(tcx, ty::mk_nil()),
127131

128132
_ => {}
129133
}

src/librustc/middle/trans/reflect.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ impl<'a> Reflector<'a> {
176176
self.visit("vec", values)
177177
}
178178

179+
// Should rename to str_*/vec_*.
179180
ty::ty_str(vst) => {
180181
let (name, extra) = self.vstore_name_and_extra(t, vst);
181182
self.visit(~"estr_" + name, extra)
@@ -189,15 +190,19 @@ impl<'a> Reflector<'a> {
189190
self.visit(~"evec_" + name, extra)
190191
}
191192
}
193+
// Should remove mt from box and uniq.
192194
ty::ty_box(typ) => {
193195
let extra = self.c_mt(&ty::mt {
194196
ty: typ,
195197
mutbl: ast::MutImmutable,
196198
});
197199
self.visit("box", extra)
198200
}
199-
ty::ty_uniq(ref mt) => {
200-
let extra = self.c_mt(mt);
201+
ty::ty_uniq(typ) => {
202+
let extra = self.c_mt(&ty::mt {
203+
ty: typ,
204+
mutbl: ast::MutImmutable,
205+
});
201206
if ty::type_contents(bcx.tcx(), t).owns_managed() {
202207
self.visit("uniq_managed", extra)
203208
} else {

src/librustc/middle/trans/tvec.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ pub fn expand_boxed_vec_ty(tcx: ty::ctxt, t: ty::t) -> ty::t {
4040
let unit_ty = ty::sequence_element_type(tcx, t);
4141
let unboxed_vec_ty = ty::mk_mut_unboxed_vec(tcx, unit_ty);
4242
match ty::get(t).sty {
43-
ty::ty_str(ty::vstore_uniq) | ty::ty_vec(_, ty::vstore_uniq) => {
44-
ty::mk_imm_uniq(tcx, unboxed_vec_ty)
45-
}
46-
ty::ty_str(ty::vstore_box) | ty::ty_vec(_, ty::vstore_box) => {
47-
ty::mk_imm_box(tcx, unboxed_vec_ty)
48-
}
49-
_ => tcx.sess.bug("non boxed-vec type \
50-
in tvec::expand_boxed_vec_ty")
43+
ty::ty_str(ty::vstore_uniq) | ty::ty_vec(_, ty::vstore_uniq) => {
44+
ty::mk_uniq(tcx, unboxed_vec_ty)
45+
}
46+
ty::ty_str(ty::vstore_box) | ty::ty_vec(_, ty::vstore_box) => {
47+
ty::mk_box(tcx, unboxed_vec_ty)
48+
}
49+
_ => tcx.sess.bug("non boxed-vec type \
50+
in tvec::expand_boxed_vec_ty")
5151
}
5252
}
5353

src/librustc/middle/trans/type_of.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,9 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type {
244244
let ty = type_of(cx, typ);
245245
Type::smart_ptr(cx, &ty).ptr_to()
246246
}
247-
ty::ty_uniq(ref mt) => {
248-
let ty = type_of(cx, mt.ty);
249-
if ty::type_contents(cx.tcx, mt.ty).owns_managed() {
247+
ty::ty_uniq(typ) => {
248+
let ty = type_of(cx, typ);
249+
if ty::type_contents(cx.tcx, typ).owns_managed() {
250250
Type::unique(cx, &ty).ptr_to()
251251
} else {
252252
ty.ptr_to()

src/librustc/middle/trans/write_guard.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//! Logic relating to rooting and write guards for managed values
12-
//! (`@` and `@mut`). This code is primarily for use by datum;
11+
//! Logic relating to rooting and write guards for managed values.
12+
//! This code is primarily for use by datum;
1313
//! it exists in its own module both to keep datum.rs bite-sized
1414
//! and for each in debugging (e.g., so you can use
1515
//! `RUST_LOG=rustc::middle::trans::write_guard`).

0 commit comments

Comments
 (0)