Open
Description
Code
#[derive(Debug)]
struct A();
fn main(){
dbg!(A);
}
Current output
error[E0277]: `fn() -> A {A}` doesn't implement `Debug`
--> src/main.rs:5:5
|
2 | struct A();
| -------- consider calling the constructor for `A`
...
5 | dbg!(A);
| ^^^^^^^ `fn() -> A {A}` cannot be formatted using `{:?}` because it doesn't implement `Debug`
|
= help: the trait `Debug` is not implemented for fn item `fn() -> A {A}`
= help: use parentheses to construct this tuple struct: `A()`
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
For more information about this error, try `rustc --explain E0277`.
error: could not compile `playground` (bin "playground") due to previous error
Desired output
error[E0423]: expected value, found struct `A`
Rationale and extra context
Since i never defined a function, it seems odd to get errors mentioning the function signature. While the example code is pretty clean, in more complex cases this can be a very confusing message
Other cases
consider the following error a user of the Bevy game engine received and was confused by, where there is no hint of the Person struct needing to be instantiated.
#[derive(Component)]
struct Name(String);
#[derive(Component)]
struct Person();
fn add_people(mut commands: Commands) {
commands.spawn((Name("Test".to_string()), Person));
}
error[E0277]: the trait bound `(fn() -> Person {Person}, Name): Bundle` is not satisfied
--> src\main.rs:10:20
|
10 | commands.spawn((Person, Name("Test".to_string())));
| ----- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bundle` is not implemented for `(fn() -> Person {Person}, Name)`
| |
| required by a bound introduced by this call
|
= help: the following other types implement trait `Bundle`:
()
(B0, B1)
(B0, B1, B2)
(B0, B1, B2, B3)
(B0, B1, B2, B3, B4)
(B0, B1, B2, B3, B4, B5)
(B0, B1, B2, B3, B4, B5, B6)
(B0, B1, B2, B3, B4, B5, B6, B7)
and 8 others
note: required by a bound in `bevy::prelude::Commands::<'w, 's>::spawn`
Anything else?
No response