kadmin | 2de9d67 | 2023-01-10 06:08:18 | [diff] [blame] | 1 | error[E0277]: the trait bound `fn() -> bool {example}: Foo` is not satisfied |
| 2 | --> $DIR/fn-trait-cast-diagnostic.rs:21:15 |
| 3 | | |
| 4 | LL | do_on_foo(example); |
| 5 | | --------- ^^^^^^^ the trait `Foo` is not implemented for fn item `fn() -> bool {example}` |
| 6 | | | |
| 7 | | required by a bound introduced by this call |
| 8 | | |
| 9 | note: required by a bound in `do_on_foo` |
| 10 | --> $DIR/fn-trait-cast-diagnostic.rs:17:22 |
| 11 | | |
| 12 | LL | fn do_on_foo(v: impl Foo) {} |
| 13 | | ^^^ required by this bound in `do_on_foo` |
| 14 | help: use parentheses to call this function |
| 15 | | |
| 16 | LL | do_on_foo(example()); |
| 17 | | ++ |
| 18 | help: the trait `Foo` is implemented for fn pointer `fn() -> bool`, try casting using `as` |
| 19 | | |
| 20 | LL | do_on_foo(example as fn() -> bool); |
| 21 | | +++++++++++++++ |
| 22 | |
| 23 | error[E0277]: the trait bound `fn() -> bool {example}: NoOtherFoo` is not satisfied |
| 24 | --> $DIR/fn-trait-cast-diagnostic.rs:24:22 |
| 25 | | |
| 26 | LL | do_on_single_foo(example); |
| 27 | | ---------------- ^^^^^^^ the trait `NoOtherFoo` is not implemented for fn item `fn() -> bool {example}` |
| 28 | | | |
| 29 | | required by a bound introduced by this call |
| 30 | | |
| 31 | note: required by a bound in `do_on_single_foo` |
| 32 | --> $DIR/fn-trait-cast-diagnostic.rs:18:29 |
| 33 | | |
| 34 | LL | fn do_on_single_foo(v: impl NoOtherFoo) {} |
| 35 | | ^^^^^^^^^^ required by this bound in `do_on_single_foo` |
| 36 | help: the trait `NoOtherFoo` is implemented for fn pointer `fn() -> bool`, try casting using `as` |
| 37 | | |
| 38 | LL | do_on_single_foo(example as fn() -> bool); |
| 39 | | +++++++++++++++ |
| 40 | |
| 41 | error: aborting due to 2 previous errors |
| 42 | |
| 43 | For more information about this error, try `rustc --explain E0277`. |