]> git.proxmox.com Git - rustc.git/blob - src/test/ui/issues/issue-57843.rs
New upstream version 1.66.0+dfsg1
[rustc.git] / src / test / ui / issues / issue-57843.rs
1 // Regression test for an ICE that occurred with the universes code:
2 //
3 // The signature of the closure `|_|` was being inferred to
4 // `exists<'r> fn(&'r u8)`. This should result in a type error since
5 // the signature `for<'r> fn(&'r u8)` is required. However, due to a
6 // bug in the type variable generalization code, the placeholder for
7 // `'r` was leaking out into the writeback phase, causing an ICE.
8
9 trait ClonableFn<T> {
10 fn clone(&self) -> Box<dyn Fn(T)>;
11 }
12
13 impl<T, F: 'static> ClonableFn<T> for F
14 where
15 F: Fn(T) + Clone,
16 {
17 fn clone(&self) -> Box<dyn Fn(T)> {
18 Box::new(self.clone())
19 }
20 }
21
22 struct Foo(Box<dyn for<'a> ClonableFn<&'a bool>>);
23
24 fn main() {
25 Foo(Box::new(|_| ())); //~ ERROR implementation of `FnOnce` is not general enough
26 }