2021-01-17 16:48:52 -08:00
|
|
|
// run-rustfix
|
2023-03-29 22:18:20 +02:00
|
|
|
|
2023-05-19 11:25:35 +02:00
|
|
|
#![allow(dropping_references)]
|
2023-03-29 22:18:20 +02:00
|
|
|
|
2012-11-05 17:50:01 -08:00
|
|
|
struct Foo {
|
2015-01-08 21:54:35 +11:00
|
|
|
x: isize
|
2012-11-05 17:50:01 -08:00
|
|
|
}
|
|
|
|
|
2021-01-17 16:48:52 -08:00
|
|
|
#[allow(drop_bounds)]
|
|
|
|
trait Bar: Drop {
|
2013-03-12 19:32:14 -07:00
|
|
|
fn blah(&self);
|
2012-11-05 17:50:01 -08:00
|
|
|
}
|
|
|
|
|
2013-02-14 11:47:00 -08:00
|
|
|
impl Drop for Foo {
|
2013-09-16 21:18:07 -04:00
|
|
|
fn drop(&mut self) {
|
2014-01-09 21:06:55 +11:00
|
|
|
println!("kaboom");
|
2012-11-05 17:50:01 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-14 11:47:00 -08:00
|
|
|
impl Bar for Foo {
|
2013-03-12 19:32:14 -07:00
|
|
|
fn blah(&self) {
|
2014-12-05 15:53:30 -08:00
|
|
|
self.drop(); //~ ERROR explicit use of destructor method
|
2012-11-05 17:50:01 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let x = Foo { x: 3 };
|
2021-01-17 16:48:52 -08:00
|
|
|
println!("{}", x.x);
|
2012-11-05 17:50:01 -08:00
|
|
|
}
|