Skip to content

Commit a6d9689

Browse files
committed
auto merge of #5136 : pcwalton/rust/impl-publicizing, r=pcwalton
2 parents 061a223 + 07c3f5c commit a6d9689

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+367
-394
lines changed

doc/tutorial.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,7 @@ points to.
11261126
11271127
~~~
11281128
let managed = @mut 10;
1129-
let owned = ~mut 20;
1129+
let mut owned = ~20;
11301130

11311131
let mut value = 30;
11321132
let borrowed = &mut value;

src/libcore/at_vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ pub mod traits {
168168
use kinds::Copy;
169169
use ops::Add;
170170

171-
pub impl<T:Copy> Add<&[const T],@[T]> for @[T] {
171+
impl<T:Copy> Add<&[const T],@[T]> for @[T] {
172172
#[inline(always)]
173173
pure fn add(&self, rhs: & &self/[const T]) -> @[T] {
174174
append(*self, (*rhs))

src/libcore/dvec.rs

+1-13
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,6 @@ impl<A> DVec<A> {
133133
self.check_out(|v| self.give_back(f(v)))
134134
}
135135
136-
/**
137-
* Swaps out the current vector and hands it off to a user-provided
138-
* function `f`. The function should transform it however is desired
139-
* and return a new vector to replace it with.
140-
*/
141-
#[inline(always)]
142-
fn swap_mut(f: &fn(v: ~[mut A]) -> ~[mut A]) {
143-
do self.swap |v| {
144-
vec::cast_from_mut(f(vec::cast_to_mut(v)))
145-
}
146-
}
147-
148136
/// Returns the number of elements currently in the dvec
149137
#[inline(always)]
150138
pure fn len() -> uint {
@@ -217,7 +205,7 @@ impl<A> DVec<A> {
217205
}
218206
219207
/// Gives access to the vector as a slice with mutable contents
220-
fn borrow_mut<R>(op: fn(x: &[mut A]) -> R) -> R {
208+
fn borrow_mut<R>(op: &fn(x: &mut [A]) -> R) -> R {
221209
do self.check_out |v| {
222210
let mut v = v;
223211
let result = op(v);

src/libcore/num/f32.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ impl num::One for f32 {
284284
static pure fn one() -> f32 { 1.0 }
285285
}
286286

287-
pub impl NumCast for f32 {
287+
impl NumCast for f32 {
288288
/**
289289
* Cast `n` to an `f32`
290290
*/

src/libcore/num/f64.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ impl cmp::Ord for f64 {
299299
pure fn gt(&self, other: &f64) -> bool { (*self) > (*other) }
300300
}
301301

302-
pub impl NumCast for f64 {
302+
impl NumCast for f64 {
303303
/**
304304
* Cast `n` to an `f64`
305305
*/

src/libcore/num/float.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ impl num::One for float {
420420
static pure fn one() -> float { 1.0 }
421421
}
422422
423-
pub impl NumCast for float {
423+
impl NumCast for float {
424424
/**
425425
* Cast `n` to a `float`
426426
*/

src/libcore/num/int-template/i16.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ mod inst {
1717
pub const bits: uint = ::u16::bits;
1818
}
1919

20-
pub impl NumCast for i16 {
20+
impl NumCast for i16 {
2121
/**
2222
* Cast `n` to a `i16`
2323
*/

src/libcore/num/int-template/i32.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ mod inst {
1717
pub const bits: uint = ::u32::bits;
1818
}
1919

20-
pub impl NumCast for i32 {
20+
impl NumCast for i32 {
2121
/**
2222
* Cast `n` to a `i32`
2323
*/

src/libcore/num/int-template/i64.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ mod inst {
1717
pub const bits: uint = ::u64::bits;
1818
}
1919

20-
pub impl NumCast for i64 {
20+
impl NumCast for i64 {
2121
/**
2222
* Cast `n` to a `i64`
2323
*/

src/libcore/num/int-template/i8.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ mod inst {
1717
pub const bits: uint = ::u8::bits;
1818
}
1919

20-
pub impl NumCast for i8 {
20+
impl NumCast for i8 {
2121
/**
2222
* Cast `n` to a `i8`
2323
*/

src/libcore/num/int-template/int.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ mod inst {
5858
}
5959
}
6060

61-
pub impl NumCast for int {
61+
impl NumCast for int {
6262
/**
6363
* Cast `n` to a `int`
6464
*/

src/libcore/num/uint-template/u16.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ mod inst {
1919
pub const bits: uint = 16;
2020
}
2121

22-
pub impl NumCast for u16 {
22+
impl NumCast for u16 {
2323
/**
2424
* Cast `n` to a `u16`
2525
*/

src/libcore/num/uint-template/u32.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ mod inst {
1919
pub const bits: uint = 32;
2020
}
2121

22-
pub impl NumCast for u32 {
22+
impl NumCast for u32 {
2323
/**
2424
* Cast `n` to a `u32`
2525
*/

src/libcore/num/uint-template/u64.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ mod inst {
1919
pub const bits: uint = 64;
2020
}
2121

22-
pub impl NumCast for u64 {
22+
impl NumCast for u64 {
2323
/**
2424
* Cast `n` to a `u64`
2525
*/

src/libcore/num/uint-template/u8.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ mod inst {
2626
pub pure fn is_ascii(x: T) -> bool { return 0 as T == x & 128 as T; }
2727
}
2828

29-
pub impl NumCast for u8 {
29+
impl NumCast for u8 {
3030
/**
3131
* Cast `n` to a `u8`
3232
*/

src/libcore/num/uint-template/uint.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ pub mod inst {
110110
return true;
111111
}
112112

113-
pub impl iter::Times for uint {
113+
impl iter::Times for uint {
114114
#[inline(always)]
115115
/**
116116
* A convenience form for basic iteration. Given a uint `x`,
@@ -209,7 +209,7 @@ pub mod inst {
209209
}
210210
}
211211

212-
pub impl NumCast for uint {
212+
impl NumCast for uint {
213213
/**
214214
* Cast `n` to a `uint`
215215
*/

src/libcore/option.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub enum Option<T> {
5656
Some(T),
5757
}
5858

59-
pub impl<T:Ord> Ord for Option<T> {
59+
impl<T:Ord> Ord for Option<T> {
6060
pure fn lt(&self, other: &Option<T>) -> bool {
6161
match (self, other) {
6262
(&None, &None) => false,

src/libcore/os.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub mod win32 {
109109
let mut done = false;
110110
while !done {
111111
let mut k: DWORD = 0;
112-
let buf = vec::cast_to_mut(vec::from_elem(n as uint, 0u16));
112+
let mut buf = vec::from_elem(n as uint, 0u16);
113113
do vec::as_mut_buf(buf) |b, _sz| {
114114
k = f(b, TMPBUF_SZ as DWORD);
115115
if k == (0 as DWORD) {

src/libcore/owned.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@
1313
use cmp::{Eq, Ord};
1414

1515
#[cfg(notest)]
16-
impl<T:Eq> Eq for ~const T {
16+
impl<T:Eq> Eq for ~T {
1717
#[inline(always)]
18-
pure fn eq(&self, other: &~const T) -> bool { *(*self) == *(*other) }
18+
pure fn eq(&self, other: &~T) -> bool { *(*self) == *(*other) }
1919
#[inline(always)]
20-
pure fn ne(&self, other: &~const T) -> bool { *(*self) != *(*other) }
20+
pure fn ne(&self, other: &~T) -> bool { *(*self) != *(*other) }
2121
}
2222

2323
#[cfg(notest)]
24-
impl<T:Ord> Ord for ~const T {
24+
impl<T:Ord> Ord for ~T {
2525
#[inline(always)]
26-
pure fn lt(&self, other: &~const T) -> bool { *(*self) < *(*other) }
26+
pure fn lt(&self, other: &~T) -> bool { *(*self) < *(*other) }
2727
#[inline(always)]
28-
pure fn le(&self, other: &~const T) -> bool { *(*self) <= *(*other) }
28+
pure fn le(&self, other: &~T) -> bool { *(*self) <= *(*other) }
2929
#[inline(always)]
30-
pure fn ge(&self, other: &~const T) -> bool { *(*self) >= *(*other) }
30+
pure fn ge(&self, other: &~T) -> bool { *(*self) >= *(*other) }
3131
#[inline(always)]
32-
pure fn gt(&self, other: &~const T) -> bool { *(*self) > *(*other) }
32+
pure fn gt(&self, other: &~T) -> bool { *(*self) > *(*other) }
3333
}
3434

src/libcore/str.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2362,7 +2362,7 @@ pub trait OwnedStr {
23622362
fn push_char(&mut self, c: char);
23632363
}
23642364

2365-
pub impl OwnedStr for ~str {
2365+
impl OwnedStr for ~str {
23662366
fn push_str(&mut self, v: &str) {
23672367
push_str(self, v);
23682368
}

src/libcore/to_bytes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ impl IterBytes for char {
170170
pub mod x32 {
171171
use to_bytes::{Cb, IterBytes};
172172

173-
pub impl IterBytes for uint {
173+
impl IterBytes for uint {
174174
#[inline(always)]
175175
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
176176
(*self as u32).iter_bytes(lsb0, f)
@@ -182,7 +182,7 @@ pub mod x32 {
182182
pub mod x64 {
183183
use to_bytes::{Cb, IterBytes};
184184

185-
pub impl IterBytes for uint {
185+
impl IterBytes for uint {
186186
#[inline(always)]
187187
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
188188
(*self as u64).iter_bytes(lsb0, f)

src/libcore/vec.rs

+8-37
Original file line numberDiff line numberDiff line change
@@ -209,16 +209,6 @@ pub pure fn build_sized_opt<A>(size: Option<uint>,
209209
build_sized(size.get_or_default(4), builder)
210210
}
211211

212-
/// Produces a mut vector from an immutable vector.
213-
pub pure fn cast_to_mut<T>(v: ~[T]) -> ~[mut T] {
214-
unsafe { ::cast::transmute(v) }
215-
}
216-
217-
/// Produces an immutable vector from a mut vector.
218-
pub pure fn cast_from_mut<T>(v: ~[mut T]) -> ~[T] {
219-
unsafe { ::cast::transmute(v) }
220-
}
221-
222212
// Accessors
223213

224214
/// Returns the first element of a vector
@@ -274,9 +264,10 @@ pub pure fn slice<T>(v: &r/[T], start: uint, end: uint) -> &r/[T] {
274264
275265
/// Return a slice that points into another slice.
276266
#[inline(always)]
277-
pub pure fn mut_slice<T>(v: &r/[mut T], start: uint,
278-
end: uint) -> &r/[mut T] {
279-
267+
pub pure fn mut_slice<T>(v: &r/mut [T],
268+
start: uint,
269+
end: uint)
270+
-> &r/mut [T] {
280271
assert (start <= end);
281272
assert (end <= len(v));
282273
do as_mut_buf(v) |p, _len| {
@@ -290,8 +281,10 @@ pub pure fn mut_slice<T>(v: &r/[mut T], start: uint,
290281
291282
/// Return a slice that points into another slice.
292283
#[inline(always)]
293-
pub pure fn const_slice<T>(v: &r/[const T], start: uint,
294-
end: uint) -> &r/[const T] {
284+
pub pure fn const_slice<T>(v: &r/[const T],
285+
start: uint,
286+
end: uint)
287+
-> &r/[const T] {
295288
assert (start <= end);
296289
assert (end <= len(v));
297290
do as_const_buf(v) |p, _len| {
@@ -3337,28 +3330,6 @@ mod tests {
33373330
let _x = windowed (0u, ~[1u,2u,3u,4u,5u,6u]);
33383331
}
33393332

3340-
#[test]
3341-
fn cast_to_mut_no_copy() {
3342-
unsafe {
3343-
let x = ~[1, 2, 3];
3344-
let addr = raw::to_ptr(x);
3345-
let x_mut = cast_to_mut(x);
3346-
let addr_mut = raw::to_ptr(x_mut);
3347-
assert addr == addr_mut;
3348-
}
3349-
}
3350-
3351-
#[test]
3352-
fn cast_from_mut_no_copy() {
3353-
unsafe {
3354-
let x = ~[mut 1, 2, 3];
3355-
let addr = raw::to_ptr(x);
3356-
let x_imm = cast_from_mut(x);
3357-
let addr_imm = raw::to_ptr(x_imm);
3358-
assert addr == addr_imm;
3359-
}
3360-
}
3361-
33623333
#[test]
33633334
fn test_unshift() {
33643335
let mut x = ~[1, 2, 3];

src/librustc/middle/borrowck/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ impl LoanKind {
451451

452452
/// Creates and returns a new root_map
453453
454-
pub impl to_bytes::IterBytes for root_map_key {
454+
impl to_bytes::IterBytes for root_map_key {
455455
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
456456
to_bytes::iter_bytes_2(&self.id, &self.derefs, lsb0, f);
457457
}

src/librustc/middle/mem_categorization.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -281,12 +281,12 @@ pub trait ast_node {
281281
fn span(&self) -> span;
282282
}
283283

284-
pub impl ast_node for @ast::expr {
284+
impl ast_node for @ast::expr {
285285
fn id(&self) -> ast::node_id { self.id }
286286
fn span(&self) -> span { self.span }
287287
}
288288

289-
pub impl ast_node for @ast::pat {
289+
impl ast_node for @ast::pat {
290290
fn id(&self) -> ast::node_id { self.id }
291291
fn span(&self) -> span { self.span }
292292
}
@@ -295,7 +295,7 @@ pub trait get_type_for_node {
295295
fn ty<N:ast_node>(&self, node: N) -> ty::t;
296296
}
297297

298-
pub impl get_type_for_node for ty::ctxt {
298+
impl get_type_for_node for ty::ctxt {
299299
fn ty<N:ast_node>(&self, node: N) -> ty::t {
300300
ty::node_id_to_type(*self, node.id())
301301
}

src/librustc/middle/trans/base.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ pub trait get_insn_ctxt {
107107
fn insn_ctxt(&self, s: &str) -> icx_popper;
108108
}
109109

110-
pub impl get_insn_ctxt for @CrateContext {
110+
impl get_insn_ctxt for @CrateContext {
111111
fn insn_ctxt(&self, s: &str) -> icx_popper {
112112
debug!("new insn_ctxt: %s", s);
113113
if self.sess.count_llvm_insns() {
@@ -117,13 +117,13 @@ pub impl get_insn_ctxt for @CrateContext {
117117
}
118118
}
119119

120-
pub impl get_insn_ctxt for block {
120+
impl get_insn_ctxt for block {
121121
fn insn_ctxt(&self, s: &str) -> icx_popper {
122122
self.ccx().insn_ctxt(s)
123123
}
124124
}
125125

126-
pub impl get_insn_ctxt for fn_ctxt {
126+
impl get_insn_ctxt for fn_ctxt {
127127
fn insn_ctxt(&self, s: &str) -> icx_popper {
128128
self.ccx.insn_ctxt(s)
129129
}

0 commit comments

Comments
 (0)