]> git.lizzy.rs Git - rust.git/blob - tests/ui/unsized/issue-91801.rs
Rollup merge of #106321 - compiler-errors:delayed-bug-backtrace, r=Nilstrieb
[rust.git] / tests / ui / unsized / issue-91801.rs
1 pub struct Something;
2
3 type Validator<'a> = dyn 'a + Send + Sync + Fn(&'a Something) -> Result<(), ()>;
4
5 pub static ALL_VALIDATORS: &[(&'static str, &'static Validator)] =
6     &[("validate that credits and debits balance", &validate_something)];
7
8 fn or<'a>(first: &'static Validator<'a>, second: &'static Validator<'a>) -> Validator<'a> {
9     //~^ ERROR return type cannot have an unboxed trait object
10     return Box::new(move |something: &'_ Something| -> Result<(), ()> {
11         first(something).or_else(|_| second(something))
12     });
13 }
14
15 fn validate_something(_: &Something) -> Result<(), ()> {
16     Ok(())
17 }
18
19 fn main() {}