Skip to content

Commit b29c368

Browse files
committed
Removing a lot of usage of '&const'
1 parent 0326b0a commit b29c368

File tree

17 files changed

+105
-137
lines changed

17 files changed

+105
-137
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/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/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/check/vtable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub struct VtableContext {
6464
}
6565

6666
impl VtableContext {
67-
pub fn tcx(&const self) -> ty::ctxt { self.ccx.tcx }
67+
pub fn tcx(&self) -> ty::ctxt { self.ccx.tcx }
6868
}
6969

7070
fn has_trait_bounds(type_param_defs: &[ty::TypeParameterDef]) -> bool {

src/libstd/at_vec.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub fn build_sized_opt<A>(size: Option<uint>,
108108
/// Iterates over the `rhs` vector, copying each element and appending it to the
109109
/// `lhs`. Afterwards, the `lhs` is then returned for use again.
110110
#[inline]
111-
pub fn append<T:Copy>(lhs: @[T], rhs: &const [T]) -> @[T] {
111+
pub fn append<T:Copy>(lhs: @[T], rhs: &[T]) -> @[T] {
112112
do build_sized(lhs.len() + rhs.len()) |push| {
113113
for lhs.iter().advance |x| { push(copy *x); }
114114
for uint::range(0, rhs.len()) |i| { push(copy rhs[i]); }
@@ -180,9 +180,9 @@ pub mod traits {
180180
use kinds::Copy;
181181
use ops::Add;
182182

183-
impl<'self,T:Copy> Add<&'self const [T],@[T]> for @[T] {
183+
impl<'self,T:Copy> Add<&'self [T],@[T]> for @[T] {
184184
#[inline]
185-
fn add(&self, rhs: & &'self const [T]) -> @[T] {
185+
fn add(&self, rhs: & &'self [T]) -> @[T] {
186186
append(*self, (*rhs))
187187
}
188188
}

src/libstd/hashmap.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,10 @@ impl<K:Hash + Eq,V> HashMap<K, V> {
282282

283283
impl<K:Hash + Eq,V> Container for HashMap<K, V> {
284284
/// Return the number of elements in the map
285-
fn len(&const self) -> uint { self.size }
285+
fn len(&self) -> uint { self.size }
286286

287287
/// Return true if the map contains no elements
288-
fn is_empty(&const self) -> bool { self.len() == 0 }
288+
fn is_empty(&self) -> bool { self.len() == 0 }
289289
}
290290

291291
impl<K:Hash + Eq,V> Mutable for HashMap<K, V> {
@@ -623,10 +623,10 @@ impl<T:Hash + Eq> Eq for HashSet<T> {
623623

624624
impl<T:Hash + Eq> Container for HashSet<T> {
625625
/// Return the number of elements in the set
626-
fn len(&const self) -> uint { self.map.len() }
626+
fn len(&self) -> uint { self.map.len() }
627627

628628
/// Return true if the set contains no elements
629-
fn is_empty(&const self) -> bool { self.map.is_empty() }
629+
fn is_empty(&self) -> bool { self.map.is_empty() }
630630
}
631631

632632
impl<T:Hash + Eq> Mutable for HashSet<T> {

src/libstd/io.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ impl<W:Writer,C> Writer for Wrapper<W, C> {
11521152
impl Writer for *libc::FILE {
11531153
fn write(&self, v: &[u8]) {
11541154
unsafe {
1155-
do vec::as_const_buf(v) |vbuf, len| {
1155+
do vec::as_imm_buf(v) |vbuf, len| {
11561156
let nout = libc::fwrite(vbuf as *c_void,
11571157
1,
11581158
len as size_t,
@@ -1203,9 +1203,9 @@ impl Writer for fd_t {
12031203
fn write(&self, v: &[u8]) {
12041204
unsafe {
12051205
let mut count = 0u;
1206-
do vec::as_const_buf(v) |vbuf, len| {
1206+
do vec::as_imm_buf(v) |vbuf, len| {
12071207
while count < len {
1208-
let vb = ptr::const_offset(vbuf, count) as *c_void;
1208+
let vb = ptr::offset(vbuf, count) as *c_void;
12091209
let nout = libc::write(*self, vb, len as size_t);
12101210
if nout < 0 as ssize_t {
12111211
error!("error writing buffer");

src/libstd/option.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,13 @@ impl<T> Option<T> {
121121

122122
/// Returns true if the option equals `none`
123123
#[inline]
124-
pub fn is_none(&const self) -> bool {
124+
pub fn is_none(&self) -> bool {
125125
match *self { None => true, Some(_) => false }
126126
}
127127

128128
/// Returns true if the option contains some value
129129
#[inline]
130-
pub fn is_some(&const self) -> bool { !self.is_none() }
130+
pub fn is_some(&self) -> bool { !self.is_none() }
131131

132132
/// Update an optional value by optionally running its content through a
133133
/// function that returns an option.

0 commit comments

Comments
 (0)