Remove legacy object creation mode, and convert remaining uses of it
This commit is contained in:
parent
5680ec0270
commit
4ecb672d7f
54 changed files with 292 additions and 351 deletions
|
|
@ -16,5 +16,5 @@ pub trait i<T> { }
|
|||
pub fn f<T>() -> i<T> {
|
||||
impl<T> i<T> for () { }
|
||||
|
||||
() as i::<T>
|
||||
@() as @i<T>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ fn writer(path: ~str, pport: comm::Port<Line>, size: uint)
|
|||
{
|
||||
let cout: io::Writer = match path {
|
||||
~"" => {
|
||||
Devnull as io::Writer
|
||||
@Devnull as @io::Writer
|
||||
}
|
||||
~"-" => {
|
||||
io::stdout()
|
||||
|
|
|
|||
|
|
@ -58,6 +58,6 @@ fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let nyan : noisy = cat(0, 2, ~"nyan") as noisy;
|
||||
let nyan : noisy = @cat(0, 2, ~"nyan") as @noisy;
|
||||
nyan.eat(); //~ ERROR type `@noisy` does not implement any method in scope named `eat`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ impl<A:Copy> repeat<A> for @A {
|
|||
|
||||
fn repeater<A:Copy>(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
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ fn to_foo<T:Copy>(t: T) {
|
|||
// the fn body itself.
|
||||
let v = &3;
|
||||
struct F<T> { f: T }
|
||||
let x = F {f:t} as foo;
|
||||
let x = @F {f:t} as foo;
|
||||
assert x.foo(v) == 3;
|
||||
}
|
||||
|
||||
|
|
@ -34,14 +34,14 @@ fn to_foo_2<T:Copy>(t: T) -> foo {
|
|||
// Not OK---T may contain borrowed ptrs and it is going to escape
|
||||
// as part of the returned foo value
|
||||
struct F<T> { f: T }
|
||||
F {f:t} as foo //~ ERROR value may contain borrowed pointers; use `&static` bound
|
||||
@F {f:t} as foo //~ ERROR value may contain borrowed pointers; use `&static` bound
|
||||
}
|
||||
|
||||
fn to_foo_3<T:Copy + &static>(t: T) -> foo {
|
||||
// OK---T may escape as part of the returned foo value, but it is
|
||||
// owned and hence does not contain borrowed ptrs
|
||||
struct F<T> { f: T }
|
||||
F {f:t} as foo
|
||||
@F {f:t} as foo
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@
|
|||
trait foo { fn foo(); }
|
||||
|
||||
fn to_foo<T:Copy + foo>(t: T) -> foo {
|
||||
t as foo //~ ERROR value may contain borrowed pointers; use `&static` bound
|
||||
@t as @foo //~ ERROR value may contain borrowed pointers; use `&static` bound
|
||||
}
|
||||
|
||||
fn to_foo2<T:Copy + foo + &static>(t: T) -> foo {
|
||||
t as foo
|
||||
@t as @foo
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ use core::hashmap::linear::LinearMap;
|
|||
// Test that trait types printed in error msgs include the type arguments.
|
||||
|
||||
fn main() {
|
||||
let x: Map<~str, ~str> = LinearMap::new::<~str, ~str>() as
|
||||
let x: @Map<~str, ~str> = @LinearMap::new::<~str, ~str>() as
|
||||
Map::<~str, ~str>;
|
||||
let y: Map<uint, ~str> = x;
|
||||
let y: @Map<uint, ~str> = @x;
|
||||
//~^ ERROR mismatched types: expected `@core::container::Map/&<uint,~str>`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,5 +34,5 @@ fn get_v(gc: get_ctxt) -> uint {
|
|||
fn main() {
|
||||
let ctxt = ctxt { v: 22u };
|
||||
let hc = has_ctxt { c: &ctxt };
|
||||
assert get_v(hc as get_ctxt) == 22u;
|
||||
assert get_v(@hc as get_ctxt) == 22u;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ impl get_ctxt for has_ctxt {
|
|||
fn make_gc() -> get_ctxt {
|
||||
let ctxt = ctxt { v: 22u };
|
||||
let hc = has_ctxt { c: &ctxt }; //~ ERROR illegal borrow
|
||||
return hc as get_ctxt;
|
||||
return @hc as get_ctxt;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ fn make_gc1(gc: get_ctxt/&a) -> get_ctxt/&b {
|
|||
}
|
||||
|
||||
fn make_gc2(gc: get_ctxt/&a) -> get_ctxt/&b {
|
||||
return gc as get_ctxt; //~ ERROR cannot infer an appropriate lifetime
|
||||
return @gc as get_ctxt; //~ ERROR cannot infer an appropriate lifetime
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ impl add for int {
|
|||
fn do_add<A:add>(x: A, y: A) -> A { x.plus(y) }
|
||||
|
||||
fn main() {
|
||||
let x = 3 as add;
|
||||
let y = 4 as add;
|
||||
let x = @3 as @add;
|
||||
let y = @4 as @add;
|
||||
do_add(x, y); //~ ERROR a boxed trait with self types may not be passed as a bounded type
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ fn set_box_impl<T>(b: box_impl<@const T>, v: @const T) {
|
|||
|
||||
fn main() {
|
||||
let b = box_impl::<@int>(box::<@int> {f: @3});
|
||||
set_box_trait(b as box_trait::<@int>, @mut 5);
|
||||
set_box_trait(@b as box_trait::<@int>, @mut 5);
|
||||
//~^ ERROR values differ in mutability
|
||||
set_box_impl(b, @mut 5);
|
||||
//~^ ERROR values differ in mutability
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
trait foo<T> { }
|
||||
|
||||
fn bar(x: foo<uint>) -> foo<int> {
|
||||
return (x as foo::<int>);
|
||||
return (@x as foo::<int>);
|
||||
//~^ ERROR mismatched types: expected `@foo<int>` but found `@foo<uint>`
|
||||
//~^^ ERROR mismatched types: expected `@foo<int>` but found `@foo<uint>`
|
||||
// This is unfortunate -- new handling of parens means the error message
|
||||
|
|
|
|||
|
|
@ -15,5 +15,5 @@ impl bar for uint { fn dup() -> uint { self } fn blah<X>() {} }
|
|||
fn main() {
|
||||
10i.dup::<int>(); //~ ERROR does not take type parameters
|
||||
10i.blah::<int, int>(); //~ ERROR incorrect number of type parameters
|
||||
(10 as bar).dup(); //~ ERROR contains a self-type
|
||||
(@10 as bar).dup(); //~ ERROR contains a self-type
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ impl i for ~int {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let x = ~0 as i;
|
||||
let x = @~0 as @i;
|
||||
failfn();
|
||||
log(error, x);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,6 @@ fn is_equal<D:double>(x: @D, exp: uint) {
|
|||
}
|
||||
|
||||
pub fn main() {
|
||||
let x = @(3u as double);
|
||||
let x = @(@3u as @double);
|
||||
is_equal(x, 6);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,6 @@ impl double for uint {
|
|||
}
|
||||
|
||||
pub fn main() {
|
||||
let x = @(3u as double);
|
||||
let x = @(@3u as @double);
|
||||
assert x.double() == 6u;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ impl Foo for int {
|
|||
}
|
||||
|
||||
pub fn main() {
|
||||
let x = 3 as @Foo;
|
||||
let x = @3 as @Foo;
|
||||
x.foo();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ fn print_out<T:ToStr>(thing: T, expected: ~str) {
|
|||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,8 +86,8 @@ fn annoy_neighbors<T:noisy>(critter: T) {
|
|||
pub fn main() {
|
||||
let nyan : cat = cat(0u, 2, ~"nyan");
|
||||
let whitefang : dog = dog();
|
||||
annoy_neighbors((copy nyan) as noisy);
|
||||
annoy_neighbors((copy whitefang) as noisy);
|
||||
annoy_neighbors(@(copy nyan) as @noisy);
|
||||
annoy_neighbors(@(copy whitefang) as @noisy);
|
||||
assert(nyan.meow_count() == 10u);
|
||||
assert(*whitefang.volume == 1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,6 +56,6 @@ fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat {
|
|||
|
||||
|
||||
pub fn main() {
|
||||
let mut nyan: noisy = cat(0u, 2, ~"nyan") as noisy;
|
||||
let mut nyan: @noisy = @cat(0u, 2, ~"nyan") as @noisy;
|
||||
nyan.speak();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,6 @@ fn print_out<T:ToStr>(thing: T, expected: ~str) {
|
|||
}
|
||||
|
||||
pub fn main() {
|
||||
let mut nyan : ToStr = cat(0u, 2, ~"nyan") as ToStr;
|
||||
let mut nyan : @ToStr = @cat(0u, 2, ~"nyan") as @ToStr;
|
||||
print_out(nyan, ~"nyan");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,6 @@ impl Reader for S {
|
|||
|
||||
pub fn main() {
|
||||
let x = S { x: 1, y: 2 };
|
||||
let x = x as @Reader;
|
||||
let x = @x as @Reader;
|
||||
x.read_bytes(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,6 @@ impl Reader for S {
|
|||
|
||||
pub fn main() {
|
||||
let x = S { x: 1, y: 2 };
|
||||
let x = x as @Reader;
|
||||
let x = @x as @Reader;
|
||||
x.read_bytes(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,6 @@ impl Reader for S {
|
|||
|
||||
pub fn main() {
|
||||
let x = S { x: 1, y: 2 };
|
||||
let x = x as @Reader;
|
||||
let x = @x as @Reader;
|
||||
x.read_bytes(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,6 @@ impl Reader for S {
|
|||
|
||||
pub fn main() {
|
||||
let x = S { x: 1, y: 2 };
|
||||
let x = x as @Reader;
|
||||
let x = @x as @Reader;
|
||||
x.read_bytes(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,6 @@ fn f<A:Copy>(x: clam<A>, a: 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ trait hax { }
|
|||
impl<A> hax for A { }
|
||||
|
||||
fn perform_hax<T:&static>(x: @T) -> hax {
|
||||
x as hax
|
||||
@x as @hax
|
||||
}
|
||||
|
||||
fn deadcode() {
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
trait hax { }
|
||||
impl<A> hax for A { }
|
||||
trait hax { }
|
||||
impl<A> hax for A { }
|
||||
|
||||
fn perform_hax<T:&static>(x: @T) -> hax {
|
||||
x as hax
|
||||
@x as @hax
|
||||
}
|
||||
|
||||
fn deadcode() {
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ fn square_from_char(c: char) -> square {
|
|||
}
|
||||
|
||||
fn read_board_grid<rdr: &static + io::Reader>(+in: rdr) -> ~[~[square]] {
|
||||
let in = (in) as io::Reader;
|
||||
let in = @in as @io::Reader;
|
||||
let mut grid = ~[];
|
||||
for in.each_line |line| {
|
||||
let mut row = ~[];
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ pub fn main() {
|
|||
// let y = @({a: 4i});
|
||||
// let z = @({a: 4i} as it);
|
||||
// let z = @({a: true} as it);
|
||||
let z = @(true as it);
|
||||
let z = @(@true as it);
|
||||
// x.f();
|
||||
// y.f();
|
||||
// (*z).f();
|
||||
|
|
|
|||
|
|
@ -21,6 +21,6 @@ fn is_equal<D:double>(x: @D, exp: uint) {
|
|||
}
|
||||
|
||||
pub fn main() {
|
||||
let x = @(3u as double);
|
||||
let x = @(@3u as @double);
|
||||
is_equal(x, 6);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ impl<A:Copy> repeat<A> for @A {
|
|||
|
||||
fn repeater<A:Copy>(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() {
|
||||
|
|
|
|||
|
|
@ -489,7 +489,7 @@ pub impl my_visitor {
|
|||
unsafe {
|
||||
let u = my_visitor(*self);
|
||||
let v = ptr_visit_adaptor::<my_visitor>(Inner {inner: u});
|
||||
visit_tydesc(inner, v as TyVisitor);
|
||||
visit_tydesc(inner, @v as @TyVisitor);
|
||||
true
|
||||
}
|
||||
}
|
||||
|
|
@ -644,7 +644,7 @@ pub fn main() {
|
|||
let td = get_tydesc_for(r);
|
||||
unsafe { error!("tydesc sz: %u, align: %u",
|
||||
(*td).size, (*td).align); }
|
||||
let v = v as TyVisitor;
|
||||
let v = @v as @TyVisitor;
|
||||
visit_tydesc(td, v);
|
||||
|
||||
for (copy u.vals).each |s| {
|
||||
|
|
|
|||
|
|
@ -30,5 +30,5 @@ pub fn main() {
|
|||
let ctxt = Ctxt { v: 22 };
|
||||
let hc = HasCtxt { c: &ctxt };
|
||||
|
||||
assert get_v(hc as get_ctxt) == 22;
|
||||
assert get_v(@hc as @get_ctxt) == 22;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue