]> git.lizzy.rs Git - rust.git/blob - src/test/ui/implied-bounds/issue-100690.rs
Rollup merge of #106043 - c410-f3r:moar-errors, r=petrochenkov
[rust.git] / src / test / ui / implied-bounds / issue-100690.rs
1 // This code (probably) _should_ compile, but it currently does not because we
2 // are not smart enough about implied bounds.
3
4 use std::io;
5
6 fn real_dispatch<T, F>(f: F) -> Result<(), io::Error>
7 //~^ NOTE required by a bound in this
8 where
9     F: FnOnce(&mut UIView<T>) -> Result<(), io::Error> + Send + 'static,
10     //~^ NOTE required by this bound in `real_dispatch`
11     //~| NOTE required by a bound in `real_dispatch`
12 {
13     todo!()
14 }
15
16 #[derive(Debug)]
17 struct UIView<'a, T: 'a> {
18     _phantom: std::marker::PhantomData<&'a mut T>,
19 }
20
21 trait Handle<'a, T: 'a, V, R> {
22     fn dispatch<F>(&self, f: F) -> Result<(), io::Error>
23     where
24         F: FnOnce(&mut V) -> R + Send + 'static;
25 }
26
27 #[derive(Debug, Clone)]
28 struct TUIHandle<T> {
29     _phantom: std::marker::PhantomData<T>,
30 }
31
32 impl<'a, T: 'a> Handle<'a, T, UIView<'a, T>, Result<(), io::Error>> for TUIHandle<T> {
33     fn dispatch<F>(&self, f: F) -> Result<(), io::Error>
34     where
35         F: FnOnce(&mut UIView<'a, T>) -> Result<(), io::Error> + Send + 'static,
36     {
37         real_dispatch(f)
38         //~^ ERROR expected a `FnOnce<(&mut UIView<'_, T>,)>` closure, found `F`
39         //~| NOTE expected an `FnOnce<(&mut UIView<'_, T>,)>` closure, found `F`
40         //~| NOTE expected a closure with arguments
41         //~| NOTE required by a bound introduced by this call
42     }
43 }
44
45 fn main() {}