Removed @self and @Trait.
This commit is contained in:
parent
c13a929d58
commit
b2d30b72bf
122 changed files with 627 additions and 1694 deletions
|
|
@ -8,8 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[feature(managed_boxes)];
|
||||
|
||||
struct pair<A,B> {
|
||||
a: A, b: B
|
||||
}
|
||||
|
|
@ -29,11 +27,11 @@ impl<A:Clone> Invokable<A> for Invoker<A> {
|
|||
}
|
||||
}
|
||||
|
||||
fn f<A:Clone + 'static>(a: A, b: u16) -> @Invokable<A> {
|
||||
@Invoker {
|
||||
fn f<A:Clone + 'static>(a: A, b: u16) -> ~Invokable:<A> {
|
||||
~Invoker {
|
||||
a: a,
|
||||
b: b,
|
||||
} as @Invokable<A>
|
||||
} as ~Invokable:<A>
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
|
|
|
|||
|
|
@ -1,70 +0,0 @@
|
|||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[feature(managed_boxes)];
|
||||
|
||||
use std::cell::RefCell;
|
||||
|
||||
struct Pair<A,B> {
|
||||
a: A, b: B
|
||||
}
|
||||
|
||||
struct RecEnum<A>(Rec<A>);
|
||||
struct Rec<A> {
|
||||
val: A,
|
||||
rec: Option<@RefCell<RecEnum<A>>>
|
||||
}
|
||||
|
||||
fn make_cycle<A:'static>(a: A) {
|
||||
let g: @RefCell<RecEnum<A>> = @RefCell::new(RecEnum(Rec {val: a, rec: None}));
|
||||
{
|
||||
let mut gb = g.borrow_mut();
|
||||
let gg = gb.get();
|
||||
let RecEnum(ref mut gg) = *gg;
|
||||
gg.rec = Some(g);
|
||||
}
|
||||
}
|
||||
|
||||
struct Invoker<A,B> {
|
||||
a: A,
|
||||
b: B,
|
||||
}
|
||||
|
||||
trait Invokable<A,B> {
|
||||
fn f(&self) -> (A, B);
|
||||
}
|
||||
|
||||
impl<A:Clone,B:Clone> Invokable<A,B> for Invoker<A,B> {
|
||||
fn f(&self) -> (A, B) {
|
||||
(self.a.clone(), self.b.clone())
|
||||
}
|
||||
}
|
||||
|
||||
fn f<A:Send + Clone + 'static,
|
||||
B:Send + Clone + 'static>(
|
||||
a: A,
|
||||
b: B)
|
||||
-> @Invokable<A,B> {
|
||||
@Invoker {
|
||||
a: a,
|
||||
b: b,
|
||||
} as @Invokable<A,B>
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let x = 22_u8;
|
||||
let y = 44_u64;
|
||||
let z = f(~x, y);
|
||||
make_cycle(z);
|
||||
let (a, b) = z.f();
|
||||
info!("a={} b={}", *a as uint, b as uint);
|
||||
assert_eq!(*a, x);
|
||||
assert_eq!(b, y);
|
||||
}
|
||||
|
|
@ -8,17 +8,15 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[feature(managed_boxes)];
|
||||
|
||||
trait double {
|
||||
fn double(@self) -> uint;
|
||||
fn double(~self) -> uint;
|
||||
}
|
||||
|
||||
impl double for uint {
|
||||
fn double(@self) -> uint { *self * 2u }
|
||||
fn double(~self) -> uint { *self * 2u }
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let x = @(@3u as @double);
|
||||
let x = ~(~3u as ~double);
|
||||
assert_eq!(x.double(), 6u);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,17 +8,15 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[feature(managed_boxes)];
|
||||
|
||||
trait double {
|
||||
fn double(@self) -> uint;
|
||||
fn double(~self) -> uint;
|
||||
}
|
||||
|
||||
impl double for @uint {
|
||||
fn double(@self) -> uint { **self * 2u }
|
||||
impl double for ~uint {
|
||||
fn double(~self) -> uint { **self * 2u }
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let x = @@@@@3u;
|
||||
let x = ~~~~~3u;
|
||||
assert_eq!(x.double(), 6u);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,17 +8,15 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[feature(managed_boxes)];
|
||||
|
||||
trait double {
|
||||
fn double(@self) -> uint;
|
||||
fn double(~self) -> uint;
|
||||
}
|
||||
|
||||
impl double for uint {
|
||||
fn double(@self) -> uint { *self * 2u }
|
||||
fn double(~self) -> uint { *self * 2u }
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let x = @@3u;
|
||||
let x = ~~3u;
|
||||
assert_eq!(x.double(), 6u);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,17 +8,15 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[feature(managed_boxes)];
|
||||
|
||||
trait double {
|
||||
fn double(@self) -> uint;
|
||||
fn double(~self) -> uint;
|
||||
}
|
||||
|
||||
impl double for uint {
|
||||
fn double(@self) -> uint { *self * 2u }
|
||||
fn double(~self) -> uint { *self * 2u }
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let x = @3u;
|
||||
let x = ~3u;
|
||||
assert_eq!(x.double(), 6u);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[feature(managed_boxes)];
|
||||
|
||||
trait Foo {
|
||||
fn foo(@self);
|
||||
}
|
||||
|
||||
impl Foo for int {
|
||||
fn foo(@self) {
|
||||
println!("Hello world!");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let x = @3 as @Foo;
|
||||
x.foo();
|
||||
}
|
||||
|
|
@ -8,21 +8,19 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[feature(managed_boxes)];
|
||||
|
||||
// xfail-fast
|
||||
// aux-build:cci_class_cast.rs
|
||||
extern mod cci_class_cast;
|
||||
use std::to_str::ToStr;
|
||||
use cci_class_cast::kitty::cat;
|
||||
|
||||
fn print_out(thing: @ToStr, expected: ~str) {
|
||||
fn print_out(thing: ~ToStr, expected: ~str) {
|
||||
let actual = thing.to_str();
|
||||
info!("{}", actual);
|
||||
assert_eq!(actual, expected);
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let nyan : @ToStr = @cat(0u, 2, ~"nyan") as @ToStr;
|
||||
let nyan: ~ToStr = ~cat(0u, 2, ~"nyan") as ~ToStr;
|
||||
print_out(nyan, ~"nyan");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[feature(managed_boxes)];
|
||||
|
||||
// xfail-fast
|
||||
struct cat {
|
||||
meows : uint,
|
||||
|
|
@ -58,13 +56,13 @@ impl ToStr for cat {
|
|||
}
|
||||
}
|
||||
|
||||
fn print_out(thing: @ToStr, expected: ~str) {
|
||||
fn print_out(thing: ~ToStr, expected: ~str) {
|
||||
let actual = thing.to_str();
|
||||
info!("{}", actual);
|
||||
assert_eq!(actual, expected);
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let nyan : @ToStr = @cat(0u, 2, ~"nyan") as @ToStr;
|
||||
let nyan: ~ToStr = ~cat(0u, 2, ~"nyan") as ~ToStr;
|
||||
print_out(nyan, ~"nyan");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[feature(managed_boxes)];
|
||||
|
||||
// If we use GEPi rathern than GEP_tup_like when
|
||||
// storing closure data (as we used to do), the u64 would
|
||||
// overwrite the u16.
|
||||
|
|
@ -33,11 +31,11 @@ impl<A:Clone> Invokable<A> for Invoker<A> {
|
|||
}
|
||||
}
|
||||
|
||||
fn f<A:Clone + 'static>(a: A, b: u16) -> @Invokable<A> {
|
||||
@Invoker {
|
||||
fn f<A:Clone + 'static>(a: A, b: u16) -> ~Invokable:<A> {
|
||||
~Invoker {
|
||||
a: a,
|
||||
b: b,
|
||||
} as @Invokable<A>
|
||||
} as ~Invokable:<A>
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
|
|
|
|||
|
|
@ -1,34 +0,0 @@
|
|||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[feature(managed_boxes)];
|
||||
|
||||
trait Foo {
|
||||
fn f(@self);
|
||||
}
|
||||
|
||||
struct S {
|
||||
x: int
|
||||
}
|
||||
|
||||
impl Foo for S {
|
||||
fn f(@self) {
|
||||
assert_eq!(self.x, 3);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let x = @S { x: 3 };
|
||||
let y = x as @Foo;
|
||||
y.f();
|
||||
y.f();
|
||||
y.f();
|
||||
y.f();
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[feature(managed_boxes)];
|
||||
|
||||
trait Foo {
|
||||
fn f(&self);
|
||||
}
|
||||
|
||||
struct S {
|
||||
x: int
|
||||
}
|
||||
|
||||
impl Foo for S {
|
||||
fn f(&self) {
|
||||
assert_eq!(self.x, 3);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let x = @S { x: 3 };
|
||||
let y = x as @Foo;
|
||||
y.f();
|
||||
}
|
||||
|
|
@ -8,8 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[feature(managed_boxes)];
|
||||
|
||||
static tau: f64 = 2.0*3.14159265358979323;
|
||||
|
||||
struct Point {x: f64, y: f64}
|
||||
|
|
@ -49,7 +47,7 @@ struct thing {
|
|||
|
||||
#[deriving(Clone)]
|
||||
struct A {
|
||||
a: @int
|
||||
a: int
|
||||
}
|
||||
|
||||
fn thing(x: A) -> thing {
|
||||
|
|
@ -59,26 +57,20 @@ fn thing(x: A) -> thing {
|
|||
}
|
||||
|
||||
impl thing {
|
||||
pub fn foo(@self) -> int { *self.x.a }
|
||||
pub fn bar(~self) -> int { *self.x.a }
|
||||
pub fn quux(&self) -> int { *self.x.a }
|
||||
pub fn bar(~self) -> int { self.x.a }
|
||||
pub fn quux(&self) -> int { self.x.a }
|
||||
pub fn baz<'a>(&'a self) -> &'a A { &self.x }
|
||||
pub fn spam(self) -> int { *self.x.a }
|
||||
pub fn spam(self) -> int { self.x.a }
|
||||
}
|
||||
|
||||
trait Nus { fn f(&self); }
|
||||
impl Nus for thing { fn f(&self) {} }
|
||||
|
||||
pub fn main() {
|
||||
|
||||
let x = @thing(A {a: @10});
|
||||
assert_eq!(x.foo(), 10);
|
||||
assert_eq!(x.quux(), 10);
|
||||
|
||||
let y = ~thing(A {a: @10});
|
||||
let y = ~thing(A {a: 10});
|
||||
assert_eq!(y.clone().bar(), 10);
|
||||
assert_eq!(y.quux(), 10);
|
||||
|
||||
let z = thing(A {a: @11});
|
||||
let z = thing(A {a: 11});
|
||||
assert_eq!(z.spam(), 11);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[feature(managed_boxes)];
|
||||
|
||||
trait Foo<T> {
|
||||
fn get(&self) -> T;
|
||||
}
|
||||
|
|
@ -25,7 +23,7 @@ impl Foo<int> for S {
|
|||
}
|
||||
|
||||
pub fn main() {
|
||||
let x = @S { x: 1 };
|
||||
let y = x as @Foo<int>;
|
||||
let x = ~S { x: 1 };
|
||||
let y = x as ~Foo<int>;
|
||||
assert_eq!(y.get(), 1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[feature(managed_boxes)];
|
||||
|
||||
trait clam<A> {
|
||||
fn chowder(&self, y: A);
|
||||
}
|
||||
|
|
@ -28,13 +26,13 @@ fn foo<A>(b: A) -> foo<A> {
|
|||
}
|
||||
}
|
||||
|
||||
fn f<A>(x: @clam<A>, a: A) {
|
||||
fn f<A>(x: ~clam<A>, a: A) {
|
||||
x.chowder(a);
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
|
||||
let c = foo(42);
|
||||
let d: @clam<int> = @c as @clam<int>;
|
||||
let d: ~clam<int> = ~c as ~clam<int>;
|
||||
f(d, c.x);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[feature(managed_boxes)];
|
||||
|
||||
// xfail-fast
|
||||
// aux-build:issue-2380.rs
|
||||
|
||||
|
|
|
|||
|
|
@ -8,19 +8,17 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[feature(managed_boxes)];
|
||||
|
||||
trait hax { }
|
||||
impl<A> hax for A { }
|
||||
|
||||
fn perform_hax<T:'static>(x: @T) -> @hax {
|
||||
@x as @hax
|
||||
fn perform_hax<T: 'static>(x: ~T) -> ~hax: {
|
||||
~x as ~hax:
|
||||
}
|
||||
|
||||
fn deadcode() {
|
||||
perform_hax(@~"deadcode");
|
||||
perform_hax(~~"deadcode");
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let _ = perform_hax(@42);
|
||||
let _ = perform_hax(~42);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,19 +8,17 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[feature(managed_boxes)];
|
||||
|
||||
trait hax { }
|
||||
impl<A> hax for A { }
|
||||
|
||||
fn perform_hax<T:'static>(x: @T) -> @hax {
|
||||
@x as @hax
|
||||
fn perform_hax<T: 'static>(x: ~T) -> ~hax: {
|
||||
~x as ~hax:
|
||||
}
|
||||
|
||||
fn deadcode() {
|
||||
perform_hax(@~"deadcode");
|
||||
perform_hax(~~"deadcode");
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
perform_hax(@42);
|
||||
perform_hax(~42);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[feature(managed_boxes)];
|
||||
|
||||
//type t = { a: int };
|
||||
// type t = { a: bool };
|
||||
type t = bool;
|
||||
|
|
@ -24,10 +22,10 @@ impl it for t {
|
|||
|
||||
pub fn main() {
|
||||
// let x = ({a: 4i} as it);
|
||||
// let y = @({a: 4i});
|
||||
// let z = @({a: 4i} as it);
|
||||
// let z = @({a: true} as it);
|
||||
let z = @(@true as @it);
|
||||
// let y = ~({a: 4i});
|
||||
// let z = ~({a: 4i} as it);
|
||||
// let z = ~({a: true} as it);
|
||||
let z = ~(~true as ~it);
|
||||
// x.f();
|
||||
// y.f();
|
||||
// (*z).f();
|
||||
|
|
|
|||
|
|
@ -8,14 +8,12 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[feature(managed_boxes)];
|
||||
|
||||
pub fn main() {
|
||||
trait Text {
|
||||
fn to_str(&self) -> ~str;
|
||||
}
|
||||
|
||||
fn to_string(t: @Text) {
|
||||
fn to_string(t: ~Text) {
|
||||
println!("{}", t.to_str());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[feature(managed_boxes)];
|
||||
|
||||
trait T {
|
||||
fn print(&self);
|
||||
}
|
||||
|
|
@ -33,9 +31,9 @@ fn print_s(s: &S) {
|
|||
}
|
||||
|
||||
pub fn main() {
|
||||
let s: @S = @S { s: 5 };
|
||||
let s: ~S = ~S { s: 5 };
|
||||
print_s(s);
|
||||
let t: @T = s as @T;
|
||||
let t: ~T = s as ~T;
|
||||
print_t(t);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[feature(managed_boxes)];
|
||||
|
||||
/*
|
||||
|
||||
#7673 Polymorphically creating traits barely works
|
||||
|
|
@ -24,7 +22,3 @@ impl<T: 'static> A for T {}
|
|||
fn owned1<T: 'static>(a: T) { ~a as ~A:; } /* note `:` */
|
||||
fn owned2<T: 'static>(a: ~T) { a as ~A:; }
|
||||
fn owned3<T: 'static>(a: ~T) { ~a as ~A:; }
|
||||
|
||||
fn managed1<T: 'static>(a: T) { @a as @A; }
|
||||
fn managed2<T: 'static>(a: @T) { a as @A; }
|
||||
fn managed3<T: 'static>(a: @T) { @a as @A; }
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@
|
|||
|
||||
// xfail-pretty
|
||||
|
||||
#[feature(managed_boxes, macro_rules)];
|
||||
#[feature(macro_rules)];
|
||||
|
||||
pub trait bomb { fn boom(@self, Ident); }
|
||||
pub trait bomb { fn boom(&self, Ident); }
|
||||
pub struct S;
|
||||
impl bomb for S { fn boom(@self, _: Ident) { } }
|
||||
impl bomb for S { fn boom(&self, _: Ident) { } }
|
||||
|
||||
pub struct Ident { name: uint }
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ fn Ident_new() -> Ident {
|
|||
Ident {name: 0x6789ABCD }
|
||||
}
|
||||
|
||||
pub fn light_fuse(fld: @bomb) {
|
||||
pub fn light_fuse(fld: ~bomb) {
|
||||
int3!();
|
||||
let f = || {
|
||||
int3!();
|
||||
|
|
@ -36,6 +36,6 @@ pub fn light_fuse(fld: @bomb) {
|
|||
}
|
||||
|
||||
pub fn main() {
|
||||
let b = @S as @bomb;
|
||||
let b = ~S as ~bomb;
|
||||
light_fuse(b);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,23 +8,21 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[feature(managed_boxes)];
|
||||
|
||||
trait repeat<A> { fn get(&self) -> A; }
|
||||
|
||||
impl<A:Clone + 'static> repeat<A> for @A {
|
||||
impl<A:Clone + 'static> repeat<A> for ~A {
|
||||
fn get(&self) -> A {
|
||||
(**self).clone()
|
||||
}
|
||||
}
|
||||
|
||||
fn repeater<A:Clone + 'static>(v: @A) -> @repeat:<A> {
|
||||
fn repeater<A:Clone + 'static>(v: ~A) -> ~repeat:<A> {
|
||||
// Note: owned kind is not necessary as A appears in the trait type
|
||||
@v as @repeat:<A> // No
|
||||
~v as ~repeat:<A> // No
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let x = 3;
|
||||
let y = repeater(@x);
|
||||
let y = repeater(~x);
|
||||
assert_eq!(x, y.get());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[feature(managed_boxes)];
|
||||
|
||||
// Test that we can coerce an `@Object` to an `&Object`
|
||||
|
||||
trait Foo {
|
||||
fn foo(&self) -> uint;
|
||||
}
|
||||
|
||||
impl Foo for uint {
|
||||
fn foo(&self) -> uint {
|
||||
*self
|
||||
}
|
||||
}
|
||||
|
||||
fn do_it_imm(obj: &Foo, v: uint) {
|
||||
let y = obj.foo();
|
||||
assert_eq!(v, y);
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let x = @22u as @Foo;
|
||||
do_it_imm(x, 22u);
|
||||
}
|
||||
|
|
@ -408,9 +408,9 @@ impl<V:TyVisitor + movable_ptr> TyVisitor for ptr_visit_adaptor<V> {
|
|||
}
|
||||
|
||||
fn visit_trait(&mut self, name: &str) -> bool {
|
||||
self.align_to::<@TyVisitor>();
|
||||
self.align_to::<~TyVisitor>();
|
||||
if ! self.inner().visit_trait(name) { return false; }
|
||||
self.bump_past::<@TyVisitor>();
|
||||
self.bump_past::<~TyVisitor>();
|
||||
true
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,10 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[feature(managed_boxes)];
|
||||
|
||||
use std::io::println;
|
||||
|
||||
trait Trait<T> {
|
||||
fn f(&self, x: T);
|
||||
}
|
||||
|
|
@ -27,18 +23,11 @@ impl Trait<&'static str> for Struct {
|
|||
}
|
||||
}
|
||||
|
||||
fn f(x: @Trait<&'static str>) {
|
||||
x.f("Sue");
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let a = Struct { x: 1, y: 2 };
|
||||
let b: @Trait<&'static str> = @a;
|
||||
b.f("Fred");
|
||||
let c: ~Trait<&'static str> = ~a;
|
||||
c.f("Mary");
|
||||
let d: &Trait<&'static str> = &a;
|
||||
d.f("Joe");
|
||||
f(@a);
|
||||
let b: ~Trait<&'static str> = ~a;
|
||||
b.f("Mary");
|
||||
let c: &Trait<&'static str> = &a;
|
||||
c.f("Joe");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[feature(managed_boxes)];
|
||||
|
||||
use std::io;
|
||||
|
||||
trait Trait {
|
||||
|
|
@ -27,23 +25,16 @@ impl Trait for Struct {
|
|||
}
|
||||
}
|
||||
|
||||
fn f(x: @Trait) {
|
||||
x.f();
|
||||
}
|
||||
|
||||
fn foo(mut a: ~Writer) {
|
||||
a.write(bytes!("Hello\n"));
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let a = Struct { x: 1, y: 2 };
|
||||
let b: @Trait = @a;
|
||||
let b: ~Trait = ~a;
|
||||
b.f();
|
||||
let c: ~Trait = ~a;
|
||||
let c: &Trait = &a;
|
||||
c.f();
|
||||
let d: &Trait = &a;
|
||||
d.f();
|
||||
f(@a);
|
||||
|
||||
let out = io::stdout();
|
||||
foo(~out);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#[feature(managed_boxes)];
|
||||
|
||||
// xfail-fast
|
||||
// aux-build:trait_default_method_xc_aux.rs
|
||||
|
||||
|
|
@ -66,7 +64,7 @@ pub fn main () {
|
|||
assert_eq!(g(0i, 3.14, 1), (3.14, 1));
|
||||
assert_eq!(g(false, 3.14, 1), (3.14, 1));
|
||||
|
||||
let obj = @0i as @A;
|
||||
let obj = ~0i as ~A;
|
||||
assert_eq!(obj.h(), 11);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[feature(managed_boxes)];
|
||||
|
||||
// test for #8664
|
||||
|
||||
pub trait Trait2<A> {
|
||||
|
|
@ -42,7 +40,7 @@ impl<V> Trait<u8,V> for () {
|
|||
fn method(&self, _x: Type<(u8,V)>) -> int { 0 }
|
||||
}
|
||||
|
||||
pub fn main () {
|
||||
let a = @() as @Trait<u8, u8>;
|
||||
pub fn main() {
|
||||
let a = ~() as ~Trait<u8, u8>;
|
||||
assert_eq!(a.method(Constant), 0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue