summary refs log tree commit diff
path: root/src/libstd/sys/unix/stack_overflow.rs
diff options
context:
space:
mode:
authorSimonas Kazlauskas <git@kazlauskas.me>2016-01-30 00:18:47 +0200
committerSimonas Kazlauskas <git@kazlauskas.me>2016-02-04 15:56:05 +0200
commit98265d338556e32c8ab1f89e14c0b3fab6e52001 (patch)
tree36b5cca413a599d71a461718d10c67f05f9a5dd1 /src/libstd/sys/unix/stack_overflow.rs
parent65dd5e6a84aa8d9af477f21fa9797e3d0774a2c1 (diff)
downloadrust-98265d338556e32c8ab1f89e14c0b3fab6e52001.tar.gz
rust-98265d338556e32c8ab1f89e14c0b3fab6e52001.zip
Convert Drop statement into terminator
The structure of the old translator as well as MIR assumed that drop glue cannot possibly panic and
translated the drops accordingly. However, in presence of `Drop::drop` this assumption can be
trivially shown to be untrue. As such, the Rust code like the following would never print number 2:

```rust
struct Droppable(u32);
impl Drop for Droppable {
    fn drop(&mut self) {
        if self.0 == 1 { panic!("Droppable(1)") } else { println!("{}", self.0) }
    }
}
fn main() {
    let x = Droppable(2);
    let y = Droppable(1);
}
```

While the behaviour is allowed according to the language rules (we allow drops to not run), that’s
a very counter-intuitive behaviour. We fix this in MIR by allowing `Drop` to have a target to take
on divergence and connect the drops in such a way so the leftover drops are executed when some drop
unwinds.

Note, that this commit still does not implement the translator part of changes necessary for the
grand scheme of things to fully work, so the actual observed behaviour does not change yet. Coming
soon™.

See #14875.
Diffstat (limited to 'src/libstd/sys/unix/stack_overflow.rs')
0 files changed, 0 insertions, 0 deletions