]> git.lizzy.rs Git - rust.git/blob - tests/ui/unsized/box-instead-of-dyn-fn.rs
Auto merge of #106711 - albertlarsan68:use-ci-llvm-when-lld, r=jyn514
[rust.git] / tests / ui / unsized / box-instead-of-dyn-fn.rs
1 use std::fmt::Debug;
2
3 // Test to suggest boxing the return type, and the closure branch of the `if`
4
5 fn print_on_or_the_other<'a>(a: i32, b: &'a String) -> dyn Fn() + 'a {
6     //~^ ERROR return type cannot have an unboxed trait object
7     if a % 2 == 0 {
8         move || println!("{a}")
9     } else {
10         Box::new(move || println!("{}", b))
11         //~^ ERROR `if` and `else` have incompatible types
12     }
13 }
14
15 fn main() {}