discord-mods-bot
discord-mods-bot copied to clipboard
`?eval` command produces less than ideal error messages due to the way the code is generated
Because it puts everything on the same line, you get the "irrelevant" surrounding code as part of your error message.
?eval `let () = 1;`
error[E0308]: mismatched types
--> src/main.rs:1:34
|
1 | fn main(){ println!("{:?}",{ let () = 1;
| ^^ - this expression has type `{integer}`
| |
| expected integer, found `()`
The fn main(){ println!("{:?}",{ is irrelevant to my mistake and is just noise when you're trying to parse the error output. By putting the provided code on its own line, you could instead get an error message like
error[E0308]: mismatched types
--> src/main.rs:2:5
|
2 | let () = 1;
| ^^ - this expression has type `{integer}`
| |
| expected integer, found `()`
(I produced this second output by doing ?eval with a code block with a blank line before the code itself.)