]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-57843.rs
Rollup merge of #62337 - Mark-Simulacrum:fix-cpu-usage-script, r=alexcrichton
[rust.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 F: Fn(T) + Clone {
15     fn clone(&self) -> Box<dyn Fn(T)> {
16         Box::new(self.clone())
17     }
18 }
19
20 struct Foo(Box<dyn for<'a> ClonableFn<&'a bool>>);
21
22 fn main() {
23     Foo(Box::new(|_| ())); //~ ERROR mismatched types
24 }