Skip to content

Commit c86df3a

Browse files
committed
auto merge of #7342 : alexcrichton/rust/assort-cleanup, r=cmr
This removes usage of `&const` throughout the standard libraries/compiler, and it removes some extraneous fields in the AST now that unique boxes always inherit their mutability.
2 parents 8883099 + 3bad712 commit c86df3a

33 files changed

+135
-165
lines changed

src/libextra/arc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,8 @@ impl<T:Freeze + Send> RWARC<T> {
436436
// lock it. This wraps the unsafety, with the justification that the 'lock'
437437
// field is never overwritten; only 'failed' and 'data'.
438438
#[doc(hidden)]
439-
fn borrow_rwlock<T:Freeze + Send>(state: *const RWARCInner<T>) -> *RWlock {
440-
unsafe { cast::transmute(&const (*state).lock) }
439+
fn borrow_rwlock<T:Freeze + Send>(state: *mut RWARCInner<T>) -> *RWlock {
440+
unsafe { cast::transmute(&(*state).lock) }
441441
}
442442

443443
/// The "write permission" token used for RWARC.write_downgrade().

src/libextra/bitv.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -705,8 +705,8 @@ impl cmp::Eq for BitvSet {
705705
}
706706

707707
impl Container for BitvSet {
708-
fn len(&const self) -> uint { self.size }
709-
fn is_empty(&const self) -> bool { self.size == 0 }
708+
fn len(&self) -> uint { self.size }
709+
fn is_empty(&self) -> bool { self.size == 0 }
710710
}
711711

712712
impl Mutable for BitvSet {

src/libextra/deque.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ pub struct Deque<T> {
2828

2929
impl<T> Container for Deque<T> {
3030
/// Return the number of elements in the deque
31-
fn len(&const self) -> uint { self.nelts }
31+
fn len(&self) -> uint { self.nelts }
3232

3333
/// Return true if the deque contains no elements
34-
fn is_empty(&const self) -> bool { self.len() == 0 }
34+
fn is_empty(&self) -> bool { self.len() == 0 }
3535
}
3636

3737
impl<T> Mutable for Deque<T> {

src/libextra/flate.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ static lz_fast : c_int = 0x1; // LZ with only one probe
4444
static lz_norm : c_int = 0x80; // LZ with 128 probes, "normal"
4545
static lz_best : c_int = 0xfff; // LZ with 4095 probes, "best"
4646

47-
pub fn deflate_bytes(bytes: &const [u8]) -> ~[u8] {
48-
do vec::as_const_buf(bytes) |b, len| {
47+
pub fn deflate_bytes(bytes: &[u8]) -> ~[u8] {
48+
do vec::as_imm_buf(bytes) |b, len| {
4949
unsafe {
5050
let mut outsz : size_t = 0;
5151
let res =
@@ -62,8 +62,8 @@ pub fn deflate_bytes(bytes: &const [u8]) -> ~[u8] {
6262
}
6363
}
6464

65-
pub fn inflate_bytes(bytes: &const [u8]) -> ~[u8] {
66-
do vec::as_const_buf(bytes) |b, len| {
65+
pub fn inflate_bytes(bytes: &[u8]) -> ~[u8] {
66+
do vec::as_imm_buf(bytes) |b, len| {
6767
unsafe {
6868
let mut outsz : size_t = 0;
6969
let res =

src/libextra/treemap.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ impl<K: Ord + TotalOrd, V> Ord for TreeMap<K, V> {
8787

8888
impl<K: TotalOrd, V> Container for TreeMap<K, V> {
8989
/// Return the number of elements in the map
90-
fn len(&const self) -> uint { self.length }
90+
fn len(&self) -> uint { self.length }
9191

9292
/// Return true if the map contains no elements
93-
fn is_empty(&const self) -> bool { self.root.is_none() }
93+
fn is_empty(&self) -> bool { self.root.is_none() }
9494
}
9595

9696
impl<K: TotalOrd, V> Mutable for TreeMap<K, V> {
@@ -265,11 +265,11 @@ impl<T: Ord + TotalOrd> Ord for TreeSet<T> {
265265
impl<T: TotalOrd> Container for TreeSet<T> {
266266
/// Return the number of elements in the set
267267
#[inline]
268-
fn len(&const self) -> uint { self.map.len() }
268+
fn len(&self) -> uint { self.map.len() }
269269

270270
/// Return true if the set contains no elements
271271
#[inline]
272-
fn is_empty(&const self) -> bool { self.map.is_empty() }
272+
fn is_empty(&self) -> bool { self.map.is_empty() }
273273
}
274274

275275
impl<T: TotalOrd> Mutable for TreeSet<T> {

src/librustc/metadata/decoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ fn get_explicit_self(item: ebml::Doc) -> ast::explicit_self_ {
786786
's' => { return ast::sty_static; }
787787
'v' => { return ast::sty_value; }
788788
'@' => { return ast::sty_box(get_mutability(string[1])); }
789-
'~' => { return ast::sty_uniq(get_mutability(string[1])); }
789+
'~' => { return ast::sty_uniq; }
790790
'&' => {
791791
// FIXME(#4846) expl. region
792792
return ast::sty_region(None, get_mutability(string[1]));

src/librustc/metadata/encoder.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -630,9 +630,8 @@ fn encode_explicit_self(ebml_w: &mut writer::Encoder, explicit_self: ast::explic
630630
ebml_w.writer.write(&[ '@' as u8 ]);
631631
encode_mutability(ebml_w, m);
632632
}
633-
sty_uniq(m) => {
633+
sty_uniq => {
634634
ebml_w.writer.write(&[ '~' as u8 ]);
635-
encode_mutability(ebml_w, m);
636635
}
637636
}
638637

src/librustc/middle/check_const.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub fn check_expr(sess: Session,
9292
if is_const {
9393
match e.node {
9494
expr_unary(_, deref, _) => { }
95-
expr_unary(_, box(_), _) | expr_unary(_, uniq(_), _) => {
95+
expr_unary(_, box(_), _) | expr_unary(_, uniq, _) => {
9696
sess.span_err(e.span,
9797
"disallowed operator in constant expression");
9898
return;

src/librustc/middle/lang_items.rs

+38-38
Original file line numberDiff line numberDiff line change
@@ -152,122 +152,122 @@ impl LanguageItems {
152152

153153
// FIXME #4621: Method macros sure would be nice here.
154154

155-
pub fn freeze_trait(&const self) -> def_id {
155+
pub fn freeze_trait(&self) -> def_id {
156156
self.items[FreezeTraitLangItem as uint].get()
157157
}
158-
pub fn copy_trait(&const self) -> def_id {
158+
pub fn copy_trait(&self) -> def_id {
159159
self.items[CopyTraitLangItem as uint].get()
160160
}
161-
pub fn send_trait(&const self) -> def_id {
161+
pub fn send_trait(&self) -> def_id {
162162
self.items[SendTraitLangItem as uint].get()
163163
}
164-
pub fn sized_trait(&const self) -> def_id {
164+
pub fn sized_trait(&self) -> def_id {
165165
self.items[SizedTraitLangItem as uint].get()
166166
}
167167

168-
pub fn drop_trait(&const self) -> def_id {
168+
pub fn drop_trait(&self) -> def_id {
169169
self.items[DropTraitLangItem as uint].get()
170170
}
171171

172-
pub fn add_trait(&const self) -> def_id {
172+
pub fn add_trait(&self) -> def_id {
173173
self.items[AddTraitLangItem as uint].get()
174174
}
175-
pub fn sub_trait(&const self) -> def_id {
175+
pub fn sub_trait(&self) -> def_id {
176176
self.items[SubTraitLangItem as uint].get()
177177
}
178-
pub fn mul_trait(&const self) -> def_id {
178+
pub fn mul_trait(&self) -> def_id {
179179
self.items[MulTraitLangItem as uint].get()
180180
}
181-
pub fn div_trait(&const self) -> def_id {
181+
pub fn div_trait(&self) -> def_id {
182182
self.items[DivTraitLangItem as uint].get()
183183
}
184-
pub fn rem_trait(&const self) -> def_id {
184+
pub fn rem_trait(&self) -> def_id {
185185
self.items[RemTraitLangItem as uint].get()
186186
}
187-
pub fn neg_trait(&const self) -> def_id {
187+
pub fn neg_trait(&self) -> def_id {
188188
self.items[NegTraitLangItem as uint].get()
189189
}
190-
pub fn not_trait(&const self) -> def_id {
190+
pub fn not_trait(&self) -> def_id {
191191
self.items[NotTraitLangItem as uint].get()
192192
}
193-
pub fn bitxor_trait(&const self) -> def_id {
193+
pub fn bitxor_trait(&self) -> def_id {
194194
self.items[BitXorTraitLangItem as uint].get()
195195
}
196-
pub fn bitand_trait(&const self) -> def_id {
196+
pub fn bitand_trait(&self) -> def_id {
197197
self.items[BitAndTraitLangItem as uint].get()
198198
}
199-
pub fn bitor_trait(&const self) -> def_id {
199+
pub fn bitor_trait(&self) -> def_id {
200200
self.items[BitOrTraitLangItem as uint].get()
201201
}
202-
pub fn shl_trait(&const self) -> def_id {
202+
pub fn shl_trait(&self) -> def_id {
203203
self.items[ShlTraitLangItem as uint].get()
204204
}
205-
pub fn shr_trait(&const self) -> def_id {
205+
pub fn shr_trait(&self) -> def_id {
206206
self.items[ShrTraitLangItem as uint].get()
207207
}
208-
pub fn index_trait(&const self) -> def_id {
208+
pub fn index_trait(&self) -> def_id {
209209
self.items[IndexTraitLangItem as uint].get()
210210
}
211211

212-
pub fn eq_trait(&const self) -> def_id {
212+
pub fn eq_trait(&self) -> def_id {
213213
self.items[EqTraitLangItem as uint].get()
214214
}
215-
pub fn ord_trait(&const self) -> def_id {
215+
pub fn ord_trait(&self) -> def_id {
216216
self.items[OrdTraitLangItem as uint].get()
217217
}
218218

219-
pub fn str_eq_fn(&const self) -> def_id {
219+
pub fn str_eq_fn(&self) -> def_id {
220220
self.items[StrEqFnLangItem as uint].get()
221221
}
222-
pub fn uniq_str_eq_fn(&const self) -> def_id {
222+
pub fn uniq_str_eq_fn(&self) -> def_id {
223223
self.items[UniqStrEqFnLangItem as uint].get()
224224
}
225-
pub fn annihilate_fn(&const self) -> def_id {
225+
pub fn annihilate_fn(&self) -> def_id {
226226
self.items[AnnihilateFnLangItem as uint].get()
227227
}
228-
pub fn log_type_fn(&const self) -> def_id {
228+
pub fn log_type_fn(&self) -> def_id {
229229
self.items[LogTypeFnLangItem as uint].get()
230230
}
231-
pub fn fail_fn(&const self) -> def_id {
231+
pub fn fail_fn(&self) -> def_id {
232232
self.items[FailFnLangItem as uint].get()
233233
}
234-
pub fn fail_bounds_check_fn(&const self) -> def_id {
234+
pub fn fail_bounds_check_fn(&self) -> def_id {
235235
self.items[FailBoundsCheckFnLangItem as uint].get()
236236
}
237-
pub fn exchange_malloc_fn(&const self) -> def_id {
237+
pub fn exchange_malloc_fn(&self) -> def_id {
238238
self.items[ExchangeMallocFnLangItem as uint].get()
239239
}
240-
pub fn exchange_free_fn(&const self) -> def_id {
240+
pub fn exchange_free_fn(&self) -> def_id {
241241
self.items[ExchangeFreeFnLangItem as uint].get()
242242
}
243-
pub fn malloc_fn(&const self) -> def_id {
243+
pub fn malloc_fn(&self) -> def_id {
244244
self.items[MallocFnLangItem as uint].get()
245245
}
246-
pub fn free_fn(&const self) -> def_id {
246+
pub fn free_fn(&self) -> def_id {
247247
self.items[FreeFnLangItem as uint].get()
248248
}
249-
pub fn borrow_as_imm_fn(&const self) -> def_id {
249+
pub fn borrow_as_imm_fn(&self) -> def_id {
250250
self.items[BorrowAsImmFnLangItem as uint].get()
251251
}
252-
pub fn borrow_as_mut_fn(&const self) -> def_id {
252+
pub fn borrow_as_mut_fn(&self) -> def_id {
253253
self.items[BorrowAsMutFnLangItem as uint].get()
254254
}
255-
pub fn return_to_mut_fn(&const self) -> def_id {
255+
pub fn return_to_mut_fn(&self) -> def_id {
256256
self.items[ReturnToMutFnLangItem as uint].get()
257257
}
258-
pub fn check_not_borrowed_fn(&const self) -> def_id {
258+
pub fn check_not_borrowed_fn(&self) -> def_id {
259259
self.items[CheckNotBorrowedFnLangItem as uint].get()
260260
}
261-
pub fn strdup_uniq_fn(&const self) -> def_id {
261+
pub fn strdup_uniq_fn(&self) -> def_id {
262262
self.items[StrDupUniqFnLangItem as uint].get()
263263
}
264-
pub fn record_borrow_fn(&const self) -> def_id {
264+
pub fn record_borrow_fn(&self) -> def_id {
265265
self.items[RecordBorrowFnLangItem as uint].get()
266266
}
267-
pub fn unrecord_borrow_fn(&const self) -> def_id {
267+
pub fn unrecord_borrow_fn(&self) -> def_id {
268268
self.items[UnrecordBorrowFnLangItem as uint].get()
269269
}
270-
pub fn start_fn(&const self) -> def_id {
270+
pub fn start_fn(&self) -> def_id {
271271
self.items[StartFnLangItem as uint].get()
272272
}
273273
pub fn ty_desc(&const self) -> def_id {

src/librustc/middle/liveness.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ fn visit_fn(fk: &visit::fn_kind,
368368
match *fk {
369369
fk_method(_, _, method) => {
370370
match method.explicit_self.node {
371-
sty_value | sty_region(*) | sty_box(_) | sty_uniq(_) => {
371+
sty_value | sty_region(*) | sty_box(_) | sty_uniq => {
372372
fn_maps.add_variable(Arg(method.self_id,
373373
special_idents::self_));
374374
}

src/librustc/middle/trans/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ fn const_expr_unadjusted(cx: @mut CrateContext, e: &ast::expr) -> ValueRef {
340340
let is_float = ty::type_is_fp(ty);
341341
return match u {
342342
ast::box(_) |
343-
ast::uniq(_) |
343+
ast::uniq |
344344
ast::deref => {
345345
let (dv, _dt) = const_deref(cx, te, ty, true);
346346
dv

src/librustc/middle/trans/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1314,7 +1314,7 @@ fn trans_unary_datum(bcx: block,
13141314
trans_boxed_expr(bcx, un_ty, sub_expr, sub_ty,
13151315
heap_managed)
13161316
}
1317-
ast::uniq(_) => {
1317+
ast::uniq => {
13181318
let heap = heap_for_unique(bcx, un_ty);
13191319
trans_boxed_expr(bcx, un_ty, sub_expr, sub_ty, heap)
13201320
}

src/librustc/middle/trans/meth.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ pub fn trans_trait_callee(bcx: block,
532532
let llpair = match explicit_self {
533533
ast::sty_region(*) => Load(bcx, llpair),
534534
ast::sty_static | ast::sty_value |
535-
ast::sty_box(_) | ast::sty_uniq(_) => llpair
535+
ast::sty_box(_) | ast::sty_uniq => llpair
536536
};
537537

538538
let callee_ty = node_id_type(bcx, callee_id);
@@ -622,7 +622,7 @@ pub fn trans_trait_callee_from_llval(bcx: block,
622622

623623
self_mode = ty::ByRef;
624624
}
625-
ast::sty_uniq(_) => {
625+
ast::sty_uniq => {
626626
// Pass the unique pointer.
627627
match store {
628628
ty::UniqTraitStore => llself = llbox,

src/librustc/middle/trans/type_use.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ pub fn mark_for_method_call(cx: &Context, e_id: node_id, callee_id: node_id) {
278278
pub fn mark_for_expr(cx: &Context, e: &expr) {
279279
match e.node {
280280
expr_vstore(_, _) | expr_vec(_, _) | expr_struct(*) | expr_tup(_) |
281-
expr_unary(_, box(_), _) | expr_unary(_, uniq(_), _) |
281+
expr_unary(_, box(_), _) | expr_unary(_, uniq, _) |
282282
expr_binary(_, add, _, _) | expr_copy(_) | expr_repeat(*) => {
283283
node_type_needs(cx, use_repr, e.id);
284284
}

src/librustc/middle/ty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3696,14 +3696,14 @@ pub enum DtorKind {
36963696
}
36973697

36983698
impl DtorKind {
3699-
pub fn is_not_present(&const self) -> bool {
3699+
pub fn is_not_present(&self) -> bool {
37003700
match *self {
37013701
NoDtor => true,
37023702
_ => false
37033703
}
37043704
}
37053705

3706-
pub fn is_present(&const self) -> bool {
3706+
pub fn is_present(&self) -> bool {
37073707
!self.is_not_present()
37083708
}
37093709

src/librustc/middle/typeck/astconv.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -662,10 +662,10 @@ fn ty_of_method_or_bare_fn<AC:AstConv,RS:region_scope + Copy + 'static>(
662662
ty::mt {ty: self_info.untransformed_self_ty,
663663
mutbl: mutability}))
664664
}
665-
ast::sty_uniq(mutability) => {
665+
ast::sty_uniq => {
666666
Some(ty::mk_uniq(this.tcx(),
667667
ty::mt {ty: self_info.untransformed_self_ty,
668-
mutbl: mutability}))
668+
mutbl: ast::m_imm}))
669669
}
670670
}
671671
}

src/librustc/middle/typeck/check/method.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1123,11 +1123,11 @@ impl<'self> LookupContext<'self> {
11231123
}
11241124
}
11251125

1126-
sty_uniq(m) => {
1126+
sty_uniq => {
11271127
debug!("(is relevant?) explicit self is a unique pointer");
11281128
match ty::get(rcvr_ty).sty {
11291129
ty::ty_uniq(mt) => {
1130-
mutability_matches(mt.mutbl, m) &&
1130+
mutability_matches(mt.mutbl, ast::m_imm) &&
11311131
self.fcx.can_mk_subty(mt.ty, candidate.rcvr_ty).is_ok()
11321132
}
11331133

src/librustc/middle/typeck/check/mod.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -2301,7 +2301,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
23012301
ast::expr_unary(callee_id, unop, oprnd) => {
23022302
let exp_inner = do unpack_expected(fcx, expected) |sty| {
23032303
match unop {
2304-
ast::box(_) | ast::uniq(_) => match *sty {
2304+
ast::box(_) | ast::uniq => match *sty {
23052305
ty::ty_box(ref mt) | ty::ty_uniq(ref mt) => Some(mt.ty),
23062306
_ => None
23072307
},
@@ -2318,9 +2318,10 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
23182318
oprnd_t = ty::mk_box(tcx,
23192319
ty::mt {ty: oprnd_t, mutbl: mutbl});
23202320
}
2321-
ast::uniq(mutbl) => {
2321+
ast::uniq => {
23222322
oprnd_t = ty::mk_uniq(tcx,
2323-
ty::mt {ty: oprnd_t, mutbl: mutbl});
2323+
ty::mt {ty: oprnd_t,
2324+
mutbl: ast::m_imm});
23242325
}
23252326
ast::deref => {
23262327
let sty = structure_of(fcx, expr.span, oprnd_t);

0 commit comments

Comments
 (0)