# Moves from \`self\` during the drop hook

**URL:** <https://internals.rust-lang.org/t/moves-from-self-during-the-drop-hook/1536>\
**Category:** ideas (deprecated)\
**Created:** [February 4, 2015, 4:53am UTC](https://internals.rust-lang.org/t/moves-from-self-during-the-drop-hook/1536 "2015-02-04T04:53:30Z")\
**Posts on this page:** 1\
**Showing post:** 18

<div class="post-metadata">

**Author:** ![pnkfelix](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/pnkfelix/32/110_2.png) [@pnkfelix](https://internals.rust-lang.org/u/pnkfelix)\
**Post date:** [February 10, 2015, 8:12am UTC](https://internals.rust-lang.org/t/moves-from-self-during-the-drop-hook/1536/18 "2015-02-10T08:12:23Z")

</div>

@Ericson2314 With either option, you need some sort of magic. I thnk you are under-estimating the amount of magic necessary to support drop-consuming `T` properly.

You are either going to impose rules like "you cannot move out of `self` in the context of `fn drop`" (which to me seems much the same as `Interior<T>`, or you are going to need some sort of ad-hoc analysis to determine which instances of `T` should not have their destructor invoked.

As a quick example scenario, consider a destructor for T that can create other T’s:

```rust
#[derive(Debug)]
struct Tick { countdown: u32 }

impl Drop for Tick {
    fn drop(&mut self) {
        let t;
        let s = self;
        println!("dropping {:?}", s) {
        if s.countdown > 0 {
            t = Tick { countdown: s.countdown - 1 };
            println!("created {:?}", t);
        }
        println!("done dropping {:?}", s);
    }
}

fn main() {
    let _spoon = Tick { countdown: 3 };
}

```

In the above code, if we solely changed the signature to `fn drop(self)` and made no other changes, then you would need an analysis to distinguish cases like `t` whose destructor should be invoked, versus cases like `s` where doing so would cause infinite regress. (The easiest way to eliminate the above scenario is to disallow moves out of `self` within `fn drop`, but again, what’s the difference between that rule and adding `Interior<T>` as an explicit form of it?

---

_[View the full topic](https://internals.rust-lang.org/t/moves-from-self-during-the-drop-hook/1536)._
