Open
Description
I tried this code:
pub struct Droppy<T, F: FnMut(&mut T)> {
inner: T,
callback: F,
}
impl<T, F: FnMut(&mut T)> Drop for Droppy<T, F> {
fn drop(&mut self) {
(self.callback)(&mut self.inner);
}
}
impl<T, F: FnMut(&mut T)> Droppy<T, F> {
pub fn new(inner: T, callback: F) -> Self {
Droppy { inner, callback }
}
pub fn force(&mut self) {
(self.callback)(&mut self.inner);
}
}
fn main(){
let mut d = Droppy::new(42, |_| assert_eq!(1,2));
d.force();
}
#[test]
fn droppy() {
main()
}
running this with cargo run
works fine. I get an assertion failure because 1 isn't 2.
But when I run cargo test
I expected to see this happen:
assertion failure because 1 isn't 2
Instead, this happened:
running 1 test
thread panicked while panicking. aborting.
error: test failed, to rerun pass '--bin broken-case'
Caused by:
process didn't exit successfully: `.../target/debug/deps/broken_case-77184cc870a0dee1` (signal: 4, SIGILL: illegal instruction)
Meta
rustc --version --verbose
:
rustc 1.50.0 (cb75ad5db 2021-02-10)
binary: rustc
commit-hash: cb75ad5db02783e8b0222fee363c5f63f7e2cf5b
commit-date: 2021-02-10
host: x86_64-unknown-linux-gnu
release: 1.50.0
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
No status