Skip to content

Commit 58f248d

Browse files
committed
test: Fix tests. rs=tests
1 parent aa4c19b commit 58f248d

Some content is hidden

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

42 files changed

+110
-98
lines changed

doc/rust.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,8 +1181,8 @@ Traits are implemented for specific types through separate [implementations](#im
11811181
# type BoundingBox = int;
11821182
11831183
trait Shape {
1184-
fn draw(Surface);
1185-
fn bounding_box() -> BoundingBox;
1184+
fn draw(&self, Surface);
1185+
fn bounding_box(&self) -> BoundingBox;
11861186
}
11871187
~~~~
11881188

@@ -1195,9 +1195,9 @@ These appear after the trait name, using the same syntax used in [generic functi
11951195

11961196
~~~~
11971197
trait Seq<T> {
1198-
fn len() -> uint;
1199-
fn elt_at(n: uint) -> T;
1200-
fn iter(&fn(T));
1198+
fn len(&self) -> uint;
1199+
fn elt_at(&self, n: uint) -> T;
1200+
fn iter(&self, &fn(T));
12011201
}
12021202
~~~~
12031203

@@ -1209,7 +1209,7 @@ For example:
12091209

12101210
~~~~
12111211
# type Surface = int;
1212-
# trait Shape { fn draw(Surface); }
1212+
# trait Shape { fn draw(&self, Surface); }
12131213
12141214
fn draw_twice<T: Shape>(surface: Surface, sh: T) {
12151215
sh.draw(surface);
@@ -1271,8 +1271,8 @@ methods of the supertrait may be called on values of subtrait-bound type paramet
12711271
Refering to the previous example of `trait Circle : Shape`:
12721272

12731273
~~~
1274-
# trait Shape { fn area() -> float; }
1275-
# trait Circle : Shape { fn radius() -> float; }
1274+
# trait Shape { fn area(&self) -> float; }
1275+
# trait Circle : Shape { fn radius(&self) -> float; }
12761276
fn radius_times_area<T: Circle>(c: T) -> float {
12771277
// `c` is both a Circle and a Shape
12781278
c.radius() * c.area()
@@ -1282,10 +1282,10 @@ fn radius_times_area<T: Circle>(c: T) -> float {
12821282
Likewise, supertrait methods may also be called on trait objects.
12831283

12841284
~~~ {.xfail-test}
1285-
# trait Shape { fn area() -> float; }
1286-
# trait Circle : Shape { fn radius() -> float; }
1287-
# impl Shape for int { fn area() -> float { 0.0 } }
1288-
# impl Circle for int { fn radius() -> float { 0.0 } }
1285+
# trait Shape { fn area(&self) -> float; }
1286+
# trait Circle : Shape { fn radius(&self) -> float; }
1287+
# impl Shape for int { fn area(&self) -> float { 0.0 } }
1288+
# impl Circle for int { fn radius(&self) -> float { 0.0 } }
12891289
# let mycircle = 0;
12901290
12911291
let mycircle: Circle = @mycircle as @Circle;
@@ -1302,7 +1302,7 @@ Implementations are defined with the keyword `impl`.
13021302
# struct Point {x: float, y: float};
13031303
# type Surface = int;
13041304
# struct BoundingBox {x: float, y: float, width: float, height: float};
1305-
# trait Shape { fn draw(Surface); fn bounding_box() -> BoundingBox; }
1305+
# trait Shape { fn draw(&self, Surface); fn bounding_box(&self) -> BoundingBox; }
13061306
# fn do_draw_circle(s: Surface, c: Circle) { }
13071307
13081308
struct Circle {
@@ -1311,8 +1311,8 @@ struct Circle {
13111311
}
13121312
13131313
impl Shape for Circle {
1314-
fn draw(s: Surface) { do_draw_circle(s, self); }
1315-
fn bounding_box() -> BoundingBox {
1314+
fn draw(&self, s: Surface) { do_draw_circle(s, *self); }
1315+
fn bounding_box(&self) -> BoundingBox {
13161316
let r = self.radius;
13171317
BoundingBox{x: self.center.x - r, y: self.center.y - r,
13181318
width: 2.0 * r, height: 2.0 * r}
@@ -2678,11 +2678,11 @@ An example of an object type:
26782678

26792679
~~~~~~~~
26802680
trait Printable {
2681-
fn to_str() -> ~str;
2681+
fn to_str(&self) -> ~str;
26822682
}
26832683
26842684
impl Printable for int {
2685-
fn to_str() -> ~str { int::to_str(self) }
2685+
fn to_str(&self) -> ~str { int::to_str(*self) }
26862686
}
26872687
26882688
fn print(a: @Printable) {
@@ -2721,11 +2721,11 @@ example, in:
27212721

27222722
~~~~~~~~
27232723
trait Printable {
2724-
fn make_string() -> ~str;
2724+
fn make_string(&self) -> ~str;
27252725
}
27262726
27272727
impl Printable for ~str {
2728-
fn make_string() -> ~str { copy self }
2728+
fn make_string(&self) -> ~str { copy *self }
27292729
}
27302730
~~~~~~~~
27312731

src/libcore/rt/thread_local_storage.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use libc::{c_void};
1212
#[cfg(unix)]
13-
use libc::{c_uint, c_int};
13+
use libc::{c_uint, c_ulong, c_int};
1414
#[cfg(unix)]
1515
use ptr::null;
1616
#[cfg(windows)]
@@ -34,7 +34,12 @@ pub unsafe fn get(key: Key) -> *mut c_void {
3434
unsafe { pthread_getspecific(key) }
3535
}
3636

37-
#[cfg(unix)]
37+
#[cfg(target_os="macos")]
38+
#[allow(non_camel_case_types)] // foreign type
39+
type pthread_key_t = c_ulong;
40+
41+
#[cfg(target_os="linux")]
42+
#[cfg(target_os="freebsd")]
3843
#[allow(non_camel_case_types)] // foreign type
3944
type pthread_key_t = c_uint;
4045

src/libsyntax/parse/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ mod test {
312312
@~"fn foo (x : int) { x; }",
313313
~[],
314314
new_parse_sess(None));
315-
check_equal(to_json_str(@tts as Encodable::<std::json::Encoder>),
315+
check_equal(to_json_str(@tts as @Encodable<std::json::Encoder>),
316316
~"[[\"tt_tok\",[,[\"IDENT\",[\"fn\",false]]]],\
317317
[\"tt_tok\",[,[\"IDENT\",[\"foo\",false]]]],\
318318
[\"tt_delim\",[[[\"tt_tok\",[,[\"LPAREN\",[]]]],\

src/libsyntax/syntax.rc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#[allow(vecs_implicitly_copyable)];
2323
#[allow(non_camel_case_types)];
2424
#[allow(deprecated_mode)];
25-
#[deny(deprecated_self)];
2625

2726
#[no_core];
2827

src/test/auxiliary/ambig_impl_2_lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
trait me {
1212
fn me(&self) -> uint;
1313
}
14-
impl me for uint { fn me(&self) -> uint { self } }
14+
impl me for uint { fn me(&self) -> uint { *self } }

src/test/compile-fail/ambig_impl_2_exe.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
extern mod ambig_impl_2_lib;
1414
use ambig_impl_2_lib::me;
1515
trait me {
16-
fn me() -> uint;
16+
fn me(&self) -> uint;
1717
}
18-
impl me for uint { fn me() -> uint { self } } //~ NOTE is `__extensions__::me`
18+
impl me for uint { fn me(&self) -> uint { *self } } //~ NOTE is `__extensions__::me`
1919
fn main() { 1u.me(); } //~ ERROR multiple applicable methods in scope
2020
//~^ NOTE is `ambig_impl_2_lib::__extensions__::me`

src/test/compile-fail/ambig_impl_bounds.rs

Lines changed: 2 additions & 2 deletions
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-
trait A { fn foo(); }
12-
trait B { fn foo(); }
11+
trait A { fn foo(&self); }
12+
trait B { fn foo(&self); }
1313

1414
fn foo<T:A + B>(t: T) {
1515
t.foo(); //~ ERROR multiple applicable methods in scope

src/test/compile-fail/borrowck-autoref-3261.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
struct X(Either<(uint,uint),extern fn()>);
1212

13-
pub impl &'self X {
14-
fn with(self, blk: &fn(x: &Either<(uint,uint),extern fn()>)) {
13+
pub impl X {
14+
fn with(&self, blk: &fn(x: &Either<(uint,uint),extern fn()>)) {
1515
blk(&**self)
1616
}
1717
}

src/test/compile-fail/class-cast-to-trait.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ priv impl cat {
4949
}
5050
}
5151

52-
fn cat(&self, in_x : uint, in_y : int, in_name: ~str) -> cat {
52+
fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat {
5353
cat {
5454
meows: in_x,
5555
how_hungry: in_y,

src/test/compile-fail/infinite-instantiation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ trait to_opt {
1717

1818
impl to_opt for uint {
1919
fn to_option(&self) -> Option<uint> {
20-
Some(self)
20+
Some(*self)
2121
}
2222
}
2323

2424
impl<T:Copy> to_opt for Option<T> {
2525
fn to_option(&self) -> Option<Option<T>> {
26-
Some(self)
26+
Some(*self)
2727
}
2828
}
2929

0 commit comments

Comments
 (0)