Skip to content

Commit

Permalink
auto merge of rust-lang#7269 : luqmana/rust/drop, r=thestinger
Browse files Browse the repository at this point in the history
Finally rename finalize to drop.
Closes rust-lang#4332.
  • Loading branch information
bors committed Jun 26, 2013
2 parents e9ac719 + ca2966c commit 22408d9
Show file tree
Hide file tree
Showing 127 changed files with 155 additions and 155 deletions.
2 changes: 1 addition & 1 deletion doc/tutorial-ffi.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl<T: Owned> Unique<T> {
#[unsafe_destructor]
impl<T: Owned> Drop for Unique<T> {
fn finalize(&self) {
fn drop(&self) {
unsafe {
let x = intrinsics::init(); // dummy value to swap in
// moving the object out is needed to call the destructor
Expand Down
6 changes: 3 additions & 3 deletions doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -2010,7 +2010,7 @@ types by the compiler, and may not be overridden:
> iterations of the language, and often still are.
Additionally, the `Drop` trait is used to define destructors. This
trait defines one method called `finalize`, which is automatically
trait defines one method called `drop`, which is automatically
called when a value of the type that implements this trait is
destroyed, either because the value went out of scope or because the
garbage collector reclaimed it.
Expand All @@ -2021,15 +2021,15 @@ struct TimeBomb {
}
impl Drop for TimeBomb {
fn finalize(&self) {
fn drop(&self) {
for self.explosivity.times {
println("blam!");
}
}
}
~~~

It is illegal to call `finalize` directly. Only code inserted by the compiler
It is illegal to call `drop` directly. Only code inserted by the compiler
may call it.

## Declaring and implementing traits
Expand Down
2 changes: 1 addition & 1 deletion src/etc/vim/syntax/rust.vim
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ syn keyword rustOperator as

syn match rustAssert "\<assert\(\w\)*!"
syn match rustFail "\<fail\(\w\)*!"
syn keyword rustKeyword break copy do drop extern
syn keyword rustKeyword break copy do extern
syn keyword rustKeyword for if impl let log
syn keyword rustKeyword copy do extern
syn keyword rustKeyword for impl let log
Expand Down
2 changes: 1 addition & 1 deletion src/libextra/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ struct PoisonOnFail {
}

impl Drop for PoisonOnFail {
fn finalize(&self) {
fn drop(&self) {
unsafe {
/* assert!(!*self.failed);
-- might be false in case of cond.wait() */
Expand Down
2 changes: 1 addition & 1 deletion src/libextra/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub struct Arena {

#[unsafe_destructor]
impl Drop for Arena {
fn finalize(&self) {
fn drop(&self) {
unsafe {
destroy_chunk(&self.head);
for self.chunks.each |chunk| {
Expand Down
2 changes: 1 addition & 1 deletion src/libextra/c_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct DtorRes {

#[unsafe_destructor]
impl Drop for DtorRes {
fn finalize(&self) {
fn drop(&self) {
match self.dtor {
option::None => (),
option::Some(f) => f()
Expand Down
2 changes: 1 addition & 1 deletion src/libextra/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub struct Future<A> {
// over ~fn's that have pipes and so forth within!
#[unsafe_destructor]
impl<A> Drop for Future<A> {
fn finalize(&self) {}
fn drop(&self) {}
}

priv enum FutureState<A> {
Expand Down
2 changes: 1 addition & 1 deletion src/libextra/net_tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub struct TcpSocket {

#[unsafe_destructor]
impl Drop for TcpSocket {
fn finalize(&self) {
fn drop(&self) {
tear_down_socket_data(self.socket_data)
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/libextra/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl<T> Rc<T> {

#[unsafe_destructor]
impl<T> Drop for Rc<T> {
fn finalize(&self) {
fn drop(&self) {
unsafe {
if self.ptr.is_not_null() {
(*self.ptr).count -= 1;
Expand Down Expand Up @@ -220,7 +220,7 @@ impl<T> RcMut<T> {

#[unsafe_destructor]
impl<T> Drop for RcMut<T> {
fn finalize(&self) {
fn drop(&self) {
unsafe {
if self.ptr.is_not_null() {
(*self.ptr).count -= 1;
Expand Down
2 changes: 1 addition & 1 deletion src/libextra/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,7 @@ mod big_tests {

#[unsafe_destructor]
impl<'self> Drop for LVal<'self> {
fn finalize(&self) {
fn drop(&self) {
let x = unsafe { local_data::local_data_get(self.key) };
match x {
Some(@y) => {
Expand Down
16 changes: 8 additions & 8 deletions src/libextra/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ struct SemReleaseGeneric<'self, Q> { sem: &'self Sem<Q> }
#[doc(hidden)]
#[unsafe_destructor]
impl<'self, Q:Owned> Drop for SemReleaseGeneric<'self, Q> {
fn finalize(&self) {
fn drop(&self) {
self.sem.release();
}
}
Expand Down Expand Up @@ -219,7 +219,7 @@ pub struct Condvar<'self> {
}

#[unsafe_destructor]
impl<'self> Drop for Condvar<'self> { fn finalize(&self) {} }
impl<'self> Drop for Condvar<'self> { fn drop(&self) {} }

impl<'self> Condvar<'self> {
/**
Expand Down Expand Up @@ -295,7 +295,7 @@ impl<'self> Condvar<'self> {

#[unsafe_destructor]
impl<'self> Drop for CondvarReacquire<'self> {
fn finalize(&self) {
fn drop(&self) {
unsafe {
// Needs to succeed, instead of itself dying.
do task::unkillable {
Expand Down Expand Up @@ -689,7 +689,7 @@ struct RWlockReleaseRead<'self> {
#[doc(hidden)]
#[unsafe_destructor]
impl<'self> Drop for RWlockReleaseRead<'self> {
fn finalize(&self) {
fn drop(&self) {
unsafe {
do task::unkillable {
let state = &mut *self.lock.state.get();
Expand Down Expand Up @@ -726,7 +726,7 @@ struct RWlockReleaseDowngrade<'self> {
#[doc(hidden)]
#[unsafe_destructor]
impl<'self> Drop for RWlockReleaseDowngrade<'self> {
fn finalize(&self) {
fn drop(&self) {
unsafe {
do task::unkillable {
let writer_or_last_reader;
Expand Down Expand Up @@ -769,12 +769,12 @@ fn RWlockReleaseDowngrade<'r>(lock: &'r RWlock)
/// The "write permission" token used for rwlock.write_downgrade().
pub struct RWlockWriteMode<'self> { priv lock: &'self RWlock }
#[unsafe_destructor]
impl<'self> Drop for RWlockWriteMode<'self> { fn finalize(&self) {} }
impl<'self> Drop for RWlockWriteMode<'self> { fn drop(&self) {} }

/// The "read permission" token used for rwlock.write_downgrade().
pub struct RWlockReadMode<'self> { priv lock: &'self RWlock }
#[unsafe_destructor]
impl<'self> Drop for RWlockReadMode<'self> { fn finalize(&self) {} }
impl<'self> Drop for RWlockReadMode<'self> { fn drop(&self) {} }

impl<'self> RWlockWriteMode<'self> {
/// Access the pre-downgrade rwlock in write mode.
Expand Down Expand Up @@ -1105,7 +1105,7 @@ mod tests {
}

impl Drop for SendOnFailure {
fn finalize(&self) {
fn drop(&self) {
self.c.send(());
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/libextra/task_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub struct TaskPool<T> {

#[unsafe_destructor]
impl<T> Drop for TaskPool<T> {
fn finalize(&self) {
fn drop(&self) {
for self.channels.iter().advance |channel| {
channel.send(Quit);
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/back/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct PassManager {
}

impl Drop for PassManager {
fn finalize(&self) {
fn drop(&self) {
unsafe {
llvm::LLVMDisposePassManager(self.llpm);
}
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/lib/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2216,7 +2216,7 @@ pub struct target_data_res {
}

impl Drop for target_data_res {
fn finalize(&self) {
fn drop(&self) {
unsafe {
llvm::LLVMDisposeTargetData(self.TD);
}
Expand Down Expand Up @@ -2253,7 +2253,7 @@ pub struct pass_manager_res {
}

impl Drop for pass_manager_res {
fn finalize(&self) {
fn drop(&self) {
unsafe {
llvm::LLVMDisposePassManager(self.PM);
}
Expand Down Expand Up @@ -2289,7 +2289,7 @@ pub struct object_file_res {
}

impl Drop for object_file_res {
fn finalize(&self) {
fn drop(&self) {
unsafe {
llvm::LLVMDisposeObjectFile(self.ObjectFile);
}
Expand Down Expand Up @@ -2326,7 +2326,7 @@ pub struct section_iter_res {
}

impl Drop for section_iter_res {
fn finalize(&self) {
fn drop(&self) {
unsafe {
llvm::LLVMDisposeSectionIterator(self.SI);
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub struct _InsnCtxt { _x: () }

#[unsafe_destructor]
impl Drop for _InsnCtxt {
fn finalize(&self) {
fn drop(&self) {
unsafe {
do local_data::local_data_modify(task_local_insn_key) |c| {
do c.map_consume |@ctx| {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub struct BuilderRef_res {
}

impl Drop for BuilderRef_res {
fn finalize(&self) {
fn drop(&self) {
unsafe {
llvm::LLVMDisposeBuilder(self.B);
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ impl CrateContext {

#[unsafe_destructor]
impl Drop for CrateContext {
fn finalize(&self) {
fn drop(&self) {
unsafe {
unset_task_llcx();
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ pub fn monitor(f: ~fn(diagnostic::Emitter)) {
}

impl Drop for finally {
fn finalize(&self) { self.ch.send(done); }
fn drop(&self) { self.ch.send(done); }
}

let _finally = finally { ch: ch };
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/util/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub struct _indenter {
}

impl Drop for _indenter {
fn finalize(&self) { debug!("<<"); }
fn drop(&self) { debug!("<<"); }
}

pub fn _indenter(_i: ()) -> _indenter {
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ struct Bored {
}

impl Drop for Bored {
fn finalize(&self) { }
fn drop(&self) { }
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ struct Guard<'self, T, U> {

#[unsafe_destructor]
impl<'self, T, U> Drop for Guard<'self, T, U> {
fn finalize(&self) {
fn drop(&self) {
unsafe {
debug!("Guard: popping handler from TLS");
let curr = local_data_pop(self.cond.key);
Expand Down
6 changes: 3 additions & 3 deletions src/libstd/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@ impl FILERes {
}

impl Drop for FILERes {
fn finalize(&self) {
fn drop(&self) {
unsafe {
libc::fclose(self.f);
}
Expand Down Expand Up @@ -1234,7 +1234,7 @@ impl FdRes {
}

impl Drop for FdRes {
fn finalize(&self) {
fn drop(&self) {
unsafe {
libc::close(self.fd);
}
Expand Down Expand Up @@ -1772,7 +1772,7 @@ pub mod fsync {

#[unsafe_destructor]
impl<T:Copy> Drop for Res<T> {
fn finalize(&self) {
fn drop(&self) {
match self.arg.opt_level {
None => (),
Some(level) => {
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#[lang="drop"]
pub trait Drop {
fn finalize(&self); // FIXME(#4332): Rename to "drop"? --pcwalton
fn drop(&self);
}

#[lang="add"]
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ fn test_unwrap_resource() {

#[unsafe_destructor]
impl ::ops::Drop for R {
fn finalize(&self) { *(self.i) += 1; }
fn drop(&self) { *(self.i) += 1; }
}

fn R(i: @mut int) -> R {
Expand Down
6 changes: 3 additions & 3 deletions src/libstd/pipes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ struct BufferResource<T> {

#[unsafe_destructor]
impl<T> Drop for BufferResource<T> {
fn finalize(&self) {
fn drop(&self) {
unsafe {
// FIXME(#4330) Need self by value to get mutability.
let this: &mut BufferResource<T> = transmute_mut(self);
Expand Down Expand Up @@ -672,7 +672,7 @@ pub struct SendPacketBuffered<T, Tbuffer> {

#[unsafe_destructor]
impl<T:Owned,Tbuffer:Owned> Drop for SendPacketBuffered<T,Tbuffer> {
fn finalize(&self) {
fn drop(&self) {
unsafe {
let this: &mut SendPacketBuffered<T,Tbuffer> = transmute(self);
if this.p != None {
Expand Down Expand Up @@ -730,7 +730,7 @@ pub struct RecvPacketBuffered<T, Tbuffer> {

#[unsafe_destructor]
impl<T:Owned,Tbuffer:Owned> Drop for RecvPacketBuffered<T,Tbuffer> {
fn finalize(&self) {
fn drop(&self) {
unsafe {
let this: &mut RecvPacketBuffered<T,Tbuffer> = transmute(self);
if this.p != None {
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/rt/comm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ impl<T> Peekable<T> for PortOne<T> {

#[unsafe_destructor]
impl<T> Drop for ChanOneHack<T> {
fn finalize(&self) {
fn drop(&self) {
if self.suppress_finalize { return }

unsafe {
Expand All @@ -249,7 +249,7 @@ impl<T> Drop for ChanOneHack<T> {

#[unsafe_destructor]
impl<T> Drop for PortOneHack<T> {
fn finalize(&self) {
fn drop(&self) {
if self.suppress_finalize { return }

unsafe {
Expand Down
Loading

0 comments on commit 22408d9

Please sign in to comment.