diff options
| author | Kivooeo <Kivooeo123@gmail.com> | 2025-07-24 17:45:27 +0500 |
|---|---|---|
| committer | Kivooeo <Kivooeo123@gmail.com> | 2025-08-05 19:02:23 +0500 |
| commit | 62c92f30cf02fc56b8a774c77097f1111dc2f4ea (patch) | |
| tree | fe8c9846c6ca02b176ea9adcb8a348bd5ead1846 /tests/ui/fn_traits | |
| parent | 0f353363965ebf05e0757f7679c800b39c51a07e (diff) | |
| download | rust-62c92f30cf02fc56b8a774c77097f1111dc2f4ea.tar.gz rust-62c92f30cf02fc56b8a774c77097f1111dc2f4ea.zip | |
moved 35 tests to organized locations
Diffstat (limited to 'tests/ui/fn_traits')
| -rw-r--r-- | tests/ui/fn_traits/closure-trait-impl-14959.rs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/ui/fn_traits/closure-trait-impl-14959.rs b/tests/ui/fn_traits/closure-trait-impl-14959.rs new file mode 100644 index 00000000000..57af1207ff9 --- /dev/null +++ b/tests/ui/fn_traits/closure-trait-impl-14959.rs @@ -0,0 +1,54 @@ +//@ check-pass + +#![feature(fn_traits, unboxed_closures)] + +use std::ops::Fn; + +trait Response { fn dummy(&self) { } } +trait Request { fn dummy(&self) { } } +trait Ingot<R, S> { + fn enter(&mut self, _: &mut R, _: &mut S, a: &mut Alloy) -> Status; +} + +#[allow(dead_code)] +struct HelloWorld; + +struct SendFile; +struct Alloy; +enum Status { + Continue +} + +impl Alloy { + fn find<T>(&self) -> Option<T> { + None + } +} + +impl<'b> Fn<(&'b mut (dyn Response + 'b),)> for SendFile { + extern "rust-call" fn call(&self, (_res,): (&'b mut (dyn Response + 'b),)) {} +} + +impl<'b> FnMut<(&'b mut (dyn Response + 'b),)> for SendFile { + extern "rust-call" fn call_mut(&mut self, (_res,): (&'b mut (dyn Response+'b),)) { + self.call((_res,)) + } +} + +impl<'b> FnOnce<(&'b mut (dyn Response + 'b),)> for SendFile { + type Output = (); + + extern "rust-call" fn call_once(self, (_res,): (&'b mut (dyn Response+'b),)) { + self.call((_res,)) + } +} + +impl<Rq: Request, Rs: Response> Ingot<Rq, Rs> for HelloWorld { + fn enter(&mut self, _req: &mut Rq, res: &mut Rs, alloy: &mut Alloy) -> Status { + let send_file = alloy.find::<SendFile>().unwrap(); + send_file(res); + Status::Continue + } +} + +fn main() {} |
