librustc: Make the Drop trait use explicit self
This commit is contained in:
parent
5a282ec26f
commit
9e1c9be16f
@ -25,7 +25,7 @@ pub trait Owned {
|
||||
|
||||
#[lang="drop"]
|
||||
pub trait Drop {
|
||||
fn finalize(); // XXX: Rename to "drop"? --pcwalton
|
||||
fn finalize(&self); // XXX: Rename to "drop"? --pcwalton
|
||||
}
|
||||
|
||||
#[lang="add"]
|
||||
|
@ -888,7 +888,7 @@ fn with_field_tys<R>(tcx: ty::ctxt,
|
||||
}
|
||||
|
||||
ty::ty_class(did, ref substs) => {
|
||||
let has_dtor = ty::ty_dtor(tcx, did).is_some();
|
||||
let has_dtor = ty::ty_dtor(tcx, did).is_present();
|
||||
op(has_dtor, class_items_as_mutable_fields(tcx, did, substs))
|
||||
}
|
||||
|
||||
|
@ -397,8 +397,14 @@ fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) {
|
||||
}
|
||||
ty::ty_class(did, ref substs) => {
|
||||
// Call the dtor if there is one
|
||||
do option::map_default(&ty::ty_dtor(bcx.tcx(), did), bcx) |dt_id| {
|
||||
trans_class_drop(bcx, v, *dt_id, did, substs)
|
||||
match ty::ty_dtor(bcx.tcx(), did) {
|
||||
ty::NoDtor => bcx,
|
||||
ty::LegacyDtor(ref dt_id) => {
|
||||
trans_class_drop(bcx, v, *dt_id, did, substs, false)
|
||||
}
|
||||
ty::TraitDtor(ref dt_id) => {
|
||||
trans_class_drop(bcx, v, *dt_id, did, substs, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => bcx
|
||||
@ -410,7 +416,8 @@ fn trans_class_drop(bcx: block,
|
||||
v0: ValueRef,
|
||||
dtor_did: ast::def_id,
|
||||
class_did: ast::def_id,
|
||||
substs: &ty::substs) -> block {
|
||||
substs: &ty::substs,
|
||||
take_ref: bool) -> block {
|
||||
let drop_flag = GEPi(bcx, v0, struct_dtor());
|
||||
do with_cond(bcx, IsNotNull(bcx, Load(bcx, drop_flag))) |cx| {
|
||||
let mut bcx = cx;
|
||||
@ -427,7 +434,18 @@ fn trans_class_drop(bcx: block,
|
||||
// just consist of the output pointer and the environment
|
||||
// (self)
|
||||
assert(params.len() == 2);
|
||||
let self_arg = PointerCast(bcx, v0, params[1]);
|
||||
|
||||
// If we need to take a reference to the class (because it's using
|
||||
// the Drop trait), do so now.
|
||||
let llval;
|
||||
if take_ref {
|
||||
llval = alloca(bcx, val_ty(v0));
|
||||
Store(bcx, v0, llval);
|
||||
} else {
|
||||
llval = v0;
|
||||
}
|
||||
|
||||
let self_arg = PointerCast(bcx, llval, params[1]);
|
||||
let args = ~[bcx.fcx.llretptr, self_arg];
|
||||
Call(bcx, dtor_addr, args);
|
||||
|
||||
@ -465,10 +483,13 @@ fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) {
|
||||
ty::ty_class(did, ref substs) => {
|
||||
let tcx = bcx.tcx();
|
||||
match ty::ty_dtor(tcx, did) {
|
||||
Some(dtor) => {
|
||||
trans_class_drop(bcx, v0, dtor, did, substs)
|
||||
ty::TraitDtor(dtor) => {
|
||||
trans_class_drop(bcx, v0, dtor, did, substs, true)
|
||||
}
|
||||
None => {
|
||||
ty::LegacyDtor(dtor) => {
|
||||
trans_class_drop(bcx, v0, dtor, did, substs, false)
|
||||
}
|
||||
ty::NoDtor => {
|
||||
// No dtor? Just the default case
|
||||
iter_structural_ty(bcx, v0, t, drop_ty)
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ pub fn simplify_type(tcx: ty::ctxt, typ: ty::t) -> ty::t {
|
||||
// Reduce a class type to a record type in which all the fields are
|
||||
// simplified
|
||||
ty::ty_class(did, ref substs) => {
|
||||
let simpl_fields = (if ty::ty_dtor(tcx, did).is_some() {
|
||||
let simpl_fields = (if ty::ty_dtor(tcx, did).is_present() {
|
||||
// remember the drop flag
|
||||
~[{ident: syntax::parse::token::special_idents::dtor,
|
||||
mt: {ty: ty::mk_u8(tcx),
|
||||
|
@ -199,7 +199,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef {
|
||||
|
||||
// include a byte flag if there is a dtor so that we know when we've
|
||||
// been dropped
|
||||
if ty::ty_dtor(cx.tcx, did) != None {
|
||||
if ty::ty_dtor(cx.tcx, did).is_present() {
|
||||
common::set_struct_body(llty, ~[T_struct(tys), T_i8()]);
|
||||
} else {
|
||||
common::set_struct_body(llty, ~[T_struct(tys)]);
|
||||
|
@ -75,6 +75,7 @@ export enum_variants, substd_enum_variants, enum_is_univariant;
|
||||
export trait_methods, store_trait_methods, impl_traits;
|
||||
export enum_variant_with_id;
|
||||
export ty_dtor;
|
||||
export DtorKind, NoDtor, LegacyDtor, TraitDtor;
|
||||
export ty_param_bounds_and_ty;
|
||||
export ty_param_substs_and_ty;
|
||||
export ty_bool, mk_bool, type_is_bool;
|
||||
@ -1868,7 +1869,7 @@ fn type_needs_drop(cx: ctxt, ty: t) -> bool {
|
||||
}
|
||||
ty_class(did, ref substs) => {
|
||||
// Any class with a dtor needs a drop
|
||||
ty_dtor(cx, did).is_some() || {
|
||||
ty_dtor(cx, did).is_present() || {
|
||||
for vec::each(ty::class_items_as_fields(cx, did, substs)) |f| {
|
||||
if type_needs_drop(cx, f.mt.ty) { accum = true; }
|
||||
}
|
||||
@ -3954,11 +3955,29 @@ fn item_path_str(cx: ctxt, id: ast::def_id) -> ~str {
|
||||
ast_map::path_to_str(item_path(cx, id), cx.sess.parse_sess.interner)
|
||||
}
|
||||
|
||||
enum DtorKind {
|
||||
NoDtor,
|
||||
LegacyDtor(def_id),
|
||||
TraitDtor(def_id)
|
||||
}
|
||||
|
||||
impl DtorKind {
|
||||
pure fn is_not_present(&const self) -> bool {
|
||||
match *self {
|
||||
NoDtor => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
pure fn is_present(&const self) -> bool {
|
||||
!self.is_not_present()
|
||||
}
|
||||
}
|
||||
|
||||
/* If class_id names a class with a dtor, return Some(the dtor's id).
|
||||
Otherwise return none. */
|
||||
fn ty_dtor(cx: ctxt, class_id: def_id) -> Option<def_id> {
|
||||
fn ty_dtor(cx: ctxt, class_id: def_id) -> DtorKind {
|
||||
match cx.destructor_for_type.find(class_id) {
|
||||
Some(method_def_id) => return Some(method_def_id),
|
||||
Some(method_def_id) => return TraitDtor(method_def_id),
|
||||
None => {} // Continue.
|
||||
}
|
||||
|
||||
@ -3968,18 +3987,21 @@ fn ty_dtor(cx: ctxt, class_id: def_id) -> Option<def_id> {
|
||||
node: ast::item_class(@{ dtor: Some(dtor), _ }, _),
|
||||
_
|
||||
}, _)) =>
|
||||
Some(local_def(dtor.node.id)),
|
||||
LegacyDtor(local_def(dtor.node.id)),
|
||||
_ =>
|
||||
None
|
||||
NoDtor
|
||||
}
|
||||
}
|
||||
else {
|
||||
csearch::class_dtor(cx.sess.cstore, class_id)
|
||||
match csearch::class_dtor(cx.sess.cstore, class_id) {
|
||||
None => NoDtor,
|
||||
Some(did) => LegacyDtor(did),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn has_dtor(cx: ctxt, class_id: def_id) -> bool {
|
||||
ty_dtor(cx, class_id).is_some()
|
||||
ty_dtor(cx, class_id).is_present()
|
||||
}
|
||||
|
||||
fn item_path(cx: ctxt, id: ast::def_id) -> ast_map::path {
|
||||
|
@ -229,7 +229,7 @@ struct PoisonOnFail {
|
||||
}
|
||||
|
||||
impl PoisonOnFail : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
/* assert !*self.failed; -- might be false in case of cond.wait() */
|
||||
if task::failing() { *self.failed = true; }
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ pub struct Arena {
|
||||
}
|
||||
|
||||
impl Arena : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
unsafe {
|
||||
destroy_chunk(&self.head);
|
||||
for list::each(self.chunks) |chunk| {
|
||||
|
@ -42,11 +42,11 @@ struct DtorRes {
|
||||
}
|
||||
|
||||
impl DtorRes : Drop {
|
||||
fn finalize() {
|
||||
match self.dtor {
|
||||
option::None => (),
|
||||
option::Some(f) => f()
|
||||
}
|
||||
fn finalize(&self) {
|
||||
match self.dtor {
|
||||
option::None => (),
|
||||
option::Some(f) => f()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ pub struct Future<A> {
|
||||
// FIXME(#2829) -- futures should not be copyable, because they close
|
||||
// over fn~'s that have pipes and so forth within!
|
||||
impl<A> Future<A> : Drop {
|
||||
fn finalize() {}
|
||||
fn finalize(&self) {}
|
||||
}
|
||||
|
||||
priv enum FutureState<A> {
|
||||
|
@ -30,10 +30,10 @@ struct TcpSocket {
|
||||
}
|
||||
|
||||
impl TcpSocket : Drop {
|
||||
fn finalize() {
|
||||
unsafe {
|
||||
tear_down_socket_data(self.socket_data)
|
||||
}
|
||||
fn finalize(&self) {
|
||||
unsafe {
|
||||
tear_down_socket_data(self.socket_data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1137,7 +1137,7 @@ mod big_tests {
|
||||
}
|
||||
|
||||
impl LVal : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
let x = unsafe { task::local_data::local_data_get(self.key) };
|
||||
match x {
|
||||
Some(@y) => {
|
||||
|
@ -153,7 +153,7 @@ struct SemRelease {
|
||||
}
|
||||
|
||||
impl SemRelease : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
self.sem.release();
|
||||
}
|
||||
}
|
||||
@ -170,7 +170,7 @@ struct SemAndSignalRelease {
|
||||
}
|
||||
|
||||
impl SemAndSignalRelease : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
self.sem.release();
|
||||
}
|
||||
}
|
||||
@ -185,7 +185,7 @@ fn SemAndSignalRelease(sem: &r/Sem<~[mut Waitqueue]>)
|
||||
/// A mechanism for atomic-unlock-and-deschedule blocking and signalling.
|
||||
pub struct Condvar { priv sem: &Sem<~[mut Waitqueue]> }
|
||||
|
||||
impl Condvar : Drop { fn finalize() {} }
|
||||
impl Condvar : Drop { fn finalize(&self) {} }
|
||||
|
||||
impl &Condvar {
|
||||
/**
|
||||
@ -257,7 +257,7 @@ impl &Condvar {
|
||||
}
|
||||
|
||||
impl SemAndSignalReacquire : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
unsafe {
|
||||
// Needs to succeed, instead of itself dying.
|
||||
do task::unkillable {
|
||||
@ -607,7 +607,7 @@ struct RWlockReleaseRead {
|
||||
}
|
||||
|
||||
impl RWlockReleaseRead : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
unsafe {
|
||||
do task::unkillable {
|
||||
let mut last_reader = false;
|
||||
@ -641,7 +641,7 @@ struct RWlockReleaseDowngrade {
|
||||
}
|
||||
|
||||
impl RWlockReleaseDowngrade : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
unsafe {
|
||||
do task::unkillable {
|
||||
let mut writer_or_last_reader = false;
|
||||
@ -678,10 +678,10 @@ fn RWlockReleaseDowngrade(lock: &r/RWlock) -> RWlockReleaseDowngrade/&r {
|
||||
|
||||
/// The "write permission" token used for rwlock.write_downgrade().
|
||||
pub struct RWlockWriteMode { /* priv */ lock: &RWlock }
|
||||
impl RWlockWriteMode : Drop { fn finalize() {} }
|
||||
impl RWlockWriteMode : Drop { fn finalize(&self) {} }
|
||||
/// The "read permission" token used for rwlock.write_downgrade().
|
||||
pub struct RWlockReadMode { priv lock: &RWlock }
|
||||
impl RWlockReadMode : Drop { fn finalize() {} }
|
||||
impl RWlockReadMode : Drop { fn finalize(&self) {} }
|
||||
|
||||
impl &RWlockWriteMode {
|
||||
/// Access the pre-downgrade rwlock in write mode.
|
||||
@ -993,7 +993,7 @@ mod tests {
|
||||
}
|
||||
|
||||
impl SendOnFailure : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
self.c.send(());
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ struct arc_destruct<T:Const> {
|
||||
}
|
||||
|
||||
impl<T:Const> arc_destruct<T> : Drop {
|
||||
fn finalize() {}
|
||||
fn finalize(&self) {}
|
||||
}
|
||||
|
||||
fn arc_destruct<T: Const>(data: int) -> arc_destruct<T> {
|
||||
@ -34,7 +34,7 @@ struct context_res {
|
||||
}
|
||||
|
||||
impl context_res : Drop {
|
||||
fn finalize() {}
|
||||
fn finalize(&self) {}
|
||||
}
|
||||
|
||||
fn context_res() -> context_res {
|
||||
|
@ -12,7 +12,7 @@ struct socket_handle {
|
||||
}
|
||||
|
||||
impl socket_handle : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
/* c::close(self.sockfd); */
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ struct rsrc {
|
||||
}
|
||||
|
||||
impl rsrc : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
foo(self.x);
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ struct port_ptr<T:Send> {
|
||||
}
|
||||
|
||||
impl<T:Send> port_ptr<T> : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
unsafe {
|
||||
debug!("in the port_ptr destructor");
|
||||
do task::unkillable {
|
||||
|
@ -45,7 +45,7 @@ struct r {
|
||||
}
|
||||
|
||||
impl r : Drop {
|
||||
fn finalize() {}
|
||||
fn finalize(&self) {}
|
||||
}
|
||||
|
||||
fn r(l: @nillist) -> r {
|
||||
|
@ -1,7 +1,7 @@
|
||||
struct X { x: () }
|
||||
|
||||
impl X : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
error!("destructor runs");
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
struct X { x: (), }
|
||||
|
||||
impl X : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
error!("destructor runs");
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
struct X { x: (), }
|
||||
|
||||
impl X : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
error!("destructor runs");
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
struct X { x: (), }
|
||||
|
||||
impl X : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
error!("destructor runs");
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
struct X { x: (), }
|
||||
|
||||
impl X : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
error!("destructor runs");
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
struct X { x: (), }
|
||||
|
||||
impl X : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
error!("destructor runs");
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
struct X { x: (), }
|
||||
|
||||
impl X : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
error!("destructor runs");
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
struct r {}
|
||||
|
||||
impl r : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ struct defer {
|
||||
}
|
||||
|
||||
impl defer : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
error!("%?", self.x);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ struct noncopyable {
|
||||
}
|
||||
|
||||
impl noncopyable : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
error!("dropped");
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
struct foo { x: int, }
|
||||
|
||||
impl foo : Drop {
|
||||
fn finalize() {}
|
||||
fn finalize(&self) {}
|
||||
}
|
||||
|
||||
fn foo(x: int) -> foo {
|
||||
|
@ -5,7 +5,7 @@ struct foo {
|
||||
}
|
||||
|
||||
impl foo : Drop {
|
||||
fn finalize() {}
|
||||
fn finalize(&self) {}
|
||||
}
|
||||
|
||||
fn foo(i:int) -> foo {
|
||||
|
@ -3,7 +3,7 @@ struct X {
|
||||
}
|
||||
|
||||
impl X : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
error!("value: %s", self.x);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
type Foo = @[u8];
|
||||
|
||||
impl Foo : Drop { //~ ERROR the Drop trait may only be implemented
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
io::println("kaboom");
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ struct Foo {
|
||||
}
|
||||
|
||||
impl Foo : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
io::println("kaboom");
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ trait Bar : Drop {
|
||||
}
|
||||
|
||||
impl Foo : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
io::println("kaboom");
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ struct Bar {
|
||||
}
|
||||
|
||||
impl Bar : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
io::println("Goodbye, cruel world");
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ struct socket {
|
||||
}
|
||||
|
||||
impl socket : Drop {
|
||||
fn finalize() {}
|
||||
fn finalize(&self) {}
|
||||
}
|
||||
|
||||
impl socket {
|
||||
|
@ -7,7 +7,7 @@ struct foo {
|
||||
}
|
||||
|
||||
impl foo : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
io::println("Goodbye, World!");
|
||||
*self.x += 1;
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ struct S {
|
||||
}
|
||||
|
||||
impl S : Drop {
|
||||
fn finalize() {}
|
||||
fn finalize(&self) {}
|
||||
}
|
||||
|
||||
fn S(x: int) -> S { S { x: x } }
|
||||
|
@ -3,7 +3,7 @@ struct C {
|
||||
}
|
||||
|
||||
impl C : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
error!("dropping: %?", self.x);
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ fn foo<T>() {
|
||||
}
|
||||
|
||||
impl<T> foo<T> : Drop {
|
||||
fn finalize() {}
|
||||
fn finalize(&self) {}
|
||||
}
|
||||
}
|
||||
fn main() { }
|
||||
|
@ -53,7 +53,7 @@ struct r {
|
||||
}
|
||||
|
||||
impl r : Drop {
|
||||
fn finalize() {}
|
||||
fn finalize(&self) {}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -4,7 +4,7 @@ fn main() {
|
||||
}
|
||||
|
||||
impl foo : Drop {
|
||||
fn finalize() {}
|
||||
fn finalize(&self) {}
|
||||
}
|
||||
|
||||
fn foo(x: comm::Port<()>) -> foo {
|
||||
|
@ -7,7 +7,7 @@ struct r {
|
||||
}
|
||||
|
||||
impl r : Drop {
|
||||
fn finalize() {}
|
||||
fn finalize(&self) {}
|
||||
}
|
||||
|
||||
fn r(x:int) -> r {
|
||||
@ -21,7 +21,7 @@ struct r2 {
|
||||
}
|
||||
|
||||
impl r2 : Drop {
|
||||
fn finalize() {}
|
||||
fn finalize(&self) {}
|
||||
}
|
||||
|
||||
fn r2(x:@mut int) -> r2 {
|
||||
|
@ -7,7 +7,7 @@ struct bar {
|
||||
}
|
||||
|
||||
impl bar : Drop {
|
||||
fn finalize() {}
|
||||
fn finalize(&self) {}
|
||||
}
|
||||
|
||||
fn bar(x:int) -> bar {
|
||||
|
@ -5,7 +5,7 @@ struct r {
|
||||
}
|
||||
|
||||
impl r : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
*(self.i) = *(self.i) + 1;
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ struct my_resource {
|
||||
}
|
||||
|
||||
impl my_resource : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
log(error, self.x);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ struct yes0 {
|
||||
}
|
||||
|
||||
impl yes0 : Drop {
|
||||
fn finalize() {}
|
||||
fn finalize(&self) {}
|
||||
}
|
||||
|
||||
struct yes1 {
|
||||
@ -11,7 +11,7 @@ struct yes1 {
|
||||
}
|
||||
|
||||
impl yes1 : Drop {
|
||||
fn finalize() {}
|
||||
fn finalize(&self) {}
|
||||
}
|
||||
|
||||
struct yes2 {
|
||||
@ -19,7 +19,7 @@ struct yes2 {
|
||||
}
|
||||
|
||||
impl yes2 : Drop {
|
||||
fn finalize() {}
|
||||
fn finalize(&self) {}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -7,7 +7,7 @@ struct Foo {
|
||||
}
|
||||
|
||||
impl Foo : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
io::println("Goodbye!");
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ struct Bar {
|
||||
}
|
||||
|
||||
impl Bar : Drop {
|
||||
fn finalize() {}
|
||||
fn finalize(&self) {}
|
||||
}
|
||||
|
||||
impl Bar : Foo {
|
||||
|
@ -5,7 +5,7 @@ struct r {
|
||||
}
|
||||
|
||||
impl r : Drop {
|
||||
fn finalize() {}
|
||||
fn finalize(&self) {}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -5,7 +5,7 @@ struct r {
|
||||
}
|
||||
|
||||
impl r : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
*(self.i) = *(self.i) + 1;
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ struct r {
|
||||
fn r(i:int) -> r { r { i: i } }
|
||||
|
||||
impl r : Drop {
|
||||
fn finalize() {}
|
||||
fn finalize(&self) {}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -5,7 +5,7 @@ struct R {
|
||||
}
|
||||
|
||||
impl R : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
let _y = R { b: self.b };
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ struct and_then_get_big_again {
|
||||
}
|
||||
|
||||
impl and_then_get_big_again : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
fn getbig(i: int) {
|
||||
if i != 0 {
|
||||
getbig(i - 1);
|
||||
|
@ -18,7 +18,7 @@ struct and_then_get_big_again {
|
||||
}
|
||||
|
||||
impl and_then_get_big_again : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
fn getbig(i: int) {
|
||||
if i != 0 {
|
||||
getbig(i - 1);
|
||||
|
@ -18,7 +18,7 @@ struct and_then_get_big_again {
|
||||
}
|
||||
|
||||
impl and_then_get_big_again : Drop {
|
||||
fn finalize() {}
|
||||
fn finalize(&self) {}
|
||||
}
|
||||
|
||||
fn and_then_get_big_again(x:int) -> and_then_get_big_again {
|
||||
|
@ -8,7 +8,7 @@ struct r {
|
||||
// failed has no effect and the process exits with the
|
||||
// runtime's exit code
|
||||
impl r : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
os::set_exit_status(50);
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ struct r {
|
||||
}
|
||||
|
||||
impl r : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
unsafe {
|
||||
let _v2: ~int = cast::reinterpret_cast(&self.v);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ struct faily_box {
|
||||
fn faily_box(i: @int) -> faily_box { faily_box { i: i } }
|
||||
|
||||
impl faily_box : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
fail ~"quux";
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ struct cat {
|
||||
|
||||
impl cat: Drop {
|
||||
#[cat_dropper]
|
||||
fn finalize() { error!("%s landed on hir feet",self.name); }
|
||||
fn finalize(&self) { error!("%s landed on hir feet",self.name); }
|
||||
}
|
||||
|
||||
|
||||
|
@ -7,7 +7,7 @@ impl cat : Drop {
|
||||
/**
|
||||
Actually, cats don't always land on their feet when you drop them.
|
||||
*/
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
error!("%s landed on hir feet", self.name);
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ struct cat {
|
||||
}
|
||||
|
||||
impl cat : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
self.done(self.meows);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ struct S<T> {
|
||||
}
|
||||
|
||||
impl<T> S<T> : core::ops::Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
io::println("bye");
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ struct Foo {
|
||||
}
|
||||
|
||||
impl Foo : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
io::println("bye");
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ struct r {
|
||||
}
|
||||
|
||||
impl r : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
*(self.i) = *(self.i) + 1;
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ struct socket {
|
||||
}
|
||||
|
||||
impl socket : Drop {
|
||||
fn finalize() {}
|
||||
fn finalize(&self) {}
|
||||
}
|
||||
|
||||
impl socket {
|
||||
|
@ -6,7 +6,7 @@ struct Font {
|
||||
}
|
||||
|
||||
impl Font : Drop {
|
||||
fn finalize() {}
|
||||
fn finalize(&self) {}
|
||||
}
|
||||
|
||||
fn Font() -> Font {
|
||||
|
@ -144,7 +144,7 @@ mod pipes {
|
||||
}
|
||||
|
||||
impl<T: Send> send_packet<T> : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
if self.p != None {
|
||||
let mut p = None;
|
||||
p <-> self.p;
|
||||
@ -172,7 +172,7 @@ mod pipes {
|
||||
}
|
||||
|
||||
impl<T: Send> recv_packet<T> : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
if self.p != None {
|
||||
let mut p = None;
|
||||
p <-> self.p;
|
||||
|
@ -4,7 +4,7 @@ struct defer {
|
||||
}
|
||||
|
||||
impl defer : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
*(self.b) = true;
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ struct defer {
|
||||
}
|
||||
|
||||
impl defer : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
*(self.b) = true;
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ struct Kitty {
|
||||
}
|
||||
|
||||
impl Kitty : Drop {
|
||||
fn finalize() {}
|
||||
fn finalize(&self) {}
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
|
@ -1,7 +1,7 @@
|
||||
struct thing { x: int, }
|
||||
|
||||
impl thing : Drop {
|
||||
fn finalize() {}
|
||||
fn finalize(&self) {}
|
||||
}
|
||||
|
||||
fn thing() -> thing {
|
||||
|
@ -3,7 +3,7 @@ struct r {
|
||||
}
|
||||
|
||||
impl r : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
*(self.b) += 1;
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ struct dtor {
|
||||
}
|
||||
|
||||
impl dtor : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
// abuse access to shared mutable state to write this code
|
||||
*self.x -= 1;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ struct Buffer {
|
||||
}
|
||||
|
||||
impl Buffer : Drop {
|
||||
fn finalize() {}
|
||||
fn finalize(&self) {}
|
||||
}
|
||||
|
||||
proto! double_buffer (
|
||||
|
@ -3,7 +3,7 @@ struct r {
|
||||
}
|
||||
|
||||
impl r : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
*(self.i) += 1;
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ struct r {
|
||||
}
|
||||
|
||||
impl r : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
unsafe {
|
||||
debug!("r's dtor: self = %x, self.v = %x, self.v's value = %x",
|
||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(&self)),
|
||||
|
@ -11,7 +11,7 @@ struct r {
|
||||
}
|
||||
|
||||
impl r : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
unsafe {
|
||||
let v2: ~int = cast::reinterpret_cast(&self.v.c);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ struct r {
|
||||
}
|
||||
|
||||
impl r : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
unsafe {
|
||||
let _v2: ~int = cast::reinterpret_cast(&self.v.c);
|
||||
// let _v3: ~int = unsafe::reinterpret_cast(self.x);
|
||||
|
@ -3,7 +3,7 @@ struct shrinky_pointer {
|
||||
}
|
||||
|
||||
impl shrinky_pointer : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
log(error, ~"Hello!"); **(self.i) -= 1;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ struct finish<T: Copy> {
|
||||
}
|
||||
|
||||
impl<T: Copy> finish<T> : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
self.arg.fin(self.arg.val);
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ struct close_res {
|
||||
}
|
||||
|
||||
impl close_res : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
*(self.i) = false;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ struct test {
|
||||
}
|
||||
|
||||
impl test : Drop {
|
||||
fn finalize() {}
|
||||
fn finalize(&self) {}
|
||||
}
|
||||
|
||||
fn test(f: int) -> test {
|
||||
|
@ -3,7 +3,7 @@ struct foo {
|
||||
}
|
||||
|
||||
impl foo : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
error!("%s", self.x);
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ struct notify {
|
||||
}
|
||||
|
||||
impl notify : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
error!("notify: task=%? v=%x unwinding=%b b=%b",
|
||||
task::get_task(),
|
||||
ptr::addr_of(&(*(self.v))) as uint,
|
||||
|
@ -10,7 +10,7 @@ struct notify {
|
||||
}
|
||||
|
||||
impl notify : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
error!("notify: task=%? v=%x unwinding=%b b=%b",
|
||||
task::get_task(),
|
||||
ptr::addr_of(&(*(self.v))) as uint,
|
||||
|
@ -10,7 +10,7 @@ struct r {
|
||||
}
|
||||
|
||||
impl r : Drop {
|
||||
fn finalize() {}
|
||||
fn finalize(&self) {}
|
||||
}
|
||||
|
||||
fn r(i:int) -> r {
|
||||
|
@ -3,7 +3,7 @@ struct r {
|
||||
}
|
||||
|
||||
impl r : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
*(self.i) = *(self.i) + 1;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ struct complainer {
|
||||
}
|
||||
|
||||
impl complainer : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
error!("About to send!");
|
||||
comm::send(self.c, true);
|
||||
error!("Sent!");
|
||||
|
@ -6,7 +6,7 @@ struct complainer {
|
||||
}
|
||||
|
||||
impl complainer : Drop {
|
||||
fn finalize() {}
|
||||
fn finalize(&self) {}
|
||||
}
|
||||
|
||||
fn complainer(c: @int) -> complainer {
|
||||
|
@ -4,7 +4,7 @@ struct foo {
|
||||
}
|
||||
|
||||
impl foo : Drop {
|
||||
fn finalize() {
|
||||
fn finalize(&self) {
|
||||
*self.x += 1;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user