提交 b7e72974 编写于 作者: B bors

auto merge of #5147 : nikomatsakis/rust/remove-legacy-trait-table, r=nikomatsakis

r? @pcwalton
......@@ -504,7 +504,7 @@ pub fn FILE_reader(f: *libc::FILE, cleanup: bool) -> @Reader {
pub fn stdin() -> @Reader {
unsafe {
rustrt::rust_get_stdin() as @Reader
@rustrt::rust_get_stdin() as @Reader
}
}
......@@ -642,11 +642,11 @@ fn get_type(&self) -> WriterType {
}
}
pub fn FILE_writer(f: *libc::FILE, cleanup: bool) -> Writer {
pub fn FILE_writer(f: *libc::FILE, cleanup: bool) -> @Writer {
if cleanup {
Wrapper { base: f, cleanup: FILERes(f) } as Writer
@Wrapper { base: f, cleanup: FILERes(f) } as @Writer
} else {
f as Writer
@f as @Writer
}
}
......@@ -702,11 +702,11 @@ pub fn FdRes(fd: fd_t) -> FdRes {
}
}
pub fn fd_writer(fd: fd_t, cleanup: bool) -> Writer {
pub fn fd_writer(fd: fd_t, cleanup: bool) -> @Writer {
if cleanup {
Wrapper { base: fd, cleanup: FdRes(fd) } as Writer
@Wrapper { base: fd, cleanup: FdRes(fd) } as @Writer
} else {
fd as Writer
@fd as @Writer
}
}
......
......@@ -412,8 +412,8 @@ pub fn Rng() -> Rng {
* all other generators constructed with the same seed. The seed may be any
* length.
*/
pub fn seeded_rng(seed: &[u8]) -> Rng {
seeded_randres(seed) as Rng
pub fn seeded_rng(seed: &[u8]) -> @Rng {
@seeded_randres(seed) as @Rng
}
fn seeded_randres(seed: &[u8]) -> @RandRes {
......@@ -449,8 +449,8 @@ fn next() -> u32 {
seeded_xorshift(123456789u32, 362436069u32, 521288629u32, 88675123u32)
}
pub pure fn seeded_xorshift(x: u32, y: u32, z: u32, w: u32) -> Rng {
XorShiftState { x: x, y: y, z: z, w: w } as Rng
pub pure fn seeded_xorshift(x: u32, y: u32, z: u32, w: u32) -> @Rng {
@XorShiftState { x: x, y: y, z: z, w: w } as @Rng
}
......@@ -472,10 +472,10 @@ pub fn task_rng() -> Rng {
unsafe {
let rng = seeded_randres(seed());
task::local_data::local_data_set(tls_rng_state, rng);
rng as Rng
@rng as @Rng
}
}
Some(rng) => rng as Rng
Some(rng) => @rng as @Rng
}
}
......
......@@ -201,7 +201,7 @@ fn visit_ptr_inner(ptr: *c_void, inner: *TyDesc) -> bool {
unsafe {
let mut u = ReprVisitor(ptr, self.writer);
let v = reflect::MovePtrAdaptor(u);
visit_tydesc(inner, (v) as @TyVisitor);
visit_tydesc(inner, @v as @TyVisitor);
true
}
}
......@@ -570,7 +570,7 @@ pub fn write_repr<T>(writer: @Writer, object: &T) {
let tydesc = intrinsic::get_tydesc::<T>();
let mut u = ReprVisitor(ptr, writer);
let v = reflect::MovePtrAdaptor(u);
visit_tydesc(tydesc, (v) as @TyVisitor)
visit_tydesc(tydesc, @v as @TyVisitor)
}
}
......
......@@ -288,7 +288,7 @@ fn finish(&mut self) -> int { finish_repr(&mut self.r) }
finished: false,
};
ProgRes(repr) as Program
@ProgRes(repr) as @Program
}
fn read_all(rd: io::Reader) -> ~str {
......
......@@ -155,7 +155,7 @@ pub unsafe fn local_set<T:Durable>(
// does not have a reference associated with it, so it may become invalid
// when the box is destroyed.
let data_ptr = cast::reinterpret_cast(&data);
let data_box = data as LocalData;
let data_box = @data as @LocalData;
// Construct new entry to store in the map.
let new_entry = Some((keyval, data_ptr, data_box));
// Find a place to put it.
......
......@@ -132,9 +132,8 @@ pub enum astencode_tag { // Reserves 0x50 -- 0x6f
tag_table_method_map = 0x60,
tag_table_vtable_map = 0x61,
tag_table_adjustments = 0x62,
tag_table_legacy_boxed_trait = 0x63,
tag_table_moves_map = 0x64,
tag_table_capture_map = 0x65
tag_table_moves_map = 0x63,
tag_table_capture_map = 0x64
}
pub const tag_item_trait_method_sort: uint = 0x70;
......
......@@ -71,11 +71,11 @@ fn get_target_lib_file_path(&self, file: &Path) -> Path {
let sysroot = get_sysroot(maybe_sysroot);
debug!("using sysroot = %s", sysroot.to_str());
FileSearchImpl {
@FileSearchImpl {
sysroot: sysroot,
addl_lib_search_paths: addl_lib_search_paths,
target_triple: str::from_slice(target_triple)
} as FileSearch
} as @FileSearch
}
pub fn search<T:Copy>(filesearch: FileSearch, pick: pick<T>) -> Option<T> {
......
......@@ -966,12 +966,6 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
}
}
do option::iter(&tcx.legacy_boxed_traits.find(&id)) |_x| {
do ebml_w.tag(c::tag_table_legacy_boxed_trait) {
ebml_w.id(id);
}
}
for maps.moves_map.find(&id).each |_| {
do ebml_w.tag(c::tag_table_moves_map) {
ebml_w.id(id);
......@@ -1121,8 +1115,6 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext,
if tag == (c::tag_table_mutbl as uint) {
dcx.maps.mutbl_map.insert(id, ());
} else if tag == (c::tag_table_legacy_boxed_trait as uint) {
dcx.tcx.legacy_boxed_traits.insert(id, ());
} else if tag == (c::tag_table_moves_map as uint) {
dcx.maps.moves_map.insert(id, ());
} else {
......@@ -1230,7 +1222,7 @@ fn ident_of(&self, +st: ~str) -> ast::ident {
#[cfg(test)]
fn mk_ctxt() -> fake_ext_ctxt {
parse::new_parse_sess(None) as fake_ext_ctxt
@parse::new_parse_sess(None) as fake_ext_ctxt
}
#[cfg(test)]
......
......@@ -209,8 +209,8 @@ fn compute_info(&self,
}
}
pub fn llvm_abi_info() -> ABIInfo {
return LLVM_ABIInfo as ABIInfo;
pub fn llvm_abi_info() -> @ABIInfo {
return @LLVM_ABIInfo as @ABIInfo;
}
......@@ -159,6 +159,6 @@ fn compute_info(&self,
}
}
pub fn abi_info() -> ABIInfo {
return ARM_ABIInfo as ABIInfo;
pub fn abi_info() -> @ABIInfo {
return @ARM_ABIInfo as @ABIInfo;
}
......@@ -408,5 +408,5 @@ fn compute_info(&self,
}
pub fn x86_64_abi_info() -> ABIInfo {
return X86_64_ABIInfo as ABIInfo;
return @X86_64_ABIInfo as @ABIInfo;
}
......@@ -870,26 +870,11 @@ pub fn trans_trait_cast(bcx: block,
match vstore {
ty::vstore_slice(*) | ty::vstore_box => {
let mut llboxdest = GEPi(bcx, lldest, [0u, 1u]);
if bcx.tcx().legacy_boxed_traits.contains_key(&id) {
// Allocate an @ box and store the value into it
let MallocResult {bcx: new_bcx, box: llbox, body: body} =
malloc_boxed(bcx, v_ty);
bcx = new_bcx;
add_clean_free(bcx, llbox, heap_managed);
bcx = expr::trans_into(bcx, val, SaveIn(body));
revoke_clean(bcx, llbox);
// Store the @ box into the pair
Store(bcx, llbox, PointerCast(bcx,
llboxdest,
T_ptr(val_ty(llbox))));
} else {
// Just store the pointer into the pair.
llboxdest = PointerCast(bcx,
llboxdest,
T_ptr(type_of(bcx.ccx(), v_ty)));
bcx = expr::trans_into(bcx, val, SaveIn(llboxdest));
}
// Just store the pointer into the pair.
llboxdest = PointerCast(bcx,
llboxdest,
T_ptr(type_of(bcx.ccx(), v_ty)));
bcx = expr::trans_into(bcx, val, SaveIn(llboxdest));
}
ty::vstore_uniq => {
// Translate the uniquely-owned value into the second element of
......
......@@ -269,7 +269,6 @@ struct ctxt_ {
adjustments: HashMap<ast::node_id, @AutoAdjustment>,
normalized_cache: HashMap<t, t>,
lang_items: middle::lang_items::LanguageItems,
legacy_boxed_traits: HashMap<node_id, ()>,
// A mapping from an implementation ID to the method info and trait
// method ID of the provided (a.k.a. default) methods in the traits that
// that implementation implements.
......@@ -831,7 +830,6 @@ pub fn mk_ctxt(s: session::Session,
adjustments: HashMap(),
normalized_cache: new_ty_hash(),
lang_items: lang_items,
legacy_boxed_traits: HashMap(),
provided_methods: HashMap(),
provided_method_sources: HashMap(),
supertraits: HashMap(),
......
......@@ -97,8 +97,8 @@ pub fn lookup_vtables(vcx: &VtableContext,
let mut result = ~[], i = 0u;
for substs.tps.each |ty| {
for ty::iter_bound_traits_and_supertraits(
tcx, bounds[i]) |trait_ty| {
tcx, bounds[i]) |trait_ty|
{
debug!("about to subst: %?, %?",
ppaux::ty_to_str(tcx, trait_ty),
ty::substs_to_str(tcx, substs));
......@@ -585,138 +585,102 @@ pub fn early_resolve_expr(ex: @ast::expr,
}
}
ast::expr_cast(src, _) => {
let target_ty = fcx.expr_ty(ex);
match ty::get(target_ty).sty {
ty::ty_trait(_, _, vstore) => {
// Look up vtables for the type we're casting to, passing in the
// source and target type.
//
// XXX: This is invariant and shouldn't be. --pcw
let ty = fcx.expr_ty(src);
let vcx = VtableContext { ccx: fcx.ccx, infcx: fcx.infcx() };
let vtable_opt =
lookup_vtable(&vcx,
&location_info_for_expr(ex),
ty,
target_ty,
true,
is_early);
match vtable_opt {
None => {
// Try the new-style boxed trait; "@int as @Trait".
// Or the new-style region trait; "&int as &Trait".
// Or the new-style uniquely-owned trait; "~int as
// ~Trait".
let mut err = false;
let ty = structurally_resolved_type(fcx, ex.span, ty);
match ty::get(ty).sty {
ty::ty_box(mt) | ty::ty_rptr(_, mt) |
ty::ty_uniq(mt) => {
// Ensure that the trait vstore and the pointer
// type match.
match (&ty::get(ty).sty, vstore) {
(&ty::ty_box(_), ty::vstore_box) |
(&ty::ty_uniq(_), ty::vstore_uniq) |
(&ty::ty_rptr(*), ty::vstore_slice(*)) => {
let location_info =
&location_info_for_expr(ex);
let vtable_opt =
lookup_vtable(&vcx,
location_info,
mt.ty,
target_ty,
true,
is_early);
match vtable_opt {
Some(vtable) => {
// Map this expression to that
// vtable (that is: "ex has vtable
// <vtable>")
if !is_early {
let vtable_map =
cx.vtable_map;
vtable_map.insert(ex.id,
@~[vtable]);
}
}
None => err = true
}
// Now, if this is &trait, we need to link
// the regions.
match (&ty::get(ty).sty, vstore) {
(&ty::ty_rptr(ra, _),
ty::vstore_slice(rb)) => {
infer::mk_subr(fcx.infcx(),
false,
ex.span,
rb,
ra);
}
_ => {}
}
}
(&ty::ty_box(_), _) => {
fcx.ccx.tcx.sess.span_err(ex.span,
~"must cast \
a boxed \
pointer to \
a boxed
trait");
err = true;
}
(&ty::ty_rptr(*), _) => {
fcx.ccx.tcx.sess.span_err(ex.span,
~"must cast \
a borrowed \
pointer to \
a borrowed \
trait");
}
(&ty::ty_uniq(*), _) => {
fcx.ccx.tcx.sess.span_err(ex.span,
~"must cast \
a unique \
pointer to \
a uniquely-\
owned trait");
}
_ => {
fcx.ccx.tcx.sess.impossible_case(
ex.span,
~"impossible combination of type and \
trait vstore");
}
}
}
_ => err = true
}
if err {
fcx.tcx().sess.span_fatal(
ex.span,
fmt!("failed to find an implementation of trait \
%s for %s",
fcx.infcx().ty_to_str(target_ty),
fcx.infcx().ty_to_str(ty)));
}
}
Some(vtable) => {
/*
Map this expression to that vtable (that is: "ex has
vtable <vtable>")
*/
if !is_early {
let vtable_map = cx.vtable_map;
vtable_map.insert(ex.id, @~[vtable]);
}
fcx.tcx().legacy_boxed_traits.insert(ex.id, ());
}
}
let target_ty = fcx.expr_ty(ex);
match ty::get(target_ty).sty {
ty::ty_trait(_, _, vstore) => {
// Look up vtables for the type we're casting to,
// passing in the source and target type. The source
// must be a pointer type suitable to the object sigil,
// e.g.: `@x as @Trait`, `&x as &Trait` or `~x as ~Trait`
let ty = structurally_resolved_type(fcx, ex.span,
fcx.expr_ty(src));
match (&ty::get(ty).sty, vstore) {
(&ty::ty_box(mt), ty::vstore_box) |
(&ty::ty_uniq(mt), ty::vstore_uniq) |
(&ty::ty_rptr(_, mt), ty::vstore_slice(*)) => {
let location_info =
&location_info_for_expr(ex);
let vcx = VtableContext {
ccx: fcx.ccx,
infcx: fcx.infcx()
};
let vtable_opt =
lookup_vtable(&vcx,
location_info,
mt.ty,
target_ty,
true,
is_early);
match vtable_opt {
Some(vtable) => {
// Map this expression to that
// vtable (that is: "ex has vtable
// <vtable>")
if !is_early {
let vtable_map =
cx.vtable_map;
vtable_map.insert(ex.id,
@~[vtable]);
}
}
None => {
fcx.tcx().sess.span_err(
ex.span,
fmt!("failed to find an implementation \
of trait %s for %s",
fcx.infcx().ty_to_str(target_ty),
fcx.infcx().ty_to_str(mt.ty)));
}
}
// Now, if this is &trait, we need to link the
// regions.
match (&ty::get(ty).sty, vstore) {
(&ty::ty_rptr(ra, _),
ty::vstore_slice(rb)) => {
infer::mk_subr(fcx.infcx(),
false,
ex.span,
rb,
ra);
}
_ => {}
}
}
(_, ty::vstore_box(*)) => {
fcx.ccx.tcx.sess.span_err(
ex.span,
fmt!("can only cast an @-pointer \
to an @-object, not a %s",
ty::ty_sort_str(fcx.tcx(), ty)));
}
(_, ty::vstore_uniq(*)) => {
fcx.ccx.tcx.sess.span_err(
ex.span,
fmt!("can only cast an ~-pointer \
to a ~-object, not a %s",
ty::ty_sort_str(fcx.tcx(), ty)));
}
(_, ty::vstore_slice(*)) => {
fcx.ccx.tcx.sess.span_err(
ex.span,
fmt!("can only cast an &-pointer \
to an &-object, not a %s",
ty::ty_sort_str(fcx.tcx(), ty)));
}
(_, ty::vstore_fixed(*)) => {
fcx.tcx().sess.span_bug(
ex.span,
fmt!("trait with fixed vstore"));
}
}
}
_ => { /* not a cast to a trait; ignore */ }
}
_ => ()
}
}
_ => ()
}
......
......@@ -70,11 +70,11 @@ pub fn bound_self_region(rp: Option<ty::region_variance>)
}
}
pub struct anon_rscope { anon: ty::Region, base: region_scope }
pub struct anon_rscope { anon: ty::Region, base: @region_scope }
pub fn in_anon_rscope<RS:region_scope + Copy + Durable>(self: RS,
r: ty::Region)
-> @anon_rscope {
@anon_rscope {anon: r, base: self as region_scope}
@anon_rscope {anon: r, base: @self as @region_scope}
}
impl region_scope for @anon_rscope {
......@@ -97,7 +97,7 @@ pub struct binding_rscope {
pub fn in_binding_rscope<RS:region_scope + Copy + Durable>(self: RS)
-> @mut binding_rscope {
let base = self as region_scope;
let base = @self as @region_scope;
@mut binding_rscope { base: base, anon_bindings: 0 }
}
......
......@@ -63,7 +63,7 @@ trait Sha1 {
/// Construct a `sha` object
pub fn sha1() -> Sha1 {
pub fn sha1() -> @Sha1 {
struct Sha1State
{ h: ~[u32],
len_low: u32,
......@@ -269,7 +269,7 @@ fn result_str(&mut self) -> ~str {
computed: false,
work_buf: @mut vec::from_elem(work_buf_len, 0u32)
};
let mut sh = (st) as Sha1;
let mut sh = @st as @Sha1;
sh.reset();
return sh;
}
......
......@@ -1296,7 +1296,7 @@ fn emit_tup_elt(&self, +_idx: uint, f: fn()) {
}
fn to_call_log (val: Encodable<TestEncoder>) -> ~[call] {
fn to_call_log<E:Encodable<TestEncoder>>(val: E) -> ~[call] {
let mut te = TestEncoder {call_log: @mut ~[]};
val.encode(&te);
copy *te.call_log
......@@ -1309,8 +1309,7 @@ enum Written {
}
#[test] fn encode_enum_test () {
check_equal (to_call_log(Book(34,44)
as Encodable::<TestEncoder>),
check_equal (to_call_log(Book(34,44)),
~[CallToEmitEnum (~"Written"),
CallToEmitEnumVariant (~"Book",0,2),
CallToEmitEnumVariantArg (0),
......@@ -1325,8 +1324,7 @@ enum Written {
pub struct HasPos { pos : BPos }
#[test] fn encode_newtype_test () {
check_equal (to_call_log (HasPos {pos:BPos(48)}
as Encodable::<TestEncoder>),
check_equal (to_call_log (HasPos {pos:BPos(48)}),
~[CallToEmitStruct(~"HasPos",1),
CallToEmitField(~"pos",0),
CallToEmitUint(48)]);
......
此差异已折叠。
......@@ -251,7 +251,7 @@ mod test {
@~"fn foo (x : int) { x; }",
~[],
new_parse_sess(None));
check_equal(to_json_str(tts as Encodable::<std::json::Encoder>),
check_equal(to_json_str(@tts as Encodable::<std::json::Encoder>),
~"[[\"tt_tok\",[,[\"IDENT\",[\"fn\",false]]]],\
[\"tt_tok\",[,[\"IDENT\",[\"foo\",false]]]],\
[\"tt_delim\",[[[\"tt_tok\",[,[\"LPAREN\",[]]]],\
......
......@@ -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 @@ fn get() -> A { *self }
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 @@
// 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 @@ fn get_ctxt() -> &self/ctxt { self.c }
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 @@ fn plus(++x: int) -> int { self + x }
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 @@ fn foo() { }
}
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 @@ fn double() -> uint { self * 2u }
}
pub fn main() {
let x = @(3u as double);
let x = @(@3u as @double);
assert x.double() == 6u;
}
......@@ -19,7 +19,7 @@ fn foo() {
}
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 @@ fn read(&self, bytes: &mut [u8], len: uint) -> uint {
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 @@ fn read(&self, bytes: &mut [u8], len: uint) -> uint {
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 @@ fn read(&self, bytes: &mut [u8], len: uint) -> uint {
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 @@ fn read(bytes: &mut [u8], len: uint) -> uint {
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 @@ fn get() -> A { *self }
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 @@ fn visit_inner(inner: *TyDesc) -> bool {
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;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册