Closed
Description
In a.rs
#![crate_type = "lib"]
pub struct X(pub u8);
impl Drop for X {
fn drop(&mut self) {
println!("{}", self.0);
}
}
pub fn f(x: &mut X, g: fn()) {
x.0 = 1;
g();
x.0 = 0;
}
In b.rs
extern crate a;
fn main() {
a::f(&mut a::X(0), g);
}
fn g() {
panic!();
}
$ rustc -O a.rs && rustc -L . b.rs && ./b
thread '<main>' panicked at 'explicit panic', b.rs:8
0
$ rustc a.rs && rustc -L . b.rs && ./b
thread '<main>' panicked at 'explicit panic', b.rs:8
1
$ rustc -V
rustc 1.6.0-nightly (2e07996a9 2015-10-29)
NB: Some pre-1.0 nightlies already behaved this way.