2024-08-03 13:11:31 -05:00
|
|
|
//@ compile-flags: -Zvalidate-mir -Zinline-mir=yes
|
2024-03-24 07:07:30 -05:00
|
|
|
|
2024-08-03 14:33:02 -05:00
|
|
|
#![feature(unboxed_closures)]
|
2024-03-24 07:07:30 -05:00
|
|
|
|
2024-08-03 14:33:02 -05:00
|
|
|
use std::sync::Arc;
|
2024-03-24 07:07:30 -05:00
|
|
|
|
|
|
|
pub struct WeakOnce<T>();
|
2024-08-03 14:33:02 -05:00
|
|
|
//~^ ERROR type parameter `T` is never used
|
|
|
|
|
2024-03-24 07:07:30 -05:00
|
|
|
impl<T> WeakOnce<T> {
|
|
|
|
extern "rust-call" fn try_get(&self) -> Option<Arc<T>> {}
|
2024-08-03 14:33:02 -05:00
|
|
|
//~^ ERROR functions with the "rust-call" ABI must take a single non-self tuple argument
|
|
|
|
//~| ERROR mismatched types
|
2024-03-24 07:07:30 -05:00
|
|
|
|
|
|
|
pub fn get(&self) -> Arc<T> {
|
|
|
|
self.try_get()
|
|
|
|
.unwrap_or_else(|| panic!("Singleton {} not available", std::any::type_name::<T>()))
|
|
|
|
}
|
|
|
|
}
|
2024-08-03 14:33:02 -05:00
|
|
|
|
|
|
|
fn main() {}
|