2025-07-24 19:07:20 +05:00
|
|
|
//! Regression test for https://github.com/rust-lang/rust/issues/15858
|
|
|
|
|
|
2018-08-30 14:18:55 +02:00
|
|
|
//@ run-pass
|
2024-08-24 06:49:09 +03:00
|
|
|
// FIXME(static_mut_refs): this could use an atomic
|
|
|
|
|
#![allow(static_mut_refs)]
|
2014-07-30 17:47:54 -07:00
|
|
|
static mut DROP_RAN: bool = false;
|
|
|
|
|
|
2015-02-12 10:29:52 -05:00
|
|
|
trait Bar {
|
2024-02-07 10:42:01 +08:00
|
|
|
fn do_something(&mut self); //~ WARN method `do_something` is never used
|
2014-07-30 17:47:54 -07:00
|
|
|
}
|
|
|
|
|
|
2015-02-12 10:29:52 -05:00
|
|
|
struct BarImpl;
|
2014-07-30 17:47:54 -07:00
|
|
|
|
2015-02-12 10:29:52 -05:00
|
|
|
impl Bar for BarImpl {
|
2014-07-30 17:47:54 -07:00
|
|
|
fn do_something(&mut self) {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-12-27 17:11:58 -05:00
|
|
|
struct Foo<B: Bar>(#[allow(dead_code)] B);
|
2014-07-30 17:47:54 -07:00
|
|
|
|
2015-02-12 10:29:52 -05:00
|
|
|
impl<B: Bar> Drop for Foo<B> {
|
2014-07-30 17:47:54 -07:00
|
|
|
fn drop(&mut self) {
|
|
|
|
|
unsafe {
|
|
|
|
|
DROP_RAN = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
|
{
|
2015-02-12 10:29:52 -05:00
|
|
|
let _x: Foo<BarImpl> = Foo(BarImpl);
|
2014-07-30 17:47:54 -07:00
|
|
|
}
|
|
|
|
|
unsafe {
|
|
|
|
|
assert_eq!(DROP_RAN, true);
|
|
|
|
|
}
|
|
|
|
|
}
|